jesbergr

GUI Button Emulation

6 posts in this topic

Am a controls engineer with limited scripting background. Am looking for way to emulate triggering a Windows based GUI function button based on a time function, and will be enlisting the help of IT dept where I work. Can anyone steer me in a direction?

 

Thanks much, RJ

Share this post


Link to post
Share on other sites



Welcome to AutoIt, Jesbergr. What kind of windows based application are you trying to emulate a trigger?

Share this post


Link to post
Share on other sites

Hi, @jesbergr, welcome to the forum. Here are some pointers to get you started. As aa2zz6 states, the more you can tell us about what you're trying to do, the more we can assist.

It sounds as though you are trying to click a button on a GUI at certain intervals. For this, I would suggest the following (without knowing more about the GUI):

  • Use the Window Info Tool (located in the same directory where you install AutoIt) to gather information about the GUI window and the button you're trying to press.
  • Assuming the Window Info Tool gives you the title of the window (or its class), look at WinExists in the help file; you'll want to ensure the window is at least there before you try to interact with it. 
  • Once you are sure the GUI exists, look at ControlClick in the help file. As long as you are able to get the title/class of the window and the Button's name/id, you're all set. You can use ControlClick to press the button, whether the window is active (in focus) or not.
  • Regarding time, some clarification would help - do you mean "press button every x Seconds" or "press button at 12:36 pm only on Tuesdays that aren't part of a month with 31 days and not in a leap year"? The great news is, AutoIt can do either :)
  • Two sections I would encourage you to read through in the help file are: Time and Date Macros and Timer and Delay Management. Somewhere in there is a fit for what you're attempting to do.

Take some time to read (or have your IT guy) these sections, and see what you can come up with. If you get stuck, don't hesitate to post your script here and we will do our best to assist.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

JLogan, thanks much for the quick response, this helps! The time trigger is 'everyday at 12pm.'

rj

Share this post


Link to post
Share on other sites

Ah, you then have a couple of options. You can just create the script and use the windows scheduler (easiest).

If this is not an option you can look at _NowTime () in the help file. I am on my phone or would post a link.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

In my experience I would recommend using the Task Scheduler to run scripts. If you want to dive into using timers here is a piece you can look at. 

 

#include <Date.au3>  ;  1 = Sun  2 = Mon  3 = Tue  4 = Wed  5 = Thu  6 = Fri  7 = Sat
$StartTime1 = "07:30"
$EndTime1 = "08:30"
$StartTime2 = "16:30"
$EndTime2 = "18:30"
AdlibRegister("_Check",1000*60);check every minute

While 1;just idle around
Sleep(1000)
WEnd

Func _Check();every minute we check
$CurrentTime = _NowTime(4);the current time
Switch @WDAY;check for D-day and start the program (a message in this case)
Case 1, 2, 3, 4, 5, 7
If BitOR($CurrentTime >= $StartTime1 And $CurrentTime <= $EndTime1, $CurrentTime >= $StartTime2 And $CurrentTime <= $EndTime2) Then MsgBox(0, "Test1", "Test1")
Case 6
If ($CurrentTime >= $StartTime2 And $CurrentTime <= $EndTime2) Then MsgBox(0, "Test2", "Test2")
EndSwitch
AdlibUnRegister();unregister the running function
Exit;and exit
EndFunc

Edit: Here is the help file JLogan mentioned above

https://www.autoitscript.com/autoit3/docs/libfunctions/_NowTime.htm

 

Edited by aa2zz6

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