TheAutomator Posted October 30, 2014 Share Posted October 30, 2014 Hi I'm trying to make a small script (windowless), when you run it there needs to appear a context-menu where the cursor is. So if you double-click on the script file it looks like the menu appears on the script icon.. is this easy to do? can't find an answer directly, wish i could post some code to begin with but I have no clue how to start this Can i use $hMenu = GUICtrlCreateContextMenu(-1) for this with no window? dll calls are welcome to if it's not possible the simple way Like always, thanks in advance! TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
MikahS Posted October 30, 2014 Share Posted October 30, 2014 It must either be associated with the GUI window in it's entirety or to a single Ctrl. That is using GUICtrlCreateContextMenu though, and I don't have any knowledge of a workaround. Hopefully someone with more experience/knowledge will chime in. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
funkey Posted October 30, 2014 Share Posted October 30, 2014 (edited) #NoTrayIcon Opt('GUIOnEventMode', 1) Global $hGui = GUICreate("Dummy Gui", 0, 0, -200, -200, -1, 0, WinGetHandle(AutoItWinGetTitle())) GUISetState() Global $Context = GUICtrlCreateContextMenu(GUICtrlCreateDummy()) Global $OptionsOpen = GUICtrlCreateMenuItem("&Open", $Context) GUICtrlSetOnEvent(-1, '_Hello') Global $OptionsClose = GUICtrlCreateMenuItem("&Close", $Context) GUICtrlCreateMenuItem("", $Context) Global $OptionsExit = GUICtrlCreateMenuItem("&Exit", $Context) TrackPopupMenu($hGui, GUICtrlGetHandle($Context), MouseGetPos(0), MouseGetPos(1)) ; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd) Func TrackPopupMenu($hWnd, $hMenu, $x, $y) DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc ;==>TrackPopupMenu Func _Hello() MsgBox(0, "Hello", "How are you?") EndFunc Edited October 30, 2014 by funkey TheAutomator and MikahS 2 Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
TheAutomator Posted October 30, 2014 Author Share Posted October 30, 2014 #NoTrayIcon Opt('GUIOnEventMode', 1) Global $hGui = GUICreate("Dummy Gui", 0, 0, -200, -200, -1, 0, WinGetHandle(AutoItWinGetTitle())) GUISetState() Global $Context = GUICtrlCreateContextMenu(GUICtrlCreateDummy()) Global $OptionsOpen = GUICtrlCreateMenuItem("&Open", $Context) GUICtrlSetOnEvent(-1, '_Hello') Global $OptionsClose = GUICtrlCreateMenuItem("&Close", $Context) GUICtrlCreateMenuItem("", $Context) Global $OptionsExit = GUICtrlCreateMenuItem("&Exit", $Context) TrackPopupMenu($hGui, GUICtrlGetHandle($Context), MouseGetPos(0), MouseGetPos(1)) ; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd) Func TrackPopupMenu($hWnd, $hMenu, $x, $y) DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc ;==>TrackPopupMenu Func _Hello() MsgBox(0, "Hello", "How are you?") EndFunc guess it was not possible the simple way ^^ that's an interesting workaround, thanks for that! Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
funkey Posted October 30, 2014 Share Posted October 30, 2014 guess it was not possible the simple way ^^ that's an interesting workaround, thanks for that! That is the simple way You are welcome. Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. 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