Jump to content

GUI control ID for mouse events


Recommended Posts

Ok, im making a simple program launcher that is a window full of buttons that have the prog icons and i would like to be able to right click on them and preferably cause a menu to drop from mouse, but at least cause a msgbox to pop up. problem is i cant get it to tell me what button you right clicked even using

GUIgetmsg(1)

not very fun...

MUHAHAHAHAHA

Link to comment
Share on other sites

Try this:

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$mainwindow = GUICreate("Event Mode GUI")
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

dim $aButtons[1]
for $i = 1 to 5
    redim $aButtons[$i]
    $aButtons[$i-1] = GUICtrlCreateButton("Button "&$i, 10, $i*30, 60)
    GUICtrlSetOnEvent(-1, "Buttonclick")
Next

GUISetState(@SW_SHOW)

While 1
  Sleep(1000)  ; Idle around
WEnd

Func Buttonclick()
  $text = GuiCtrlRead(@GUI_CTRLID)
  MsgBox(0, "GUI Event", $text)
EndFunc

Func CLOSEClicked()
  Exit
EndFunc

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

Try this:

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$mainwindow = GUICreate("Event Mode GUI")
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

dim $aButtons[1]
for $i = 1 to 5
    redim $aButtons[$i]
    $aButtons[$i-1] = GUICtrlCreateButton("Button "&$i, 10, $i*30, 60)
    GUICtrlSetOnEvent(-1, "Buttonclick")
Next

GUISetState(@SW_SHOW)

While 1
  Sleep(1000)  ; Idle around
WEnd

Func Buttonclick()
  $text = GuiCtrlRead(@GUI_CTRLID)
  MsgBox(0, "GUI Event", $text)
EndFunc

Func CLOSEClicked()
  Exit
EndFunc
hmm nope, i want to know what control was right clicked on, not pressed. i could easily do that with the standard GUIGetMsg() while, select loop. Edited by smstroble

MUHAHAHAHAHA

Link to comment
Share on other sites

Oh. Okay:

#include <GUIConstants.au3>
global $right=0
Opt("GUIOnEventMode", 1)
$mainwindow = GUICreate("Event Mode GUI")
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetOnEvent($GUI_EVENT_SECONDARYUP, "RightClick")

dim $aButtons[1]
for $i = 1 to 5
    redim $aButtons[$i]
    $aButtons[$i-1] = GUICtrlCreateButton("Button "&$i, 10, $i*30, 60)
    GUICtrlSetOnEvent(-1, "Buttonclick")
Next

GUISetState(@SW_SHOW)

While 1
  Sleep(1000)  ; Idle around
WEnd

Func Buttonclick($right=0)
    $text = GuiCtrlRead(@GUI_CTRLID)
    if $right = 0 then
        MsgBox(0, "GUI Event", "Left Click: " & $text)
    Else
        MsgBox(0, "GUI Event", "Right Click: " & $text)
    EndIf
    $right = 0
EndFunc

Func RightClick()
    $right=1
    MouseClick("left")
EndFunc

Func CLOSEClicked()
  Exit
EndFunc

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

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