Jump to content

How can I check if a button is pressed?


r84170
 Share

Recommended Posts

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

Link to comment
Share on other sites

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