Gui button-Left or Right Click Variables-Ctrl+Click? Topic is solved
Gui button-Left or Right Click Variables-Ctrl+Click?
Is there an easy way to add Left Click and Right Click functionality to a gui button? (or CTRL+Left click)
Re: Gui button-Left or Right Click Variables-Ctrl+Click? Topic is solved
Hi Arempi,
If it is question of the LButton specify a g-label the moment you create the control, otherwise, to monitor the RButton click event specify a GUIContextMenu label - simple example:
If it is question of a specific button and in case you want to use Ctrl+Click as hotkey, you can also use a context-sensitive hotkey (#If function, the latter function using MouseGetPos to determine whether or not the mouse is over a specific button the moment RButton is pressed):
Hope this helps.
If it is question of the LButton specify a g-label the moment you create the control, otherwise, to monitor the RButton click event specify a GUIContextMenu label - simple example:
Code: Select all
#NoEnv
#Warn
SendMode Input
#SingleInstance force
; Windows 8.1 64 bit - Autohotkey v1.1.27.04 32-bit Unicode
Gui, Add, Button, gsubroutine w300 h50, OK
Gui, Show, AutoSize
return
subroutine:
MsgBox % A_ThisLabel
return
GuiContextMenu:
MsgBox % A_ThisLabel
return
Code: Select all
#NoEnv
#Warn
SendMode Input
#SingleInstance force
; Windows 8.1 64 bit - Autohotkey v1.1.27.04 32-bit Unicode
; menu -----------------------------------------------------------------
Menu, MyMenu, Add, Item1, MenuHandler
try Menu, MyMenu, Icon, Item1, imageres.dll, 1
Menu, MyMenu, Add
Menu, MyMenu, Add, Item2, MenuHandler
try Menu, MyMenu, Icon, Item2, imageres.dll, 2
; GUI -----------------------------------------------------------------
Gui, Add, Edit, w200, OK
Gui, Add, ListBox, w200, OK
Gui, Add, Button, hwndCID w200, OK ; 'hwndCID' stores the window handle (HWND) of the control in 'CID'
Gui, Show, AutoSize
return
#If mouseIsOverControl(CID)
^RButton::Menu, MyMenu, Show
#If
MenuHandler:
MsgBox % A_ThisMenuItem
return
mouseIsOverControl(__controlID) {
MouseGetPos,,,, __outputVarControl, 2 ; stores the control's HWND in '__outputVarControl'
return (__outputVarControl = __controlID)
}
Hope this helps.
Re: Gui button-Left or Right Click Variables-Ctrl+Click?
A_AhkUser,
Perfect!... I needed to have the ability to send two different routines (currently) per button. I did not think to add contextmenus for further options - great idea. I'm still learning ahk, working on my first program/script. 640 lines so far. There is probably better ways to accomplish most of the functions. lol.
Don't understand some of this, but enough to get me started!
I appreciate the help! ~Arempi
Perfect!... I needed to have the ability to send two different routines (currently) per button. I did not think to add contextmenus for further options - great idea. I'm still learning ahk, working on my first program/script. 640 lines so far. There is probably better ways to accomplish most of the functions. lol.
Don't understand some of this, but enough to get me started!
I appreciate the help! ~Arempi