Jump to content

Newbee to AutoIt


 Share

Recommended Posts

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

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

; 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

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 by Xandy
Link to comment
Share on other sites

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

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

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

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

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 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...