Sign in to follow this  
Followers 0
gottygolly

Get control id on a right click.

3 posts in this topic

In my script I have labels and if you right click on a label it gives you an option to interact with the label via contextmenu. My problem is I have it setup that you can change the label and based on how you changed it, it will change the contextmenu.

If you left click you can get the id of the control through @gui_ctrlid, my curiosity lies in whether or not you can get the id off of a right click so I can set the contextmenu information accordingly to the right label.

(sorry if I was confusing, currently on my phone) 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 96, 72, 145, 105)
$Button2 = GUICtrlCreateButton("Button1", 316, 232, 145, 105)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_SECONDARYUP
            $aCI = GUIGetCursorInfo($Form1)
            If $aCI[4] <> 0 Then
            MsgBox(0,"",$aCI[4])
            EndIf
    EndSwitch
WEnd

It works only for GUIs that you created as you can see. was it?

Edited by GordonFreeman

Share this post


Link to post
Share on other sites

Thanks for the help man, I guess all that I needed was the $GUI_EVENT_SECONDARYUP variable.

Re-made it into GUIOnEventMode form since that is what my script is in.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
Opt("GUIOnEventMode",1)
GUISetOnEvent(-3,"_exit")
$Button1 = GUICtrlCreateButton("Button1", 96, 72, 145, 105)
$Button2 = GUICtrlCreateButton("Button2", 316, 232, 145, 105)
GUISetOnEvent($GUI_EVENT_SECONDARYUP,"button")
GUISetState()

While 1
Sleep(10)
WEnd

Func _exit()
    Exit
EndFunc

Func button()
    $p = GUIGetCursorInfo($Form1)
    MsgBox(0,"","ID: "&$p[4]&@CRLF&GUICtrlRead($p[4]))
EndFunc

Thanks for the help!

1 person likes this

Share this post


Link to post
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
Sign in to follow this  
Followers 0