ColtsFan Posted January 17, 2010 Share Posted January 17, 2010 I've got a GUI that saves it's position upon exit. When I unplug my second monitor and use just my laptop screen the GUI is often docked off the screen. This brings up a question I've wondered for a long time, is it possible to add a menu item to the taskbar button? Not the icon by the clock, but the actual button itself (see attached thumbnail). For Example, when you right-click the AutoIt help file there are additional options there. This might not be possible. I searched the help file and couldn't find anything on it. Here's a screenshot of the menu I mean... Perhaps someone knows of a UDF or something that might help? Thanks for your help Link to comment Share on other sites More sharing options...
Anoni Posted January 19, 2010 Share Posted January 19, 2010 I am watching this string hopeful that someone can answer this question. Hopefully it is possible. Maybe having made a reply at all will get this the attention it needs for someone to provide an answer? *if you find a solution to this outside of the forums, it would be appreciated if you could share* -good luck!- Link to comment Share on other sites More sharing options...
reb Posted January 19, 2010 Share Posted January 19, 2010 Hi I found this on the forum a while back. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <Constants.au3> Opt("TrayAutoPause",1) Opt("TrayMenuMode",1) HotKeySet("^!x" , "getcolor") HotKeySet("{ESC}" , "fexit") $setclip = 1 dim $vdif, $wdif, $output, $black, $cyanng, $magentang, $yellowng $main = GUICreate("Get cursor Color", 75, 45, @DesktopWidth - 140, @DesktopHeight - 120, $WS_BORDER, $WS_EX_CLIENTEDGE + $WS_EX_TOPMOST ) GUISetState() ;Tray GUI Creation $Clip = TrayCreateItem("To Clipboard ") TrayItemSetState($clip, $TRAY_CHECKED) $setclip = 1 TrayCreateItem("") $valitem = TrayCreateItem("Instructions") TrayCreateItem("") $aboutitem = TrayCreateItem("About") TrayCreateItem("") $exit = TrayCreateItem("Exit") TraySetState() While 1 $mouse = MouseGetPos() $msg = TrayGetMsg() Select Case $msg = 0 $var = PixelGetColor( $mouse[0] , $mouse[1]) $background = GUICtrlSetBkColor($main, $var) GUISetBkColor($var, $main) ContinueLoop Case $msg = $Clip $decide = TrayItemGetState($clip) If $decide = 1 then $setclip = 1 Else $setclip = 0 endif Case $msg = $valitem Msgbox(64,"Instructions:","ALT+CTRL+X - Get Color" & @CRLF & "ESC - Exit Program") Case $msg = $aboutitem Msgbox(64,"about:","November 2009" & @CRLF & "Free usage") Case $msg = $exit exit EndSelect WEnd Func getcolor() ;Hex color to RGB $output = "" $hex = Hex ( $var , 6) ;~ $HR = StringMid($hex, 1, 2) ;~ $HG = StringMid($hex, 3, 2) ;~ $HB = StringMid($hex, 5, 2) ;~ $R = Dec($HR) ;~ $G = Dec($HG) ;~ $B = Dec($HB) ;Convert RGB to CMY ;~ $cyanr = 1-($r/255) ;~ $magentar = 1-($g/255) ;~ $yellowr= 1-($b/255) ;Convert CMY to CMYK ;~ $blackr=1 ;~ If $blackr > $cyanr Then $blackr = $cyanr ;~ if $blackr > $magentar Then $blackr= $magentar ;~ if $blackr > $yellowr Then $blackr = $yellowr ;~ if $blackr = 1 Then ;~ $cyanr = 0 ;~ $magentar = 0 ;~ $yellowr = 0 ;~ Else ;~ $cyanr = ($cyanr-$blackr)/(1-$blackr) ;~ $magentar = ($magentar-$blackr)/(1-$blackr) ;~ $yellowr = ($yellowr-$blackr)/(1-$blackr) ;~ EndIf ;~ $kr = $blackr ;Let's get only the three decimal numbert to match YMCK requirements ;~ $cyan = StringFormat("%.3f", $cyanr) ;~ $magenta = StringFormat("%.3f", $magentar) ;~ $yellow = StringFormat("%.3f", $yellowr) ;~ $k = StringFormat("%.3f", $kr) ;Output results in a a ballon or to the clipboard ;~ $output = "Hexadecimal : " & $hex & @CRLF ;~ $output = $output & "RGB : " & $R & ", " & $G & ", " & $B & @CRLF ;~ $output = $output & "CYMK : C-" & $cyan & ", M-" & $magenta & ", Y-" & $yellow & ", K-" & $k $output = "GUISetBkColor(0x" & $hex & ")" TrayTip("RGB / CYMK Color", $output, 1) $backup = ClipGet() If $setclip = 1 then ClipPut($output) Else ClipPut($backup) EndIf EndFunc func fexit() Exit EndFunc (don't know who to credit it to) It works great for me and includes a menu by right clicking the tray icon which I believe is what you want to do. You can adapt the code to suit your purposes. REB MEASURE TWICE - CUT ONCE Link to comment Share on other sites More sharing options...
danielmohr91 Posted January 24, 2010 Share Posted January 24, 2010 (edited) I've got a GUI that saves it's position upon exit. When I unplug my second monitor and use just my laptop screen the GUI is often docked off the screen. This brings up a question I've wondered for a long time, is it possible to add a menu item to the taskbar button? Not the icon by the clock, but the actual button itself (see attached thumbnail). For Example, when you right-click the AutoIt help file there are additional options there. This might not be possible. I searched the help file and couldn't find anything on it. Here's a screenshot of the menu I mean... Perhaps someone knows of a UDF or something that might help? Thanks for your help Great question. I've often wondered the same thing myself. Thanubus, you made a great suggestion with the _GUICtrlMenu_GetSystemMenu() functions. ColtsFan, Here's a quick example I made on how to add a menu items. This is my first time, this just shows how to get them there. Perhaps someone else here more experienced than myself can enlighten us as how to make it actually do something. I'm thinking something along the lines of GUIRegisterMsg to get started. expandcollapse popup; gui create menu #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> ; This is needed for the GUI Menu... $title = "Menu Test" $Form1 = GUICreate($title, 600, 275, 300, 125) $Button1 = GUICtrlCreateButton("Button1", 10, 15, 580, 60, $WS_GROUP) $Edit1 = GUICtrlCreateEdit("", 10, 80, 580, 180) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _menu() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _menu() Local $hWnd, $hMenu $hWnd = WinGetHandle($title) $hMenu = _GUICtrlMenu_GetSystemMenu($hWnd) For $i = 5 to 10 _GUICtrlMenu_InsertMenuItem($hMenu, $i, "Menu Item " &$i) Next ; Display system menu $iCount = _GUICtrlMenu_GetItemCount($hMenu) EndFunc ;==>_Main Edited January 24, 2010 by danielmohr91 Link to comment Share on other sites More sharing options...
ColtsFan Posted January 24, 2010 Author Share Posted January 24, 2010 Great question. I've often wondered the same thing myself. Thanubus, you made a great suggestion with the _GUICtrlMenu_GetSystemMenu() functions. ColtsFan, Here's a quick example I made on how to add a menu items. This is my first time, this just shows how to get them there. Perhaps someone else here more experienced than myself can enlighten us as how to make it actually do something. I'm thinking something along the lines of GUIRegisterMsg to get started. expandcollapse popup; gui create menu #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> ; This is needed for the GUI Menu... $title = "Menu Test" $Form1 = GUICreate($title, 600, 275, 300, 125) $Button1 = GUICtrlCreateButton("Button1", 10, 15, 580, 60, $WS_GROUP) $Edit1 = GUICtrlCreateEdit("", 10, 80, 580, 180) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _menu() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _menu() Local $hWnd, $hMenu $hWnd = WinGetHandle($title) $hMenu = _GUICtrlMenu_GetSystemMenu($hWnd) For $i = 5 to 10 _GUICtrlMenu_InsertMenuItem($hMenu, $i, "Menu Item " &$i) Next ; Display system menu $iCount = _GUICtrlMenu_GetItemCount($hMenu) EndFunc ;==>_Main Thanks everyone! And thank you daniel, for the example I deleted the for... to... loop and added my own menu items. Pretty cool. Like you said, I still don't have anyway of responding to them. I read up on GuiRegisterMsg and you're on to something. I can't figure out what to call with it though. Anyone? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 24, 2010 Moderators Share Posted January 24, 2010 Hi guys,You read a new SysMenu item by registering the WM_SYSCOMMAND message. I have based this on your script and used the Edit control to show the result:expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> ; This is needed for the GUI Menu... $title = "Menu Test" $Form1 = GUICreate($title, 600, 275, 300, 125) $Button1 = GUICtrlCreateButton("Button1", 10, 15, 580, 60, $WS_GROUP) $Edit1 = GUICtrlCreateEdit("", 10, 80, 580, 180) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _menu() GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _menu() Local $hWnd, $hMenu $hWnd = WinGetHandle($title) $hSystemMenu = _GUICtrlMenu_GetSystemMenu($hWnd) _GUICtrlMenu_GetItemCount($hSystemMenu) _GUICtrlMenu_AppendMenu($hSystemMenu, $MF_SEPARATOR, 0, "") _GUICtrlMenu_AppendMenu($hSystemMenu, $MF_STRING, 0x5000, "New Sysmenu Item") EndFunc ;==>_menu Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam) If BitAND($wParam, 0xFFFF) = 0x5000 Then Write("You pressed me!") EndFunc ;==>WM_SYSCOMMAND ; Write message to memo Func Write($sMessage) GUICtrlSetData($Edit1, $sMessage & @CRLF, 1) EndFunc ;==>WriteI hope it does what you want. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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