I need to automate a specific GUI from a legacy system written in C.
The spy tool gives me this
I use this code
Local $swintit = WinGetTitle("[active]") ConsoleWrite("active Window " & $swintit & @CRLF) If $swintit = "FILES NOTES" Then ; If $swintit = "FILES NOTES" Then ; got Window, now atomate ConsoleWrite("got Window " & @CRLF) ; now focus, then click :) ;EditPaste ;ControlCommand("FILES NOTES", "", 404, $acno) ; paste acno GUICtrlSetState(404, $GUI_Focus) ControlCommand("FILES NOTES", "", 404, $acno) ; paste acno GUICtrlSetState(401, $GUI_Focus) ControlClick("FILES NOTES", "", 401, $acno) ; click okay EndIf ; If $swintit = "FILES NOTES" Then The idea is to paste the acno value into the edit box, then click an Okay button.
I get a console write that the active Window is as expected, but my loop completes without ever writing anything into the GUI.
I also tried the control ID as text "404" - same result
What am I missing?
I have the following snippet of code that sort of works but isn’t doing exactly what I want.
expand popup #include <GuiConstants.au3> Global $gGUIWidth = 250 Global $gGUIHeight = 150 Initial() Func Initial() ; Create the initial GUI $BaseGUI = GUICreate("", $gGUIWidth, $gGUIHeight, -1, -1, -1, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW) GUISetState(@SW_SHOW, $BaseGUI) ; Create a field for entering the current value GUICtrlCreateLabel("Current Value:", 10, 10) $CurrentValueFld = GUICtrlCreateInput("", 10, 40, 215, 20, $ES_NUMBER) GUICtrlSetState($CurrentValueFld, $GUI_FOCUS) ; Create Calculate button Local $CalculateButton = GUICtrlCreateButton("Calculate", 10, 70, 75, 25) GUICtrlSetState($CalculateButton, $GUI_DISABLE) ; Watch the value field and determine if the value is greater than 0 and if so, enable Calculate button $i = 0 Do $CurrentValue = GUICtrlRead($CurrentValueFld) If $CurrentValue > 0 Then GUICtrlSetState($CalculateButton, $GUI_ENABLE + $GUI_FOCUS) $i = 1 EndIf until $i = 1 ;Loop until the user exits and check for ESC, "X", or Begin button While 1 $InitialGUIMsg = GUIGetMsg() If $InitialGUIMsg = $GUI_EVENT_CLOSE Then Exit EndIf WEnd EndFunc
I want to be able to:
Start with focus in the value field (it is doing this now) Allow for more than one digit to be entered into the field (it is sort of doing this now but I have to bring focus back to the field) Enable the Calculate button and give focus to it once a value is entered into the value field (it is doing this now) but keep the cursor in the value field so the more digits can be entered (it is not doing this now) Be able to hit ESC or “X” to close the dialog at any time (this only works after I enter a digit in the value field Basically, I want to be able to allow the user to enter one or more digits and hit ENTER or SPACE (while the cursor is still in the value field) to push the Calculate button. I assume I need to bring focus to the button but maybe I don't and can get away with assigning hotkeys for ENTER and SPACE to push the Calculate button while keeping focus in the value field.
If you could, please add comments in your code as to what the changes are doing if they aren't obvious to a noobish programmer.
Thanks for any help you can offer on this.
Hello, I am trying to hide all the controls in my GUI. Is it possible to do an easier way than to use GUICtrlSetState on every single Control I have?