creeping Posted March 27, 2007 Share Posted March 27, 2007 I have created some buttons using GUICtrlCreateButton() If the user left clicks -> perform action1 If the user right clicks -> perform action2 Thanks. Link to comment Share on other sites More sharing options...
smashly Posted March 27, 2007 Share Posted March 27, 2007 (edited) There's probly a better way to do it, but you could do similar for any type of control , not just buttons.. expandcollapse popup#include <GuiConstants.au3> Opt("GUIOnEventMode", 1) Opt("MouseCoordMode", 0) $Main = GuiCreate("MyGUI", 141, 128,-1, -1) $Button_1 = GuiCtrlCreateButton("Button1", 30, 20, 80, 30) GUICtrlSetOnEvent($Button_1, 'ButtonID') $Button_2 = GuiCtrlCreateButton("Button2", 30, 70, 80, 30) GUICtrlSetOnEvent($Button_2, 'ButtonID') GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, 'ButtonID',$Main) GUISetOnEvent($GUI_EVENT_CLOSE, 'ButtonID',$Main) GuiSetState() While 1 Sleep(10) WEnd Func ButtonID() Select Case @GUI_CTRLID = $GUI_EVENT_SECONDARYDOWN $mp = MouseGetPos() If ($mp[0] > 33 and $mp[0] < 114) And ($mp[1] > 48 And $mp[1] < 78) Then MsgBox(0,'', 'Button1 was Right Clicked') ElseIf ($mp[0] > 33 and $mp[0] < 114) And ($mp[1] > 99 And $mp[1] < 130) Then MsgBox(0,'', 'Button2 was Right Clicked') EndIf Case @GUI_CTRLID = $Button_1 MsgBox(0,'','Button1 was Left Clicked') Case @GUI_CTRLID = $Button_2 MsgBox(0,'','Button2 was Left Clicked') Case @GUI_CTRLID = $GUI_EVENT_CLOSE Exit EndSelect EndFunc Cheers Edited March 27, 2007 by smashly Link to comment Share on other sites More sharing options...
creeping Posted March 27, 2007 Author Share Posted March 27, 2007 Cool, that will do fine. Ta Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 27, 2007 Share Posted March 27, 2007 Standard Windows buttons aren't meant to be right clicked. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now