LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Closing Microsoft edge using LabVIEW program

Solved!
Go to solution

I need a program that can close Microsoft Edge without terminating the task (Killing of task using command).

 

The program should gracefully close the application when run. If anyone has an idea on how to achieve this, please share. A hardcoded example would be appreciated.

 

I'm including a link from NI for closing applications, but it didn't work for me.

 

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YIRICA4&l=en-IN

0 Kudos
Message 1 of 12
(735 Views)

Test your code work on another program (i.e. Calculator).  Edge is problematic.  Turns out Microsoft Edge has an invisible character in the name.  You'll need to use a different method to get a window handle. There is a function called EnumWindows that should return a list of handles.  I'm not sure how to set it up.

 

For reference on the invisible character:

https://stackoverflow.com/questions/34927143/find-microsoft-edge-using-findwindow-api

 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 12
(710 Views)
Solution
Accepted by topic author Alwin_Capsys

Here is a link to a post about how to grab a list of windows and their associated handles. 

With Edge running, I ran it on my machine, and you can see the invisible character.

You'll just need to search the "Windows" array for 'Edge' and return the corresponding value from "Handles" array and feed this into the Send Message API call.

aputman_0-1721851153324.png

 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 3 of 12
(704 Views)

With this, how the application can be built? If you don't mind, can you share the program which made using this? 

0 Kudos
Message 4 of 12
(641 Views)

The code in the linked post is a snippet.  It can be dragged directly into a blank VI and the code will auto-populate. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 5 of 12
(636 Views)

Hi,

Once i get its handle number, how to add that to SendMessage API. Is this the way to add (below attached snippet)? Sorry, I am not familiar with calling API's. Is it possible to integrate the full and send for closing Microsoft Edge?

Download All
0 Kudos
Message 6 of 12
(620 Views)

Sorry, I do not know how to do it either.  I could probably figure it out but that is your job.  😉

I'm only referencing the articles mentioned above and offering suggestions. 

 

I would search for 'Edge', not the blank character. 

Does the Application Index array return the proper values associated with Edge?

If so, use those values to index the Handles array and pass that to the SendMessage API call.  You're not using the actual handle but rather the index value into the array of handles. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 7 of 12
(614 Views)

Yaa. Sorry. It was a mistake from my side. In curiosity I indexed like that. Later I connected properly, but the result was same.

Alwin_Capsys_0-1721924100793.png

 

0 Kudos
Message 8 of 12
(610 Views)

There are four parameters on SendMessage.  You're missing the one with the actual message (16 in decimal format or 10 in hex) 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 9 of 12
(606 Views)

I have configured 4 parameters. But I am not getting a 4 node function API as like the picture they have shown. I don't know why it is.

Alwin_Capsys_0-1721925248709.png

 

0 Kudos
Message 10 of 12
(595 Views)