Jump to content

Automation of a autoit gui


Recommended Posts

Ok so weird situation here im trying to build a separate exe that will automate button clicks in a gui created by autoit, ive attached a screenshot below of the order i need the buttons to click in and a screenshot of the code ive got so far. any help would be greatly appreciated it. im extremely new to this and programming in general but what i need is a exe i can create that logs in to the gui and then clicks those buttons numbered 1 to 5 with 5 minute or so pauses in between clicks

code.JPG

gui.JPG

Link to comment
Share on other sites

You can use ControlClick to click the buttons regardless of where the position of the button is. Alternatively you can also use ControlGetPos to get the x, y, width, and height of the control.  Here's an example using ControlClick using the Class and Text of the button instead of the ctrlID (Even though I do have the ID's saved)

#include <GUIConstants.au3>

Global $frmExample = GUICreate("Control Click Example", 340, 305)
Global $btnCleaner = GUICtrlCreateButton("CCleaner", 10, 10, 100, 40)
Global $btnTfc = GUICtrlCreateButton("TFC", 120, 10, 100, 40)
Global $btnHibernation = GUICtrlCreateButton("Hibernation", 230, 10, 100, 40)
Global $btnExample = GUICtrlCreateButton("Click All The Buttons!", 10, 270, 320, 25)
Global $edtReport = GUICtrlCreateEdit("", 10, 60, 320, 200, $ES_READONLY)

GUISetState(@SW_SHOW, $frmExample)

While (True)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            GUIDelete($frmExample)
            Exit 0
        Case $btnCleaner
            GUICtrlSetData($edtReport, GUICtrlRead($edtReport) & "CCleaner pressed" & @CRLF)
        Case $btnTfc
            GUICtrlSetData($edtReport, GUICtrlRead($edtReport) & "TFC pressed" & @CRLF)
        Case $btnHibernation
            GUICtrlSetData($edtReport, GUICtrlRead($edtReport) & "Hibernation pressed" & @CRLF)
        Case $btnExample
            ControlClick("Control Click Example", "", "[Class:Button;Text:CCleaner]")
            ControlClick("Control Click Example", "", "[Class:Button;Text:TFC]")
            ControlClick("Control Click Example", "", "[Class:Button;Text:Hibernation]")
    EndSwitch
WEnd

 

Link to comment
Share on other sites

I'm sure that exact script won't do exactly what you want. It's merely an example to demonstrate how to use ControlClick on a button where you don't know the ctrlID (I did that by specifying the class name and the text of the button). With that you can learn how to make a script to do what you want.

Link to comment
Share on other sites

Just now, InunoTaishou said:

I'm sure that exact script won't do exactly what you want. It's merely an example to demonstrate how to use ControlClick on a button where you don't know the ctrlID (I did that by specifying the class name and the text of the button). With that you can learn how to make a script to do what you want.

if you could give me an easy example of just clicking one button im sure i could get the rest from there, my knowledge with scripting and programming in general is extremely limited

 

Link to comment
Share on other sites

I gave you an example where clicking one button caused the script to click three buttons without using the id returned from creating the buttons.

Quote

ControlClick

Sends a mouse click command to a given control.

ControlClick ( "title", "text", controlID [, button = "left" [, clicks = 1 [, x [, y]]]] )

Parameters

title The title/hWnd/class of the window to access. See Title special definition.
text The text of the window to access. See Text special definition.
controlID The control to interact with. See Controls.
button [optional] The button to click, "left", "right", "middle", "main", "menu", "primary", "secondary". Default is the left button.
clicks [optional] The number of times to click the mouse. Default is 1.
x [optional] The x position to click within the control. Default is center.
y [optional] The y position to click within the control. Default is center.

 

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

×
×
  • Create New...