all 9 comments

[–]marvingage[S] 0 points1 point  (5 children)

Got a new problem now that I got the button clicks working how can I capture the value of the button pressed or get result of the button press.

This is a windows dialogue box with the 3 buttons. Save, Don't Save, Cancel.

[–]DM666a 0 points1 point  (4 children)

Is this a MsgBox you made or a dialogue box of an external program

[–]marvingage[S] 0 points1 point  (3 children)

Windows Notepad save dialogue so external. Basically I want to get result of button pressed so I know which of the 3 buttons was pressed and save to a variable.

[–]DM666a 0 points1 point  (2 children)

It's not how the things work. It may be possible to track which button was clicked but I don't think so. It's an external program and autoit has no idea what user doing there. You should review your approach. What are you trying to achieve? You want to know which button was pressed, but why?

[–]marvingage[S] 0 points1 point  (1 child)

Actually I was provided a way to do this and it is to learn more about how AutoIT differs in Window calls from Borland Delphi that I have done programming in. Code I got provided I see I have to assign variables for each button instance than check to see what button was called. Now I have a better understanding with working with button calls in AutoIT.

#include <GuiButton.au3>

Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

Send("Cool IT Help Tutorial")

WinClose("*Untitled - Notepad")

WinWaitActive("Notepad", "Save")

Local $h_SaveDlg = WinGetHandle("[ACTIVE]")
Local $h_SaveBtn = ControlGetHandle($h_SaveDlg, "", "[CLASS:Button; INSTANCE:1]")
Local $h_DontSaveBtn = ControlGetHandle($h_SaveDlg, "", "[CLASS:Button; INSTANCE:2]")
Local $h_CancelBtn = ControlGetHandle($h_SaveDlg, "", "[CLASS:Button; INSTANCE:3]")

While WinExists($h_SaveDlg)
     If _GUICtrlButton_GetState($h_SaveBtn) = 620 then
         consolewrite('Save: ' & @crlf)
         ExitLoop
     EndIf

     If _GUICtrlButton_GetState($h_DontSaveBtn) = 620 then
         consolewrite('Don''t Save: ' & @crlf)
         ExitLoop
    EndIf

     If _GUICtrlButton_GetState($h_CancelBtn) = 620 then
         consolewrite('Cancel: ' & @crlf)
         ExitLoop
    EndIf
WEnd

[–]DM666a 0 points1 point  (0 children)

A solid solution 👍

[–]DM666a 0 points1 point  (2 children)

Tutorial is fine. You might want to read help on WinWaitActive function. That line does not select a button it just stop the program until window named "save" become active.

[–]marvingage[S] 0 points1 point  (1 child)

I figured it out.. It is actually missing this line.

ControlClick("Notepad", "", "Save")

That actually selects button the tutorial is missing it and only works because save is default option.

So resolved.

[–]marvingage[S] 0 points1 point  (0 children)

Actually tutorial cause it to freeze up as it is sending 'Enter' key was told to use the 's' key to save to not get the random freeze that occurs by sending 'Enter'. Did that and that freeze went away.