07-24-2024 12:36 PM
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
Solved! Go to Solution.
07-24-2024 02:48 PM
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
07-24-2024 03:03 PM
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.
07-25-2024 09:58 AM
With this, how the application can be built? If you don't mind, can you share the program which made using this?
07-25-2024 10:02 AM
The code in the linked post is a snippet. It can be dragged directly into a blank VI and the code will auto-populate.
07-25-2024 10:45 AM
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?
07-25-2024 11:00 AM
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.
07-25-2024 11:15 AM
Yaa. Sorry. It was a mistake from my side. In curiosity I indexed like that. Later I connected properly, but the result was same.
07-25-2024 11:21 AM
There are four parameters on SendMessage. You're missing the one with the actual message (16 in decimal format or 10 in hex)
07-25-2024 11:34 AM
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.