Jump to content

Recommended Posts

  • 1 year later...
Posted

Old thread, but relevant for anyone stumbling across this.

GUICtrlSendMsg() isn't designed to simulate mouse clicks.

Use ControlClick() instead:

; create some GUI
$MyGUI = GUICreate( "Test-GUI", ... )
$MyButton = GUICtrlCreateButton( "The button", 10, 10, ...)

etc.

; simulate a click on 'The button':
ControlClick( $MyGUI, "", $MyButton )

 

Posted

@Fingo  Not precisely true.  It could be appropriate under certain circumstances to send a message to self...

#include <GUIConstants.au3>

Global Const $MK_LBUTTON = 1

Example()

Func Example()
  Local $hGUI = GUICreate("Example", 300, 200)
  Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25)
  GUISetState()

  Sleep(1000)  ; leave some time to see the GUI

  GUICtrlSendMsg($idButton_Close, $WM_LBUTTONDOWN, $MK_LBUTTON, 0x00030003)
  GUICtrlSendMsg($idButton_Close, $WM_LBUTTONUP, $MK_LBUTTON, 0x00030003)

  While 1
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE, $idButton_Close
        ConsoleWrite("Closing GUI" & @CRLF)
        ExitLoop
    EndSwitch
  WEnd
EndFunc   ;==>Example

 

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