Jump to content

Recommended Posts

Posted

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.

Posted

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

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...