Sign in to follow this  
Followers 0
r84170

How can I check if a button is pressed?

12 posts in this topic

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.

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

Have anyone another idea? Is there a comand which scans the message of the button?

Share this post


Link to post
Share on other sites

why dont u start using my suggestions?

Share this post


Link to post
Share on other sites

it seems a bit complicate for me

Share this post


Link to post
Share on other sites

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. :P // My preferred way

Share this post


Link to post
Share on other sites

then u have to make the buttons move if the window is moved

Share this post


Link to post
Share on other sites

That happens automatically if they're added to the other programs gui. :P

Share this post


Link to post
Share on other sites

how do u add a button to an external window?

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

by specifying the external window's window handle as the [parent] parameter of GUICreate. :P

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

Edited by FreeFry

Share this post


Link to post
Share on other sites

is awesome, I didnt know it

Share this post


Link to post
Share on other sites

Have fun. :P

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
Sign in to follow this  
Followers 0