Jump to content
TheWizEd

Newbee to AutoIt

Recommended Posts

TheWizEd

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
Earthshine

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

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
jdelaney

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
TheWizEd
; 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
Earthshine

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

 

Share this post


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

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

 

Share this post


Link to post
Share on other sites
Xandy

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
TheWizEd

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

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

Send("{ALT}+F")


 

 

 

 

 

 

Share this post


Link to post
Share on other sites
jdelaney

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

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
jdelaney

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

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

×