Helge Posted April 28, 2005 Posted April 28, 2005 Is there any way to show a context-menu, when for example left-clicking a button ?At default it requires a right-click, which works, but for what I want to use it for(where the context-menu is the only function for that button) it's just doesn'tfeel natural having to right-click it.Doesn't seem like a big deal, but anyway it would be great if it was possible !
MHz Posted April 28, 2005 Posted April 28, 2005 Do you not have in Mouse options, to change primary button with secondary button? I have the option in XP.
Helge Posted April 28, 2005 Author Posted April 28, 2005 Do you not have in Mouse options, to change primary button with secondary button? I have the option in XP.<{POST_SNAPBACK}>Yes, but that's just a crude workaround.I was thinking more of a DLLCall or something...
Josbe Posted April 28, 2005 Posted April 28, 2005 Maybe ControlClick()e.g.:Case $msg = $pressedCTRL ControlClick($hWnd, "", $pressedCTRL, "right"); Display the context menu AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
Helge Posted April 28, 2005 Author Posted April 28, 2005 Maybe ControlClick()e.g.:Case $msg = $pressedCTRL ControlClick($hWnd, "", $pressedCTRL, "right"); Display the context menu<{POST_SNAPBACK}>Already thought of.. It works perfectly, however I wouldn't call this a clean solutionbut maybe a...clean workaround.. ?Anyway, I will probably use this method if there isn't any other way of doing it.
Josbe Posted April 28, 2005 Posted April 28, 2005 Already thought of.. It works perfectly, however I wouldn't call this a clean solutionbut maybe a...clean workaround.. ?Anyway, I will probably use this method if there isn't any other way of doing it.<{POST_SNAPBACK}>Yes, maybe isn't a clean, like you say...I think that, there is a DLL function... AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
therks Posted April 29, 2005 Posted April 29, 2005 That's how I always did it. Only problem is that the menu will appear near the mouse, even if you used an accelerator key or something. Say the button name was &Click, you move your mouse 200px away from teh button, then press Alt+C. The menu will appear at the mouse. My AutoIt Stuff | My Github
Lazycat Posted April 29, 2005 Posted April 29, 2005 Hmm, with DllCall we can do it this way:#include <GUIConstants.au3> $WM_CONTEXTMENU = 0x7B $hGUI = GUICreate("Left Clicks context demo", 300, 200) $hMenu = GUICtrlCreateContextMenu() GUICtrlCreateMenuitem ("Menu item 1", $hMenu) GUICtrlCreateMenuitem ("Menu item 2", $hMenu) $hBtn = GUICtrlCreateButton("Click me!", 5, 5) GUISetState() While 1 $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_CLOSE Then Exit If $nMsg = $hBtn Then DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hGUI, "int", $WM_CONTEXTMENU, "int", ControlGetHandle($hGUI, "", $hBtn), "int", 0) Endif WendThat's how I always did it. Only problem is that the menu will appear near the mouse, even if you used an accelerator key or something. Say the button name was &Click, you move your mouse 200px away from teh button, then press Alt+C. The menu will appear at the mouse.Yes, it is... According to MSDN lParam here is carry position of where mouse clicked. But I'm trying to set this with no luck... it's always appears at mouse position. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s])
Helge Posted May 12, 2005 Author Posted May 12, 2005 Awsome, LazyCat !Thanks a bunch !I saw your post yesterday, but then I didn't had the time to test it !Anyway, it works perfectly ! Thanks again !ShakeHand("right")-Helge-Hmm, with DllCall we can do it this way:#include <GUIConstants.au3> $WM_CONTEXTMENU = 0x7B $hGUI = GUICreate("Left Clicks context demo", 300, 200) $hMenu = GUICtrlCreateContextMenu() GUICtrlCreateMenuitem ("Menu item 1", $hMenu) GUICtrlCreateMenuitem ("Menu item 2", $hMenu) $hBtn = GUICtrlCreateButton("Click me!", 5, 5) GUISetState() While 1 $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_CLOSE Then Exit If $nMsg = $hBtn Then DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hGUI, "int", $WM_CONTEXTMENU, "int", ControlGetHandle($hGUI, "", $hBtn), "int", 0) Endif WendYes, it is... According to MSDN lParam here is carry position of where mouse clicked. But I'm trying to set this with no luck... it's always appears at mouse position.<{POST_SNAPBACK}>
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