Sign in to follow this  
Followers 0
Batch

Quickest Way To Click Button

5 posts in this topic

Greets Auto-itters(?)

Thanks for all your help in the past. I've created a bunch of script to install programs with the old v2, and I'm creating v3 scripts with the same commands, just wondering if there is a better way with all the new if not @error type stuff.

I just want to click a button in a window, I think it should look like this:

AutoItSetOption( "WinWaitDelay", "0" )

Run( "C:\Program Files\Countdown Timer\CountDown.exe" )
WinWait( "Enter the countdown time" )
WinActivate( "Enter the countdown time" )
WinWaitActive( "Enter the countdown time" )
ControlClick( "Enter the countdown time", "", "TButton3" )

That works just fine, and works quickly, I was wondering if there is a more appropriate way to do it like a "If not ControlClick" or something. I apoligize if that sounds :whistle:, but I think I've seen somebody do something like that. Let me know! TIA, you people are the bomb!

Share this post


Link to post
Share on other sites



Something like this would work and have some testing to ensure the window exists.

It will wait 3 seconds for the window to popup:

By the way, the window doesn't need to have the focus for the CONTROL commands to work correctly, so the winactivate is not needed.

Run( "C:\Program Files\Countdown Timer\CountDown.exe" )
If WinWait( "Enter the countdown time",3 ) then
   ControlClick( "Enter the countdown time", "", "TButton3" )
Else
   msgbox(4096,'Error','Window not found error.....'  )
EndIf

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Interesting...thanks for your reply, I was not aware that the activate commands were no longer necessary.

Share this post


Link to post
Share on other sites

Interesting...thanks for your reply, I was not aware that the activate commands were no longer necessary.

WinActive is needed when you do a Send command because that "types" the characters in the active window...

With the control commands you tell it for which window you want the command to be executed.


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Yes, I have tested this and it is true. I just have a WinWait statement before the ControlClick and it works great, as instant as possible. If anyone else is trying to do the same thing I am, I am using a freeware countdown timer. I have discovered that for some reason, after setting all my options (transparency, hide buttons, hide border, set text and background color) after running the program a few times, it reverts back for some reason. I suggest a wonderful utility called "regmon.exe". Google will help you find it. You can open regmon, turn on the filter and include countdown. I found where in the registry the settings were stored and exported them to a .reg file. Now in my AutoIt script I tell it to do a RunWait( "regedit /s countdown.reg" ) and it ensures the timer is setup how and where I like it. Thanks again JdeB for your prompt reply.

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
Sign in to follow this  
Followers 0