TheWizEd Posted February 6, 2018 Share Posted February 6, 2018 I'm trying to use AutoIt to automate an application. So far my script "Run"s the app and the intial window opens. I'm trying to click "File" "Open" but can't get the app to do anything. I'm running AutoIt Window Info and can get the hWnd and Command Id's on a toolbar but can't seem to trigger them. Are there any examples to show how to do this? Link to comment Share on other sites More sharing options...
Earthshine Posted February 6, 2018 Share Posted February 6, 2018 (edited) What application? Where is your code?? What control id info. Post it Edited February 6, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
jdelaney Posted February 6, 2018 Share Posted February 6, 2018 Pay special attention to the help file of this one, regarding 'accelerators': WinMenuSelectItem Give it a go, post your failing script if you can't figure it out. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
TheWizEd Posted February 6, 2018 Author Share Posted February 6, 2018 ; Script Start - Add your code below here #include <MsgBoxConstants.au3> Local $pId = Run("C:\Program Files (x86)\Equis\The DownLoader\Dlwin.exe") Sleep(4000) ; Wait for splash screen Local $hWnd = WinWaitActive("The DownLoader", "", 10) MsgBox($MB_SYSTEMMODAL, "hWnd", $hWnd) ControlClick($hWnd,"","[ID:57601]") Control Id from Windo Info. I've tried WinMenuSelectItem($hWnd,"","File","Open") Link to comment Share on other sites More sharing options...
Earthshine Posted February 6, 2018 Share Posted February 6, 2018 Most likely you just have to wait for it to be ready to except commands My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
TheWizEd Posted February 6, 2018 Author Share Posted February 6, 2018 5 minutes ago, Earthshine said: Most likely you just have to wait for it to be ready to except commands How do I do that? Link to comment Share on other sites More sharing options...
Earthshine Posted February 6, 2018 Share Posted February 6, 2018 That particular application may not use standard Windows controls. What does the windows info to all say about it My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Xandy Posted February 6, 2018 Share Posted February 6, 2018 (edited) Add a 5 second sleep after the WinWait. Just to test if the window needs more time to become ready to accept commands. ; Script Start - Add your code below here #include <MsgBoxConstants.au3> Local $pId = Run("C:\Program Files (x86)\Equis\The DownLoader\Dlwin.exe") Sleep(4000) ; Wait for splash screen Local $hWnd = WinWaitActive("The DownLoader", "", 10) Sleep(5000); ADDED LINE TO PAUSE SCRIPT 5 SECONDS MsgBox($MB_SYSTEMMODAL, "hWnd", $hWnd) ControlClick($hWnd,"","[ID:57601]") Edited February 6, 2018 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
TheWizEd Posted February 6, 2018 Author Share Posted February 6, 2018 I can't get the menu items, but I tried some of the notepad examples and same thing. I can get Commad ID of a toolbar but can't simulate click. Link to comment Share on other sites More sharing options...
TheWizEd Posted February 6, 2018 Author Share Posted February 6, 2018 3 minutes ago, Xandy said: Add a 5 second sleep after the WinWait. Just to test if the window needs more time to become ready to accept commands. ; Script Start - Add your code below here #include <MsgBoxConstants.au3> Local $pId = Run("C:\Program Files (x86)\Equis\The DownLoader\Dlwin.exe") Sleep(4000) ; Wait for splash screen Local $hWnd = WinWaitActive("The DownLoader", "", 10) Sleep(5000); ADDED LINE TO PAUSE SCRIPT 5 SECONDS MsgBox($MB_SYSTEMMODAL, "hWnd", $hWnd) ControlClick($hWnd,"","[ID:57601]") Still nothing. Link to comment Share on other sites More sharing options...
Xandy Posted February 6, 2018 Share Posted February 6, 2018 (edited) Do you want this command: WinMenuSelectItem Instead of ControlClick? Edited February 6, 2018 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Au3Builder Posted February 6, 2018 Share Posted February 6, 2018 Put this code after WinWaitActive. It should invoke a menu item (File) in the app. I know it works with notepad. Send("{ALT}+F") Link to comment Share on other sites More sharing options...
jdelaney Posted February 6, 2018 Share Posted February 6, 2018 You didn't look into 'accelerators' as I advised! go back and try again. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
TheWizEd Posted February 6, 2018 Author Share Posted February 6, 2018 2 hours ago, jdelaney said: You didn't look into 'accelerators' as I advised! go back and try again. By accelerator I'm assuming you mean &File and so on. I did try accelerators but those didn't work either. Link to comment Share on other sites More sharing options...
TheWizEd Posted February 6, 2018 Author Share Posted February 6, 2018 4 hours ago, Au3Builder said: Put this code after WinWaitActive. It should invoke a menu item (File) in the app. I know it works with notepad. Send("{ALT}+F") Success. But it seems this is trial and error try ControlClick, try WinMenuSelectItem, try Send. Link to comment Share on other sites More sharing options...
Zedna Posted February 6, 2018 Share Posted February 6, 2018 Use Winspector + _SendMessage() as described for example here: Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
TheWizEd Posted February 13, 2018 Author Share Posted February 13, 2018 I'm still trying to understand what some of these commands do. What's wrong with the following code excerpt. ; Open file from toolbar $iStartTime = _Timer_Init() Local $vResult = ControlCommand($hWnd,"",59394,"SendCommandID",57601) MsgBox($MB_SYSTEMMODAL, "",_Timer_Diff($iStartTime)) ; Open dialog appears but the next command doesn't see it $iStartTime = _Timer_Init() $vResult = WinWait("Open","",10) MsgBox($MB_SYSTEMMODAL, "",_Timer_Diff($iStartTime)) ; MsgBox appears 10 seconds after I close Open file dialog Link to comment Share on other sites More sharing options...
jdelaney Posted February 13, 2018 Share Posted February 13, 2018 You'll need to start a second process to do the controlcommand. your script is deadlocked. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
TheWizEd Posted February 13, 2018 Author Share Posted February 13, 2018 3 minutes ago, jdelaney said: You'll need to start a second process to do the controlcommand. your script is deadlocked. ControlCommand works and a dialog box with title "Open" appears. My interpretation of WinWait is to make sure the dialog has opened. What do you mean by and how do I start a second process? Link to comment Share on other sites More sharing options...
jdelaney Posted February 13, 2018 Share Posted February 13, 2018 (edited) The window opens, but you are waiting on the parent window to return success. which won't happen until the popup is closed. in the helpfile, search command line variables for examples of running a line of script as a second process. You can verify this by putting a msgbox right after the control command call. the msgbox won't come up until you close the window. then your script waits 10 seconds while failing to find the already closed window. Edited February 13, 2018 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. 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