Jump to content

Need AutoIT to search for a change in word, then act when it finds the change - (Moved)


Recommended Posts

Hi all,

I've been trying to research about this one but keep hitting a wall so here I am.

My goal: To start executing mouse clicks when a word in a box changes to "Done"

Would I need a combination of WinExists and If statements? Would this be the best way to do this? If so I would really appreciate a little help with the syntax.

Thanks for your time pros!

forumhelp.jpg

Link to comment
Share on other sites

  • Moderators

@MaxWilko welcome to the forum. Please post the code you have tried already, even if it is not doing what you want it to do. We will then be happy to assist.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Welcome to Autoit and the forum!

Did you try the AutoIt Window Info tool? If it returns the ID for the control you can query the value.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hi all ! 

Hi @water yes! I can use the AutoIT window info tool to find the ID of the control. This is great I can query it's value, I must sound very noob but how would I query the value? attached is a photo of the window info tool & my code

Quote

; CTECalibration2 AutoScript for AXF09T390


If @OSArch = "x64" Then
    DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turns On 64 Bit Redirection
    ShellExecute("osk.exe")                                                            ;turns on on screen keyboard
        $cartID = InputBox("Cartridge ID", "Please Enter;")    ;here a GUI asks for the Cart ID & stores as varible
        ProcessClose ( "osk.exe" )
    DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turns Off 64 Bit Redirection
EndIf

ShellExecute('C:\WINDOWS\CTX Calibration2\CTXCalibration2.exe')
WinWait('CTX Cartridge Calibration 2')     ;wait for the program to be fully loaded
WinActivate('CTX Cartridge Calibration 2')   ;this makes the window active for clicking
AutoItSetOption('MouseCoordMode', 0)   ;need this to click properly
MouseClick('primary', 1053, 13, 1, 0)
MouseClick('primary', 171, 99, 1, 0)
Send("{BACKSPACE}")
Send("{BACKSPACE}")
Send("{BACKSPACE}")
Send("{BACKSPACE}")
Send($cartID)
MouseClick('primary', 229, 134, 1, 0)
Send("{DOWN}")
Send("{DOWN}")
Send("{DOWN}")
Send("{DOWN}")
Send("{ENTER}")    ;select AXF09T390
MouseClick('primary', 449, 45, 1, 0)  ;Start Calibration
Send("25.007")   ;EnterSylvacPreset
Send("{ENTER}")
BlockInput(1)
Sleep (280000) ;Blocks input for duration while calibration is in process

; Now I need to initiate more clicks after message "Done" is displayed, hmmmm
 

 

autoITWindowInfo.jpg

Link to comment
Share on other sites

Just now, MaxWilko said:

Hi all ! 

Hi @water yes! I can use the AutoIT window info tool to find the ID of the control. This is great I can query it's value, I must sound very noob but how would I query the value? attached is a photo of the window info tool & my code

 

autoITWindowInfo.jpg

Thanks again for your support!

Link to comment
Share on other sites

I'm assuming it is a text box that updates when the process is done.

Put in a loop to test for value = "Done" and continue once the value is true.

For extra points, put a counter and a small delay, and exit the loop once the counter has decremented to zero, as the calibration process may hang or time out and your utility will wait forever.

Link to comment
Share on other sites

@Confuzzled, MaxWilko is asking:

10 hours ago, MaxWilko said:

how would I query the value?

but your answer of

4 hours ago, Confuzzled said:

Put in a loop to test for value = "Done" and continue once the value is true.

is both condescending and non-helpful.

For extra points, why not explain how to access the value of the control?

Code hard, but don’t hard code...

Link to comment
Share on other sites

Global $sWindowTitle = "CTX Cartridge Calibration 2" ; Title of the window to wait for
Global $iControlID = 67626                           ; ID of the control to retrieve the value from
Global $sTargetValue = "Done"                        ; Value to wait for
Global $iWaitTime = 5000                             ; Time in milliseconds to wait before checking the control again
Global $iMaxCheck = 5                                ; Maximum retries
While 1
    $sValue = ControlGetText($sWindowTitle, "", $iControlID)
    If @error Or $iMaxCheck <= 0 Then Exit MsgBox(0, "Error", "Could not find window or Control")
    If $sValue = $sTargetValue Then ExitLoop
    $iMaxCheck = $iMaxCheck - 1
    Sleep($iWaitTime)
Wend

I'm not sure this works at all because IIRC WindowsForms are hard to automate.

Edited by water
Added max retries value

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks @water this was really helpful and I understood it. Problem that occurs it seems is the ControlID changes everytime the program opens, so it cannot find the window and pops the error that was kindly coded for me.

I am going to attempt using pixel capture I think its called, there is also a colour that changes when it is complete, perhaps this might be an easier way to script, I will post back with my progress soon. Thanks everyone

Link to comment
Share on other sites

:)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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