Moderators Melba23 Posted November 2, 2011 Moderators Share Posted November 2, 2011 dv8, My pleasure. 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...
coffeeturtle Posted November 10, 2011 Share Posted November 10, 2011 This is a welcomed addition to Menu and Tray Menu items! I very much wanted such functionality for a long time instead of the plain look and feel. I am going to implement this right away into my own codes.Thank you!By the way, is there a way to get the actual system tray icon to reflect text instead of an image? For instance, imitating the System Tray clock. I'd like to have my own system tray clock with these new modern menu.I guess an example of this in C++ is here:http://blogs.msdn.com/b/abhinaba/archive/2005/09/12/464150.aspxBut it doesn't seem AutoIT has similar commands in it's systemtray functions.Thanks for any input or directing. Link to comment Share on other sites More sharing options...
faustf Posted July 6, 2012 Share Posted July 6, 2012 hi guy i have some problem this is my code i dont understund why if i use this include the script block : ERROR: $ILC_MASK previously declared as a 'Const'. If Not IsDeclared("ILC_MASK") Then Global $ILC_MASK = 0x0001 my code expandcollapse popup; ModernMenu2003 Gradient Example ; Syntax: ; ;_SetMenuIconGradBkColor(0x??????) ;where ? is a hexadecimal digit ; To prevent gradient, use this code: ; ;_SetMenuIconGradBkColor($nMenuIconBkClr) ;#include <GuiEdit.au3> ;#include <GUIConstantsEx.au3> ;#include <WindowsConstants.au3> ;#include <ButtonConstants.au3> ;#include <Date.au3> ;#include <editconstants.au3> ;#include <listviewconstants.au3> ;#include <staticconstants.au3> ;#include <windowsconstants.au3> ;#include <guilistview.au3> ;#include <Word.au3> #include <GuiImageList.au3> ;#include <Timers.au3> ;#include <GuiListBox.au3> ;#include <GuiButton.au3> ;#include <ComboConstants.au3> ;#include <misc.au3> ;#include <Word.au3> ;#include <MPDF_UDF.au3> ;#include <GUIComboBox.au3> ;#include <Constants.au3> ;#include <DateTimeConstants.au3> ;#include <file.au3> ;#include <array.au3> ;#include <INet.au3> ;#include <Process.au3> ;#include <ColorPicker.au3> ;#include <WinAPI.au3> ;#include <GDIPlus.au3> ;#include <ScreenCapture.au3> #include <GUIConstants.au3> #include 'ModernMenu.au3' Global Const $WM_CONTEXTMENU = 0x7B $hMainGUI = GUICreate('Sample Menu') ; Set default color values - BGR-values! SetDefaultMenuColors() ; File-Menu $FileMenu = GUICtrlCreateMenu('&File') $OpenItem = _GUICtrlCreateODMenuItem('Open', $FileMenu, 'shell32.dll', 4) $SaveItem = _GUICtrlCreateODMenuItem('Save', $FileMenu, 'shell32.dll', 6) _GUICtrlCreateODMenuItem('', $FileMenu) ; Separator $RecentMenu = _GUICtrlCreateODMenu('Recent Files', $FileMenu) _GUICtrlCreateODMenuItem('', $FileMenu) ; Separator $ExitItem = _GUICtrlCreateODMenuItem('Exit', $FileMenu, 'shell32.dll', 27) ; Tools-Menu $ToolsMenu = GUICtrlCreateMenu('&Tools') $CalcItem = _GUICtrlCreateODMenuItem('Calculator', $ToolsMenu, 'calc.exe', 0) $CmdItem = _GUICtrlCreateODMenuItem('CMD', $ToolsMenu, 'cmd.exe', 0) $EditorItem = _GUICtrlCreateODMenuItem('Editor', $ToolsMenu, 'notepad.exe', 0) $RegeditItem = _GUICtrlCreateODMenuItem('Regedit', $ToolsMenu, 'regedit.exe', 0) ; View-Menu $ViewMenu = GUICtrlCreateMenu('&View') $ViewColorMenu = _GUICtrlCreateODMenu('Menu Colors', $ViewMenu, 'mspaint.exe', 0) $SetDefClrItem = _GUICtrlCreateODMenuItem('Default', $ViewColorMenu, '', 0, 1) _GUICtrlCreateODMenuItem('', $ViewColorMenu) ; Separator $SetRedClrItem = _GUICtrlCreateODMenuItem('Red', $ViewColorMenu, '', 0, 1) $SetGrnClrItem = _GUICtrlCreateODMenuItem('Green', $ViewColorMenu, '', 0, 1) GUICtrlSetState(-1, $GUI_CHECKED) $SetBlueClrItem = _GUICtrlCreateODMenuItem('Blue', $ViewColorMenu, '', 0, 1) $ViewStateItem = _GUICtrlCreateODMenuItem('Enable Config', $ViewMenu) GUICtrlSetState(-1, $GUI_CHECKED) ; Help-Menu $HelpMenu = GUICtrlCreateMenu('&?') $HelpItem = _GUICtrlCreateODMenuItem('Help Topics', $HelpMenu, 'shell32.dll', 23) _GUICtrlCreateODMenuItem('', $HelpMenu) ; Separator $AboutItem = _GUICtrlCreateODMenuItem('About...', $HelpMenu, '', 0) ; You can also the same things on context menus $GUIContextMenu = GUICtrlCreateContextMenu(-1) $ConAboutItem = _GUICtrlCreateODMenuItem('About...', $GUIContextMenu, 'explorer.exe', 7) _GUICtrlCreateODMenuItem('', $GUIContextMenu) ; Separator $ConExitItem = _GUICtrlCreateODMenuItem('Exit', $GUIContextMenu, 'shell32.dll', 27) ; My_WM_MeasureItem and My_WM_DrawItem are registered in ; 'ModernMenu.au3' so they don't need to registered here ; Also OnAutoItExit() is in 'ModernMenu.au3' to cleanup the ; menu imagelist and special font GUISetState() ; Main GUI Loop While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE, $ExitItem, $ConExitItem ExitLoop Case $AboutItem, $ConAboutItem Msgbox(64, 'About', 'Menu color sample by Holger Kotsch') Case $ViewStateItem If BitAnd(GUICtrlRead($ViewStateItem), $GUI_CHECKED) Then GUICtrlSetState($ViewStateItem, $GUI_UNCHECKED) GUICtrlSetState($ViewColorMenu, $GUI_DISABLE) Else GUICtrlSetState($ViewStateItem, $GUI_CHECKED) GUICtrlSetState($ViewColorMenu, $GUI_ENABLE) EndIf Case $SetDefClrItem SetCheckedItem($SetDefClrItem) SetDefaultMenuColors() Case $SetRedClrItem SetCheckedItem($SetRedClrItem) SetRedMenuColors() Case $SetGrnClrItem SetCheckedItem($SetGrnClrItem) SetGreenMenuColors() Case $SetBlueClrItem SetCheckedItem($SetBlueClrItem) SetBlueMenuColors() EndSwitch WEnd Exit Func SetCheckedItem($DefaultItem) GUICtrlSetState($SetDefClrItem, $GUI_UNCHECKED) GUICtrlSetState($SetRedClrItem, $GUI_UNCHECKED) GUICtrlSetState($SetGrnClrItem, $GUI_UNCHECKED) GUICtrlSetState($SetBlueClrItem, $GUI_UNCHECKED) GUICtrlSetState($DefaultItem, $GUI_CHECKED) EndFunc Func SetDefaultMenuColors() _SetMenuBkColor(0xFFFFFF) ;_SetMenuIconBkColor(0xCACACA) ;_SetMenuIconGradBkColor(0xEFEFEF) ;;; _SetMenuSelectBkColor(0xE5A2A0) _SetMenuSelectRectColor(0x854240) _SetMenuSelectTextColor(0x000000) _SetMenuTextColor(0x000000) EndFunc Func SetRedMenuColors() _SetMenuBkColor(0xAADDFF) ;_SetMenuIconBkColor(0x5566BB) ;_SetMenuIconGradBkColor(0x99CCEE) ;;; _SetMenuSelectBkColor(0x70A0C0) _SetMenuSelectRectColor(0x854240) _SetMenuSelectTextColor(0x000000) _SetMenuTextColor(0x000000) EndFunc Func SetGreenMenuColors() _SetMenuBkColor(0xAAFFAA) ;_SetMenuIconBkColor(0x66BB66) ;_SetMenuIconGradBkColor(0x99EE99) ;;; _SetMenuSelectBkColor(0xBBCC88) _SetMenuSelectRectColor(0x222277) _SetMenuSelectTextColor(0x770000) _SetMenuTextColor(0x000000) EndFunc Func SetBlueMenuColors() _SetMenuBkColor(0xFFB8B8) ;_SetMenuIconBkColor(0xBB8877) ;_SetMenuIconGradBkColor(0xEEA7A7) ;;; _SetMenuSelectBkColor(0x662222) _SetMenuSelectRectColor(0x4477AA) _SetMenuSelectTextColor(0x66FFFF) _SetMenuTextColor(0x000000) EndFunc Func _HiWord($x) Return BitShift($x, 16) EndFunc ;==>_HiWord Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc ;==>_LoWord can you help me?? thankz Link to comment Share on other sites More sharing options...
AZJIO Posted January 23, 2013 Share Posted January 23, 2013 Win7 x 64 supported? My other projects or all Link to comment Share on other sites More sharing options...
MachinistProgrammer Posted November 6, 2013 Share Posted November 6, 2013 the download file is corrupt All my projects live on github Link to comment Share on other sites More sharing options...
LarsJ Posted November 6, 2013 Share Posted November 6, 2013 sycam0inc, You can open the file with 7-zip. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
MachinistProgrammer Posted November 7, 2013 Share Posted November 7, 2013 Never mind it was just an old version of Internet explorer caulsing trouble (so logically i got Firefox) All my projects live on github Link to comment Share on other sites More sharing options...
AZJIO Posted December 21, 2013 Share Posted December 21, 2013 32 example ModernMenuRaw_Examples.7z pixelsearch 1 My other projects or all Link to comment Share on other sites More sharing options...
Popular Post LarsJ Posted October 18, 2014 Popular Post Share Posted October 18, 2014 (edited) I'm going to use these menus. I've updated the UDF, ModernMenuRaw.au3. Of the posts it appears that Holger updated the code on a regular basis until May 2008. ProgAndy made some updates in August 2008. These updates were about the background color of the menubar, the ability to use icon handles, and better cleanup code on exit. The updates I've made are based on the UDF by ProgAndy attached to post 213. It's my intention to update the UDF to make it run under the current versions of AutoIt, and to get rid of errors. Especially already known errors, which can be fixed in a few lines of code. It's not my intention to add a lot of new code to the UDF. Updates 2014-10-18 This update is based on original code by Holger (first post) and updates by ProgAndy (posts 211 - 213). The update supports AutoIt 3.3.10 and later. Code relating to Windows versions not supported by 3.3.10 is deleted. WindowsConstants.au3 is included and double-defined global constants are commented out. Added an update to be able to use colored controls e.g. buttons with this UDF. Post 222. Update (one line) for x64 support. Post 266 by Holger. Added x64 support to functions by ProgAndy. Declared a few local variables. Updates 2014-10-19 Updates to pass Au3Check. (-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6) Updates 2015-01-24 Updates for tray menus suggested by nickston (posts 298, 299, 312) Most important is an update that makes it possible to use a flashing tray menu icon. There are also a few code optimizations. Updates 2021-11-12 Disabled $IDI_ global constants in ModernMenuRaw.au3. $IDI_ constants are included in AutoItConstants.au3. None of the updates above are script breaking. If you are using tray menus and want to compile your script, you should pay attention to posts 268 - 270. Note also that _TrayIconCreate creates a GUI to receive messages from tray icons. After calling this function you should probably use GUISwitch($hGui) or something. Post 227. In the top of ModernMenuRaw.au3 I've included commands.txt from the original zip by Holger. Two commands of ProgAndy to handle the background color of the menubar are added. I've also added an alphabetical list of functions, and a list of Windows messages (used with GUIRegisterMsg). Examples In order to make it easy the examples are included in the zip. The original examples by Holger are included with no changes at all. The 32 examples by AZJIO in the post above are also included with no changes. There are two versions of the examples: an english and a russian. The examples demonstrates the commands one by one and are named with the name of the command. Copied an example by AZJIO and renamed it to _TrayIconSetState-flashing.au3. Added one line of code to make the tray menu icon flash. Only an english version. A new example by nickston that demonstrates a flashing tray menu icon. The example shows how to turn flashing on and off. Two new examples _GUICtrlCreateODTopMenu.au3 and _GUIMenuBarSetBkColor.au3 that demonstrates the commands by ProgAndy to set the background color of the menubar. _GUIMenuBarSetBkColor.au3 is not working on Windows 7. A new example that shows how to use a bitmap from an image list as an icon in a menu item. The example shows also how to use icon handles. 7z-file ModernMenuRaw.au3 - update on 12.11.2021 ModernMenuRaw.au3 - all previous versions ExamplesAZJIO - 32 examples by AZJIO in english and russian versions ExamplesHolger - the original examples by Holger Examplesnickston - flashing tray menu icon ExampleszNew - three new examples Tested with AutoIt 3.3.10 on Windows 7 32/64 bit and Windows XP 32 bit. 2014-10-19: ModernMenuRaw.7z 2015-01-24: ModernMenuRaw.7z Tested with AutoIt 3.3.14.2/5 and beta 3.3.15.4 on Windows 7/10 32/64 bit. ModernMenuRaw.7z Edited November 13, 2021 by LarsJ New update and 7z-file mLipok, Parsix, abberration and 6 others 7 2 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
editcheck Posted October 25, 2014 Share Posted October 25, 2014 thz to Holger for the code and thz to LarsJ for the update. =) Link to comment Share on other sites More sharing options...
orbs Posted November 3, 2014 Share Posted November 3, 2014 hello, few questions i have for anyone who has been using this great UDF: 1) is there a way to have the menu with the side title, but without icons (and without the icons placeholder)? not setting icons at all does not do it - it reverts the modern menu back to standard. 2) is there a way to have a submenu without icons (and without the icons placeholder), but keep the modern menu colors? 3) is there a way to make the tray menu respond to double-click? thanks for any hints. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
LarsJ Posted November 3, 2014 Share Posted November 3, 2014 Thanks for comments and likes.1) and 2) Icons appear to be the main point of this UDF. I do not think that you can create menus without icons. It certainly can be done, but you have to implement the owner drawn menus yourself. You can find the code in the UDF.3) No, not with this UDF. As far as I know most menus respond to a single click and then closes. The menu will never receive the double click. To implement double click in a standard menu, you probably have to use methods like hook procedures or menu subclassing.You can get the updated (19.10.2014) UDF in post 289. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
nickston Posted January 3, 2015 Share Posted January 3, 2015 Thanks for comments and likes. 1) and 2) Icons appear to be the main point of this UDF. I do not think that you can create menus without icons. It certainly can be done, but you have to implement the owner drawn menus yourself. You can find the code in the UDF. 3) No, not with this UDF. As far as I know most menus respond to a single click and then closes. The menu will never receive the double click. To implement double click in a standard menu, you probably have to use methods like hook procedures or menu subclassing. You can get the updated (19.10.2014) UDF in post 289. In post >251 was described error, I think need adding fix in your update. Into func _TrayIconSetState change SetTimer($TRAYMSGWND, $FLASHTIMERID, $FLASHTIMEOUT, 0) to SetTimer($TRAYMSGWND, $nID, $FLASHTIMEOUT, 0) Link to comment Share on other sites More sharing options...
LarsJ Posted January 4, 2015 Share Posted January 4, 2015 Thank you, I'll update the UDF.Do you have an example that demonstrates the flashing? Just a small example like the examples by AZJIO. Then I'll add the example to the zip. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
UEZ Posted January 4, 2015 Share Posted January 4, 2015 I think it makes more sense to lock this topic and open a new one.Br,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
LarsJ Posted January 4, 2015 Share Posted January 4, 2015 Why do you think that? At least 95% of the code is still the original code by Holger. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
UEZ Posted January 4, 2015 Share Posted January 4, 2015 Because Holger isn't active for a long time, this topic started before 9 years and it is still active.Br,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
nickston Posted January 4, 2015 Share Posted January 4, 2015 Thank you, I'll update the UDF. Do you have an example that demonstrates the flashing? Just a small example like the examples by AZJIO. Then I'll add the example to the zip. Ex: #NoTrayIcon #include <ModernMenuRAW.au3> #include <GUIConstantsEx.au3> $tray_win=_TrayIconCreate('g',@ScriptName,0) _SetTrayBkColor(0xAAFFAA) _SetTrayIconBkColor(0xBB8877) _SetTraySelectRectColor(0x4477AA) _SetTrayTextColor(0x000000) _TrayCreateContextMenu($tray_win) $tray_start=_TrayCreateItem('Start') _TrayItemSetIcon(-1, "", 0) $star=False GUICtrlSetState(-1,$star) _TrayCreateItem('') _TrayItemSetIcon(-1, "", 0) $tray_exit=_TrayCreateItem('Exit') _TrayItemSetIcon(-1,"shell32.dll", 28);28 While 1 $msg=GUIGetMsg() Switch $msg Case $tray_exit exit Case $tray_start If $star Then GUICtrlSetState($tray_start,$GUI_UNCHECKED) _trayiconsetstate($tray_win,8) Else GUICtrlSetState($tray_start,$GUI_CHECKED) _trayiconsetstate($tray_win,4) EndIf $star= Not $star EndSwitch WEnd And some new improvement: Func _GetIconID($nID, $sFile) #cs If StringRight($sFile, 4) = ".exe" Then If $nID < 0 Then $nID = - ($nID + 1) ElseIf $nID > 0 Then $nID = - $nID EndIf ElseIf StringRight($sFile, 4) = ".icl" And $nID < 0 Then $nID = - ($nID + 1) Else If $nID > 0 Then $nID = - $nID ElseIf $nID < 0 Then $nID = - ($nID + 1) EndIf EndIf #ce ;nickston ;#cs $nID = - $nID If $nID > 0 Then $nID -=1 EndIf ;#ce Return $nID EndFunc Func _GetNewTrayIndex() Local $i, $bFreeFound = FALSE For $i = 1 To $TRAYNOTIFYIDS[0][0] If $TRAYNOTIFYIDS[$i][0] = 0 Then $bFreeFound = TRUE ExitLoop EndIf Next If Not $bFreeFound Then $TRAYNOTIFYIDS[0][0] += 1 Local $nSize = UBound($TRAYNOTIFYIDS) ;If $TRAYNOTIFYIDS[0][0] > $nSize - 10 Then _ ; Redim $TRAYNOTIFYIDS[$nSize + 10][9] ;nickston If $TRAYNOTIFYIDS[0][0] > $nSize - 1 Then _ Redim $TRAYNOTIFYIDS[$nSize + 10][9] $i = $TRAYNOTIFYIDS[0][0] EndIf Return $i EndFunc expandcollapse popupFunc _TrayIconCreate($sToolTip = "", $sIconFile = @AutoItExe, $nIconID = 0, $sCallback = "", $nMsg = 0, $hIcon = 0) If $sToolTip = "" Then $sToolTip = $sDefaultTT ;nickston+ #cs $nIconID = _GetIconID($nIconID, $sIconFile) If $sIconFile = "" Then If $hIcon = 0 Then If $nIconID = 0 Then $sIconFile = @AutoItExe Else $hIcon = LoadIcon(0, $nIconID) EndIf EndIf EndIf If $sIconFile <> "" Then Local $stIcon = DllStructCreate("hwnd") If ExtractIconExW($sIconFile, $nIconID, 0, DllStructGetPtr($stIcon), 1) > 0 Then $hIcon = DllStructGetData($stIcon, 1) Else $hIcon = LoadIcon(0, 32516) EndIf EndIf If $TRAYMSGWND = 0 Then $TRAYMSGWND = GUICreate("", 1, 1, 9999, 9999, -1, 0x00000080) GUISetState() ShowWindow($TRAYMSGWND, @SW_HIDE) EndIf Local $nNID = _GetNewTrayIndex() If $nNID = 0 Then DestroyIcon($hIcon) Return 0 EndIf #ce ;nickston- ; #cs If $TRAYMSGWND = 0 Then $TRAYMSGWND = GUICreate("", 1, 1, 9999, 9999, -1, 0x00000080) GUISetState() ShowWindow($TRAYMSGWND, @SW_HIDE) EndIf Local $nNID = _GetNewTrayIndex() If $nNID = 0 Then ;DestroyIcon($hIcon) Return 0 EndIf $hIcon=-1 ;#ce $TRAYNOTIFYIDS[$nNID][0] = $nNID $TRAYNOTIFYIDS[$nNID][1] = $hIcon $TRAYNOTIFYIDS[$nNID][2] = 0 $TRAYNOTIFYIDS[$nNID][3] = 9 $TRAYNOTIFYIDS[$nNID][4] = $sToolTip $TRAYNOTIFYIDS[$nNID][5] = $sCallback $TRAYNOTIFYIDS[$nNID][6] = $nMsg $TRAYNOTIFYIDS[$nNID][7] = FALSE $TRAYNOTIFYIDS[$nNID][8] = FALSE _TrayIconSetIcon($nNID,$sIconFile,$nIconID) $TRAYLASTID = $nNID Return $nNID EndFunc expandcollapse popupFunc _TrayIconDelete($nID) If $nID = -1 Then $nID = $TRAYLASTID If $TRAYMSGWND = 0 Or $nID <= 0 Then Return 0 ;nickston+ #cs Local $stNID = DllStructCreate($sNOTIFYICONDATAW) DllStructSetData($stNID, 1, DllStructGetSize($stNID)) DllStructSetData($stNID, 2, $TRAYMSGWND) DllStructSetData($stNID, 3, $nID) #ce ;nickston- Local $nResult = 0 Local $i For $i = 1 To $TRAYNOTIFYIDS[0][0] If $nID = $TRAYNOTIFYIDS[$i][0] Then $stNID = DllStructCreate($sNOTIFYICONDATAW) DllStructSetData($stNID, 1, DllStructGetSize($stNID)) DllStructSetData($stNID, 2, $TRAYMSGWND) DllStructSetData($stNID, 3, $nID) $nResult = Shell_NotifyIcon($NIM_DELETE, DllStructGetPtr($stNID)) DestroyIcon($TRAYNOTIFYIDS[$i][1]) $TRAYNOTIFYIDS[$i][8] = FALSE $TRAYNOTIFYIDS[$i][7] = FALSE $TRAYNOTIFYIDS[$i][6] = 0 $TRAYNOTIFYIDS[$i][5] = "" $TRAYNOTIFYIDS[$i][4] = "" $TRAYNOTIFYIDS[$i][3] = 0 If $TRAYNOTIFYIDS[$i][2] <> 0 Then GUIDelete($TRAYNOTIFYIDS[$i][2]) $TRAYNOTIFYIDS[$i][2] = 0 $TRAYNOTIFYIDS[$i][1] = 0 $TRAYNOTIFYIDS[$i][0] = 0 ExitLoop EndIf Next Return $nResult EndFunc expandcollapse popupFunc _TrayIconSetState($nID = -1, $nState = 1) If $nState = 0 Then Return 1 ; No change If $nID = -1 Then $nID = $TRAYLASTID If $TRAYMSGWND = 0 Or $nID <= 0 Then Return 0 Local $i, $nResult = 0, $bFound = FALSE For $i = 1 To $TRAYNOTIFYIDS[0][0] If $nID = $TRAYNOTIFYIDS[$i][0] Then $bFound = TRUE ExitLoop EndIf Next If Not $bFound Then Return 0 Local $stNID = DllStructCreate($sNOTIFYICONDATAW) If BitAnd($nState, 1) Then DllStructSetData($stNID, 1, DllStructGetSize($stNID)) DllStructSetData($stNID, 2, $TRAYMSGWND) DllStructSetData($stNID, 3, $nID) DllStructSetData($stNID, 4, BitOr($NIF_ICON, $NIF_MESSAGE)) DllStructSetData($stNID, 5, $TRAYTIPMSG) DllStructSetData($stNID, 6, $TRAYNOTIFYIDS[$nID][1]) $nResult = Shell_NotifyIcon($NIM_ADD, DllStructGetPtr($stNID)) If $nResult Then _TrayIconSetToolTip($nID, $TRAYNOTIFYIDS[$nID][4]) ElseIf BitAnd($nState, 2) Then DllStructSetData($stNID, 1, DllStructGetSize($stNID)) DllStructSetData($stNID, 2, $TRAYMSGWND) DllStructSetData($stNID, 3, $nID) $nResult = Shell_NotifyIcon($NIM_DELETE, DllStructGetPtr($stNID)) EndIf If BitAnd($nState, 4) Then If Not $TRAYNOTIFYIDS[$nID][7] Then If $hBlankIcon = 0 Then _CreateBlankIcon() If $hBlankIcon <> 0 Then ;SetTimer($TRAYMSGWND, $FLASHTIMERID, $FLASHTIMEOUT, 0) ;nickston SetTimer($TRAYMSGWND, $nID, $FLASHTIMEOUT, 0) $TRAYNOTIFYIDS[$nID][7] = TRUE EndIf EndIf ElseIf BitAnd($nState, 8) Then ;KillTimer($TRAYMSGWND, $FLASHTIMERID) KillTimer($TRAYMSGWND, $nID) DllStructSetData($stNID, 1, DllStructGetSize($stNID)) DllStructSetData($stNID, 2, $TRAYMSGWND) DllStructSetData($stNID, 3, $nID) DllStructSetData($stNID, 4, $NIF_ICON) DllStructSetData($stNID, 6, $TRAYNOTIFYIDS[$nID][1]) $nResult = Shell_NotifyIcon($NIM_MODIFY, DllStructGetPtr($stNID)) $TRAYNOTIFYIDS[$nID][7] = FALSE $TRAYNOTIFYIDS[$nID][8] = FALSE EndIf Return $nResult EndFunc expandcollapse popupFunc _TrayIconSetIcon($nID = -1, $sIconFile = @AutoItExe, $nIconID = 0) If $nID = -1 Then $nID = $TRAYLASTID If $TRAYMSGWND = 0 Or $nID <= 0 Then Return 0 $nIconID = _GetIconID($nIconID, $sIconFile) Local $hIcon = 0 If $sIconFile = "" Then If $nIconID = 0 Then $sIconFile = @AutoItExe Else $hIcon = LoadIcon(0, $nIconID) EndIf EndIf If $sIconFile <> "" Then Local $stIcon = DllStructCreate("hwnd") If ExtractIconExW($sIconFile, $nIconID, 0, DllStructGetPtr($stIcon), 1) > 0 Then $hIcon = DllStructGetData($stIcon, 1) Else $hIcon = LoadIcon(0, 32516) EndIf EndIf Local $stNID = DllStructCreate($sNOTIFYICONDATAW) DllStructSetData($stNID, 1, DllStructGetSize($stNID)) DllStructSetData($stNID, 2, $TRAYMSGWND) DllStructSetData($stNID, 3, $nID) DllStructSetData($stNID, 6, $hIcon) ;nickston If $TRAYNOTIFYIDS[$nID][1]=-1 Then DllStructSetData($stNID, 4, BitOr($NIF_ICON, $NIF_MESSAGE)) DllStructSetData($stNID, 5, $TRAYTIPMSG) $nResult = Shell_NotifyIcon($NIM_ADD, DllStructGetPtr($stNID)) ;Local $nResult = Shell_NotifyIcon($NIM_MODIFY, DllStructGetPtr($stNID)) Else DllStructSetData($stNID, 4, $NIF_ICON) DestroyIcon($TRAYNOTIFYIDS[$nID][1]) Local $nResult = Shell_NotifyIcon($NIM_MODIFY, DllStructGetPtr($stNID)) EndIf If $nResult Then $TRAYNOTIFYIDS[$nID][1] = $hIcon Else DestroyIcon($hIcon) $TRAYNOTIFYIDS[$nID][1] = 0 EndIf Return $nResult EndFunc Link to comment Share on other sites More sharing options...
nickston Posted January 4, 2015 Share Posted January 4, 2015 (edited) For all mouse buttions clicks: expandcollapse popupFunc _TrayNotifyIcon($hWnd, $Msg, $wParam, $lParam) #forceref $Msg ;Local $nClick = 0 Local $nID = $wParam If $TRAYNOTIFYIDS[$nID][5] <> "" And _ ($TRAYNOTIFYIDS[$nID][6] = 0 Or _ $TRAYNOTIFYIDS[$nID][6] = $lParam) Then Call($TRAYNOTIFYIDS[$nID][5], $nID, $lParam) EndIf ;nickston+ 04.01.15 #cs Switch $lParam Case $WM_LBUTTONDOWN $nClick = 1 case $WM_LBUTTONUP $nClick = 2 case $WM_LBUTTONDBLCLK $nClick = 4 case $WM_RBUTTONDOWN $nClick = 8 case $WM_RBUTTONUP $nClick = 16 case $WM_RBUTTONDBLCLK $nClick = 32 case $WM_MOUSEMOVE $nClick = 64 EndSwitch If BitAnd($nClick, $TRAYNOTIFYIDS[$nID][3]) And $TRAYNOTIFYIDS[$nID][2] > 0 Then #ce $nClick=GetMouseCode($lParam) If BitAnd($nclick, $TRAYNOTIFYIDS[$nID][3]) And $TRAYNOTIFYIDS[$nID][2] > 0 Then Local $hMenu = GUICtrlGetHandle($TRAYNOTIFYIDS[$nID][2]) If $hMenu <> 0 Then Local $stPoint = DllStructCreate("int;int") GetCursorPos(DllStructGetPtr($stPoint)) SetForegroundWindow($hWnd) TrackPopupMenuEx($hMenu, 0, DllStructGetData($stPoint, 1), DllStructGetData($stPoint, 2), $hWnd, 0) PostMessage($hWnd, 0, 0, 0) EndIf EndIf EndFunc expandcollapse popupFunc _TrayIconCreate($sToolTip = "", $sIconFile = @AutoItExe, $nIconID = 0, $sCallback = "", $nMsg = 0, $hIcon = 0) If $sToolTip = "" Then $sToolTip = $sDefaultTT ;nickston+ #cs $nIconID = _GetIconID($nIconID, $sIconFile) If $sIconFile = "" Then If $hIcon = 0 Then If $nIconID = 0 Then $sIconFile = @AutoItExe Else $hIcon = LoadIcon(0, $nIconID) EndIf EndIf EndIf If $sIconFile <> "" Then Local $stIcon = DllStructCreate("hwnd") If ExtractIconExW($sIconFile, $nIconID, 0, DllStructGetPtr($stIcon), 1) > 0 Then $hIcon = DllStructGetData($stIcon, 1) Else $hIcon = LoadIcon(0, 32516) EndIf EndIf If $TRAYMSGWND = 0 Then $TRAYMSGWND = GUICreate("", 1, 1, 9999, 9999, -1, 0x00000080) GUISetState() ShowWindow($TRAYMSGWND, @SW_HIDE) EndIf Local $nNID = _GetNewTrayIndex() If $nNID = 0 Then DestroyIcon($hIcon) Return 0 EndIf #ce ;nickston- ; #cs If $TRAYMSGWND = 0 Then $TRAYMSGWND = GUICreate("", 1, 1, 9999, 9999, -1, 0x00000080) GUISetState() ShowWindow($TRAYMSGWND, @SW_HIDE) EndIf Local $nNID = _GetNewTrayIndex() If $nNID = 0 Then ;DestroyIcon($hIcon) Return 0 EndIf $hIcon=-1 ;#ce $TRAYNOTIFYIDS[$nNID][0] = $nNID $TRAYNOTIFYIDS[$nNID][1] = $hIcon $TRAYNOTIFYIDS[$nNID][2] = 0 ;nickston+ 04.01.15 ;$TRAYNOTIFYIDS[$nNID][3] = 9 $TRAYNOTIFYIDS[$nNID][3] = 10 ;nickston- $TRAYNOTIFYIDS[$nNID][4] = $sToolTip $TRAYNOTIFYIDS[$nNID][5] = $sCallback $TRAYNOTIFYIDS[$nNID][6] = $nMsg $TRAYNOTIFYIDS[$nNID][7] = FALSE $TRAYNOTIFYIDS[$nNID][8] = FALSE _TrayIconSetIcon($nNID,$sIconFile,$nIconID) $TRAYLASTID = $nNID Return $nNID EndFunc expandcollapse popupFunc GetMouseCode($WM_Code) Switch $WM_Code Case $WM_MOUSEFIRST $nClick = 1 Case $WM_MOUSEMOVE $nClick = 1 Case $WM_LBUTTONDOWN $nClick = 2 case $WM_LBUTTONUP $nClick = 4 case $WM_LBUTTONDBLCLK $nClick = 8 case $WM_RBUTTONDOWN $nClick = 16 case $WM_RBUTTONUP $nClick = 32 case $WM_RBUTTONDBLCLK $nClick = 64 case $WM_MBUTTONDOWN $nClick = 128 case $WM_MBUTTONUP $nClick = 256 case $WM_MBUTTONDBLCLK $nClick = 512 case $WM_MOUSEWHEEL $nClick = 1024 case $WM_XBUTTONDOWN $nClick = 2048 case $WM_XBUTTONUP $nClick = 4096 case $WM_XBUTTONDBLCLK $nClick = 8192 case $WM_MOUSEHWHEEL $nClick = 16384 EndSwitch Return $nClick EndFunc Edited January 5, 2015 by nickston Link to comment Share on other sites More sharing options...
LarsJ Posted January 5, 2015 Share Posted January 5, 2015 UEZ, I don't understand at all why you want to close this tread. I could see your pointif the original code was faulty and outdatedif an update was completely depending on Holgerif I were adding a lot of new code to the UDF, and in that way creating a completely new UDFif this thread had been inactive for several years, and I suddenly added an update to an UDF which isn't used anymoreA little simplified this UDF makes functions in Microsoft DLL files available to AutoIt and calls these functions in response to WM_DRAWITEM and WM_MEASUREITEM messages with the purpose of adding colors and icons to menu items. The code prepares and executes the DllCalls.The functions in the DLL files are highly depending on structures. A lot of the code is used to create structures and fill the structures with data.Another big part of the code is used to manipulate a bunch of arrays to keep track of the menu items.Neither DllStruct-commands nor commands to read/write data in arrays have changed much since 2008. This means that the original code by Holger is not faulty and is not outdated. The code runs perfectly under the current versions of AutoIt (3.3.10/12).Since the UDF (simplified) only prepares and executes DllCalls, the date of the UDF really doesn't matter as long as the code is working. What matters according to dates, are the dates of the DLL files. On a Win 7/8 PC the DLLs are much younger than the UDF.Most of the code in the UDF is about calling functions in Microsoft DLLs with DllCall. To use DllCall you must implement the specifications as you find in the Microsoft documentation. This is what Holger has done. To be able to update the UDF all you have to do is to read the documentation. This is not depending on Holger.Because so much of the code is about implementing Microsoft specifications, a completely new UDF would more or less look like the old UDF. The specifications has not changed much since 2008. The new and old code would be the same. What's the purpose then in creating a new UDF. It seems more reasonable to update the original UDF by Holger.What I have done is nothing compared to the work by Holger. I have cleaned up the constants. Probably 5% of the code. Because constants in include files are reorganized from time to time, it's not surprising that an UDF from 2008 needs some updates to be able to run under the current AutoIt versions.Then I have added a single line of code here and there. Code lines that I have copied directly from the posts in this thread. You can find a list in post 289. Some of the code lines added by Holger himself e.g. the x64 update in post 266 in january 2010.I have not added a single line of my own code to the UDF. This is still the original code by Holger with a few modifications by ProgAndy. Because the code is still the original code, this thread is the proper place to add the update.This thread seems still to be valuable for a lot of AutoIt users. The thread is still active. There has been added new posts more or less regularly.I simply just don't understand the purpose of closing the thread. Don't do that. And I'll certainly not just steal the code created by Holger, and add it to a new thread as if it was my own code. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions 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