b0x4it Posted July 7, 2011 Share Posted July 7, 2011 (edited) Is there any way to send exit command to other applications in a way that we do it manually. One way is to simply use this code in a batch file taskkill /t /f /im "ApplicationEXEName.exe" but if the application does something during the termination, this method doesn't allow it to do the terminate event. I am looking for a way to do it just like we do it manually e.g. pushing X or File->Exit to make sure that the application successfully terminates the instance. Thanks Edited July 7, 2011 by b0x4it Link to comment Share on other sites More sharing options...
jaberwacky Posted July 7, 2011 Share Posted July 7, 2011 Is MouseMove() or is Send() not an option? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 7, 2011 Share Posted July 7, 2011 Look at WinClose, WinKill, and ProcessClose in the Helpfile. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
b0x4it Posted July 7, 2011 Author Share Posted July 7, 2011 Thank you for your reply. These solutions work fine for most of the cases, but in some cases like Babylon where the it is usually minimized at systray and of course has no File menu: 1. how can I force it to restore and then try to send some key to it? 2. the only way to Exit these kind of applications is to right-click at their icons at systray and then select Exit. Is there any way to do it? Thanks Link to comment Share on other sites More sharing options...
jaberwacky Posted July 8, 2011 Share Posted July 8, 2011 You can look in the helpfile and tell us what you find. Try to do a little scripting. Come back and show us what you've done thus far. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
b0x4it Posted July 8, 2011 Author Share Posted July 8, 2011 I have chosen three application that when I close them they do not exit and just minimize to systray. I tried different commands on them to find out what would be the best way to ask an application (even those that are minimized in systray) to Exit in the way we usually do it manually by choosing File->Exit that let the application to save the job. The chosen applications are: Babylon PopPeeper SyncBack What I did and experienced: 1. Command ProcessClose used like this: ProcessClose("exename.exe") a. Babylon: it works even for both up and minimized states b. PopPeeper: it works even for both up and minimized states c. SyncBack: it works even for both up and minimized states 2. Command WinClose used like this: WinClose("[CLASS:class name using Au3Info.exe]", "") a. Babylon: it does not close this app to systray!!! b. PopPeeper: it works c. SyncBack: it works then I realized that the best way may be to just make the application active and send a hotkey like Alt+x to it. then I tried WinActivate 3. Command WinActivate used like this: WinActivate("[CLASS:class name using Au3Info.exe]", "") a. Babylon: it does not works for both minimized and up-but-in-background states!!! b. PopPeeper: it works for both minimized and up-but-in-background states. c. SyncBack: it works just when this app is not minimized and is in background. so it just brings it in foreground. if it is minimized, this command does nothing!!! at the end I couldn't find any solution to be able to Exit and not Kill different application. Even activating them in order to be able to send some hotkey to them is not working for all of them. I appreciate if somebody can help me out! Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 8, 2011 Share Posted July 8, 2011 Try Sending (after activation of course) or ControlSending Alt-F4 - (like this .. !{F4}) See the Helpfile if necessary for actual syntax. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
b0x4it Posted July 8, 2011 Author Share Posted July 8, 2011 thanks for your reply, but it obviously does not work because I can't even activate Babylon. How am I supposed to activate a windows if WinActivate doesn't work on it? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 8, 2011 Share Posted July 8, 2011 Well obviously nothing worked in my previous post either, until you tried and saw what actually did and did not work. Does this Babylon program not even have a window title or something to use with ControlSend? What is the key sequence you would use to exit this program, if it was active and in the foreground? ControlSend that key sequence, maybe that'll work. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
b0x4it Posted July 8, 2011 Author Share Posted July 8, 2011 Because I was not successful to even activate Babylon, then I didn't try sending anything to it. Its windows is un-standard (not like common rectangular windows), so its title can not be used. This is all the information that Au3Info shows about it: expandcollapse popup>>>> Window <<<< Title: Babylon Class: #32770 Position: 1215, 428 Size: 576, 418 Style: 0x960A0044 ExStyle: 0x00010000 Handle: 0x007A07E2 >>>> Control <<<< Class: Instance: ClassnameNN: Name: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: >>>> Mouse <<<< Position: 1405, 441 Cursor ID: 0 Color: 0x5D8EC0 >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< SplitArea >>>> Hidden Text <<<< Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 8, 2011 Share Posted July 8, 2011 ControlSend might work. That program does have a title, and if a control-id is not explicitly passed to ControlSend, it should pass it's 'payload' to the main window of a program. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
b0x4it Posted July 9, 2011 Author Share Posted July 9, 2011 (edited) I tried WinClose("Babylon", "") and interestingly it worked! WinClose does not work in this way: WinClose("[CLASS:#32770]", "") and I do not know why?? The I tried ControlSend like this: ControlSend("Babylon", "", 300, "!{F4}") ; 300 is the ControlID of a textbox and ControlSend("Babylon", "", "ATL:006EEBC81", "!{F4}") ; OR ControlSend("Babylon", "", "[CLASSNN:ATL:006EEBC81]", "!{F4}") where ATL:006EEBC81 is the ClassnameNN, but none of them works. Do you have any suggestion? I also found that if using totalcommander run a au3 file including this: ControlSend("Babylon", "", "", "!{F4}") then it will close totalcommander instead of Babylon. So it means that I have to first activate Babylon in order to send some key to it even with ControlSend. Then there would be no different between ControlSend and Send. I tried it on Notepad and experienced same. What do you think? Edited July 9, 2011 by b0x4it Link to comment Share on other sites More sharing options...
dexto Posted July 9, 2011 Share Posted July 9, 2011 I also found that if using totalcommander run a au3 file including this: ControlSend("Babylon", "", "", "!{F4}") then it will close totalcommander instead of Babylon. So it means that I have to first activate Babylon in order to send some key to it even with ControlSend. Then there would be no different between ControlSend and Send. I tried it on Notepad and experienced same. What do you think? Look at the helpfile for WinTitleMatchMode: Alters the method that is used to match window titles during search operations. 1 = Match the title from the start (default) So if the window title start with "Babylon" it would be a valid match. Link to comment Share on other sites More sharing options...
wolf9228 Posted July 9, 2011 Share Posted July 9, 2011 (edited) Sorry ... This Reply to another topic HotKeySet("{F1}", "_SendText") HotKeySet("{F2}", "_SendKey") HotKeySet("{ESC}", "Terminate") While 1 Sleep(150) WEnd Func _SendText() Run("notepad") WinWait("[CLASS:Notepad]") Send("!st.+9pI`VR@2",1) EndFunc Func _SendKey() Run("notepad") WinWait("[CLASS:Notepad]") Send("{ALTDOWN}",0) Send("f",1) Send("{ALTUP}",0) Send("{CTRLDOWN}",0) Send("o",1) Send("{CTRLUP}",0) EndFunc Func Terminate() Exit 0 EndFunc Edited July 9, 2011 by wolf9228 صرح السماء كان هنا Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 9, 2011 Share Posted July 9, 2011 ControlSend("Babylon", "", 300, "!{F4}") ; 300 is the ControlID of a textbox Try this: put quotes around 300. So like this ControlSend("Babylon", "", "300", "!{F4}"), also try this, ControlSend("Babylon", "", "", "!{F4}"). - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
wolf9228 Posted July 9, 2011 Share Posted July 9, 2011 #Include <WinAPI.au3> Run("notepad") WinWait("[CLASS:Notepad]") $hWnd = WinGetHandle("[CLASS:Notepad]") Dim $iPID Sleep(3000) _WinAPI_GetWindowThreadProcessId($hWnd,$iPID) ProcessClose($iPID) صرح السماء كان هنا Link to comment Share on other sites More sharing options...
taietel Posted July 9, 2011 Share Posted July 9, 2011 Try this (as somdcomputerguy suggested): $PID = ProcessExists("ApplicationEXEName.exe") If $PID Then ProcessClose($PID) Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now