Jump to content
Sign in to follow this  
Krol

Context menu

Recommended Posts

Krol

Can i create (simple, without GUI) context menu, which will be to appear at pressing hot key?

Share this post


Link to post
Share on other sites
tAKTelapis

So, press a hotkey, and a small menu pops up?

Yup, but its gonna need a GUI.

Just have the hotkey change the state of the GUI, from @SW_HIDE to @SW_SHOW. :)

Or even have it draw and destroy the GUI.

Share this post


Link to post
Share on other sites
Krol

It would not be desirable to do GUI but if it is impossible to use simple context menu likely it is necessary :)

Share this post


Link to post
Share on other sites
James

Something like this should start you off.

#include <GuiConstants.au3>

HotKeySet("{F2}", "Context")

$hwnd = GUICreate("", 400, 300)
GUISetState()

Do
    $Msg = GUIGetMsg()
Until $Msg = $GUI_EVENT_CLOSE

Func Context()
    Local $Pos = WinGetPos($hwnd)
    
    $C = GUICreate("", 60, 80, $Pos[2], $Pos[3])
    GUISetState()
    
    While WinExists($C)
        $cMsg = GUIGetMsg()
        Switch $cMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($C)
        EndSwitch
    WEnd
EndFunc

You will need to change the Context GUI style.

Share this post


Link to post
Share on other sites
Somerset

made this awhile ago.. :)

#include <GUIConstants.au3>
Global $title="Customizedcontextmenu"
HotKeySet("{End}", "Terminate")
HotKeySet("{f1}", "RClickie")
GUICreate($title, 1, 1,1,1,$WS_POPUP)


$contextmenu    = GUICtrlCreateContextMenu ()

$newsubmenu  = GUICtrlCreateMenu ("new", $contextmenu)
$textitem      = GUICtrlCreateMenuitem ("text", $newsubmenu)

$fileitem      = GUICtrlCreateMenuitem ("Open", $contextmenu)
$saveitem      = GUICtrlCreateMenuitem ("Save", $contextmenu)
GUICtrlCreateMenuitem ("", $contextmenu)   ; separator

$notepad      = GUICtrlCreateMenuitem ("Notepad", $contextmenu)

GUISetState ()
WinSetState ($title, "",@SW_HIDE)

While 1
$msg = GUIGetMsg()
if $msg = $notepad then Run ( "notepad.exe")
    Sleep(10)
WEnd


Func Terminate()
    Exit 0
EndFunc

Func RClickie()
$pos = MouseGetPos()
WinMove ($title, "", $pos[0], $pos[1])
ControlClick ($title,"","","right")
WinSetState ($title, "",@SW_hide)
EndFunc

 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites
Krol

@beerman thx, very good! :)

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  

×