Jump to content

Quickest Way To Click Button


Recommended Posts

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!

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

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.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

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