r84170 Posted October 17, 2008 Posted October 17, 2008 How can I check the state of a button of an external program? - An external program shows a message box with 2 buttons (okay; cancel) - How can my script kown if and which button is pressed? Thank you for any help.
oMBRa Posted October 17, 2008 Posted October 17, 2008 get the position of the button then if the user sends a mouse click, get the mouse pos and compare it with the button pos
r84170 Posted October 17, 2008 Author Posted October 17, 2008 Have anyone another idea? Is there a comand which scans the message of the button?
FreeFry Posted October 17, 2008 Posted October 17, 2008 Or he could hide the buttons in the app, and create his own buttons in there(and await their keystrokes), then depending on which button was clicked, take action, the if wanted, simulate a click on the 'real' button. // My preferred way
oMBRa Posted October 17, 2008 Posted October 17, 2008 then u have to make the buttons move if the window is moved
FreeFry Posted October 19, 2008 Posted October 19, 2008 That happens automatically if they're added to the other programs gui.
FreeFry Posted October 19, 2008 Posted October 19, 2008 (edited) by specifying the external window's window handle as the [parent] parameter of GUICreate. For the sake of examples: #include <WindowsConstants.au3> Dim Const $swClass = "[CLASS:Notepad]" If Not WinExists($swClass) Then Run("notepad.exe") WinWait($swClass) Dim $iwHandle = WinGetHandle($swClass) Dim $icHandle = ControlGetHandle($iwHandle, "", "Edit1") Dim $acPosition = ControlGetPos($iwHandle, "", $icHandle) GUICreate("", $acPosition[2], $acPosition[3], $acPosition[0], $acPosition[1], $WS_CHILD, -1, $iwHandle) Dim $ibID = GUICtrlCreateButton("SuperButton", 0, 0, $acPosition[2], $acPosition[3]) ControlHide($iwHandle, "", $icHandle) GUISetState() While 1 Switch GUIGetMsg() Case $ibID MsgBox(0, "Button", "You clicked the all mighty super buttan ;)") WinClose($iwHandle) Exit EndSwitch If Not WinExists($iwHandle) Then Exit WEnd Edit: More proper, and merged my previous post. Edit2: Oh, as well you need the $WS_CHILD style for your gui. Edited October 19, 2008 by FreeFry
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now