TheWizEd

Newbee to AutoIt

33 posts in this topic

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?

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

What application? Where is your code?? What control id info. Post it

Edited by Earthshine

Share this post


Link to post
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.

Share this post


Link to post
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")

Share this post


Link to post
Share on other sites

Most likely you just have to wait for it to be ready to except commands

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

That particular application may not use standard Windows controls. What does the windows info to all say about it

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by Xandy

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#10 ·  Posted

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.

Share this post


Link to post
Share on other sites

#12 ·  Posted

Put this code after WinWaitActive. It should invoke a menu item (File) in the app. I know it works with notepad.

Send("{ALT}+F")


 

 

 

 

 

 


I'm ready to die!

Share this post


Link to post
Share on other sites

#13 ·  Posted

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.

Share this post


Link to post
Share on other sites

#14 ·  Posted

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.

Share this post


Link to post
Share on other sites

#15 ·  Posted

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.

Share this post


Link to post
Share on other sites

#17 ·  Posted

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

Share this post


Link to post
Share on other sites

#18 ·  Posted

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.

Share this post


Link to post
Share on other sites

#19 ·  Posted

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?

Share this post


Link to post
Share on other sites

#20 ·  Posted (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 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.

Share this post


Link to post
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