fmen Posted September 9, 2005 Posted September 9, 2005 I am embarrassed to post the small bit of code I came up with so would appreciate any help or direction. My goal is to create a menu launcher that pops up with a right click of the mouse at the top, bottom, or sides of the screen, and then disappears until it is needed again. Something like the excellent runit (www.magister-lex.at/RUNit). Maybe someone already wrote it but my searches were not successful. Thanks. Opt("SendKeyDelay", 0) Opt("WinTitleMatchMode", 2) #include <GUIConstants.au3> $pos = MouseGetPos() If $pos[1]=0 Then GUICreate("Gui", 50, 100, $pos[0],$pos[1], $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $b = GuiCtrlCreateButton("Go", -1, -1, 50, 17) ;;;;;;;;;;;;RIGHT CLICK MENU;;;;;;;;;;;;;;;;;;;;; $bcontext = GUICtrlCreateContextMenu($b) $bexit = GUICtrlCreateMenuitem("Exit",$bcontext) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $bexit Then ExitLoop Wend endif
Dickb Posted September 9, 2005 Posted September 9, 2005 I am embarrassed to post the small bit of code I came up with so would appreciate any help or direction.My goal is to create a menu launcher that pops up with a right click of the mouse at the top, bottom, or sides of the screen, and then disappears until it is needed again.Something like the excellent runit (www.magister-lex.at/RUNit).Maybe someone already wrote it but my searches were not successful. Thanks.<{POST_SNAPBACK}>Is this what you want? It's not the way I would organize the code, but I left it as close as possible to your code.The sleep is to reduce the processor usage. Without it, the processor usage will be 100%.And you need to place the mouse test in a loop (The While/Wend) else the mouse position will only be tested once.After the Exit choice you have to delete the Gui else it stays visible.opt("SendKeyDelay", 0) opt("WinTitleMatchMode", 2) #include <GUIConstants.au3> While 1 $pos = MouseGetPos() If $pos[1] = 0 Then $MyGui = GUICreate("Gui", 50, 100, $pos[0], $pos[1], $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $b = GUICtrlCreateButton("Go", -1, -1, 50, 17) ;;;;;;;;;;;;RIGHT CLICK MENU;;;;;;;;;;;;;;;;;;;;; $bcontext = GUICtrlCreateContextMenu($b) $bexit = GUICtrlCreateMenuItem("Exit", $bcontext) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $bexit Then GUIDelete($MyGui) ExitLoop EndIf WEnd EndIf Sleep(100) WEnd
PerryRaptor Posted September 10, 2005 Posted September 10, 2005 (edited) Here is a popup menu that slides in from the right along the righthand side of the desktop when the desktop has the focus. it is activated by pressing the {home} key on the keyboard. This demo uses less than 7% of the CPU. I prefer this popup menu because it hasn't interfered with other applications thus far. expandcollapse popup#NoTrayIcon #include <GUIConstants.au3> Opt("GuiOnEventMode", 1) $Menupos = 1 $GuiWidth = 150 $GuiHeight = 500 $xPos = (@DesktopWidth) $yPos = (@DesktopHeight - $GuiHeight) / 2 ;$Button_1A = "button_1A" ;$Button_1B = "button_1B" ;Main Gui $Gui = GUICreate("Gui", 150, 500, $xPos, $yPos, $WS_POPUP, $WS_EX_TOOLWINDOW) GUISetBkColor (0) GUISetState() ;ButtonA $ButtonA = GUICtrlCreateButton ( "ButtonA", 25, 20 ,100 ,30) GUICtrlSetOnEvent($ButtonA, "ButtonA_Pressed") ;GUICtrlSetImage ( $Button_1A, "C:\Icons\ButtonA.ico" ) GUISetState() ;ButtonB $ButtonB = GUICtrlCreateButton ( "ButtonB", 25, 50 ,100 ,30) GUICtrlSetOnEvent($ButtonB, "ButtonB_Pressed") GUISetState() ;ButtonC $ButtonC = GUICtrlCreateButton ( "Terminate", 25, 450 ,100 ,30) GUICtrlSetOnEvent($ButtonC, "Terminate") GUISetState() HotKeySet("{Home}","Menu_Open") HotKeySet("{End}","Terminate") While 1 Sleep(10) WEnd ;Functions Func Menu_Open () $Menupos = 2 $GuiWidth = 150 $xPos = (@DesktopWidth) HotKeySet("{Home}","None") While $xPos > (@DesktopWidth - $GuiWidth) $xPos = $xPos - 2 WinMove("Gui", "", $xPos, $yPos, 150, 500) Sleep (0) Wend HotKeySet("{home}" , "Menu_Close") EndFunc Func Menu_Close () $Menupos = 1 $GuiWidth = 150 $xPos = (@DesktopWidth - $GuiWidth) HotKeySet("{Home}","None") While $xPos < (@DesktopWidth) $xPos = $xPos + 2 WinMove("Gui", "", $xPos, $yPos, 150, 500) Sleep (0) Wend HotKeySet("{Home}" , "Menu_Open") EndFunc Func None () EndFunc Func ButtonA_Pressed() MsgBox(4096,"control", "ButtonA pressed") EndFunc Func ButtonB_Pressed() MsgBox(4096,"control", "ButtonB pressed") EndFunc Func Terminate () If $Menupos = 1 Then Else $GuiWidth = 150 $xPos = (@DesktopWidth - $GuiWidth) HotKeySet("{Home}","None") While $xPos < (@DesktopWidth) $xPos = $xPos + 2 WinMove("Gui", "", $xPos, $yPos, 150, 500) Sleep (0) Wend EndIf Exit 0 EndFunc I'm not the originator of the code. I got it from Nova. Edited September 10, 2005 by PerryRaptor
PerryRaptor Posted September 11, 2005 Posted September 11, 2005 Oh, I forgot to mod the script...Needs a GuiDelete command in the Terminate() function in case the desktop resolution is re-sized.
fmen Posted September 13, 2005 Author Posted September 13, 2005 This is way more than I had hoped for. Thank you so much.]
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