bestchrisever

Automation of a autoit gui

8 posts in this topic

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

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

excellent let me give this a spin i really appreciate the guidance

 

Share this post


Link to post
Share on other sites

not working for me im sure im doing something wrong, essentially like i said im looking to make a exe that will just automate those clicks, dont need a second gui or anything just something that runs the programs in the order i numbered

 

Share this post


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

Share this post


Link to post
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

 

Share this post


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

 

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