Jump to content

Create GUI controls with specific Control ID


rawkhopper
 Share

Recommended Posts

Hello Everyone,

I use some software for work that only works when attached to the machine.  There is not an "offline" version of the software that I have access to.  So I was curious if I could create a GUI in AutoIt that had specific Control IDs so that I could experiment with automation when away from the machine.  This way I would not have to use customer time to satisfy my own automation needs.

For example the software that controls the machine has a Textbox with a control ID of 1001.  I can recreate a gui using a snapshot of the background and then creating a textbox in the right location.  But I like to use ControlSend so that mouse and keyboard use is less likely to interrupt the automation.  So can I set the control ID of my fake textbox to fool my own automation so that I can test it when not in the customer lab?

I hope I am making sense.

#include <GUIConstantsEx.au3>
Global $hGuiWin = GUICreate ( "FakeProgram", 1276, 1015)
GUISetBkColor (0xf0f0f0, $hGuiWin )
$FakeTextBox = GUICtrlCreateInput ("", 85, 39, 73,16) #can I set the Control ID to 1001 for this box?
GUICtrlCreatePic('C:\Users\MYNAME\Desktop\SCREENSHOT.jpg', 0, 0 ,1276, 1015)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)

    Do
        $msg = GUIGetMsg()

    Until $msg = $GUI_EVENT_CLOSE
Exit

 

 

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
Global $hGuiWin = GUICreate ( "FakeProgram", 1276, 1015)
GUISetBkColor (0xf0f0f0, $hGuiWin )

For $i = 3 To 1000     ; First Control ID = 3
  GUICtrlCreateDummy() ; This allocates Control IDs from 3 to 1000
Next                   ; The next control will get ID = 1001

$FakeTextBox = GUICtrlCreateInput ("", 85, 39, 73,16) ; can I set the Control ID to 1001 for this box?
;GUICtrlCreatePic('C:\Users\MYNAME\Desktop\SCREENSHOT.jpg', 0, 0 ,1276, 1015)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)

Do
  $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

Exit

 

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