Jump to content

Windowless context-menu when script starts


 Share

Recommended Posts

Hi  :bye:

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  :sweating:

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

Link to comment
Share on other sites

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. :D

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

#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 by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

#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!

Link to comment
Share on other sites

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 to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
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
 Share

×
×
  • Create New...