JAFN Posted March 13, 2011 Share Posted March 13, 2011 Hi, let me say up front that while I had a lot of programing experience decades ago I might as well be a complete newbie. If possible I will need to be led by the hand. I have searched long and hard through the help system and searched for 'Icon' in the faq and here. In a nutshell, I have a short script that runs in two possible states. I would like to switch between two custom icons in the tray depending on what state the code is in. I tried several variations of 'TraySetIcon()' but so far with no luck. Can you point me in the right direction? [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
SYRAU3 Posted March 13, 2011 Share Posted March 13, 2011 (edited) #NoTrayIcon Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. $exititem = TrayCreateItem("Exit") TraySetState() $start = 0 While 1 $msg = TrayGetMsg() If $msg = $exititem Then ExitLoop $diff = TimerDiff($start) If $diff > 1000 Then $num = -Random(0,100,1) ; negative to use ordinal numbering ToolTip("#icon=" & $num) TraySetIcon("Shell32.dll",$num) $start = TimerInit() EndIF WEnd Exit It is Working fine!!!! or: include the attatched file into your script and for Example: #include <ModernMenuRaw.au3> $f_tray = _TrayIconCreate('tinyMSN', @ScriptDir & '\dll\availible.ico', 'MyTrayTipCallBack') $c_cm = _TrayCreateContextMenu($f_tray) _TrayIconSetState($f_tray, @SW_SHOW)ModernMenuRaw.au3 Edited March 13, 2011 by SYRAU3 Link to comment Share on other sites More sharing options...
JAFN Posted March 13, 2011 Author Share Posted March 13, 2011 The first is from the help system that seems to work fine with icons from system dlls but appears to not handle custom icons. Lets say I have two tray icons: StateOn.ico and StateOff.ico. How would I go about loading one or the other as a tray icon? Thanks [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2011 Moderators Share Posted March 13, 2011 JAFN,TraySetIcon works both with icons from inside DLLs and standalone icons - I use it all the time. What syntax are you using to display your "custom" icons? All you need is the full path and filename. 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...
JAFN Posted March 13, 2011 Author Share Posted March 13, 2011 JAFN,TraySetIcon works both with icons from inside DLLs and standalone icons - I use it all the time. What syntax are you using to display your "custom" icons? All you need is the full path and filename. M23if $var=0 then TraySetIcon("DropBeepUncom.ico") soundPlay($sound) sleep($alarmPing) else TraySetIcon("DropBeepCom.ico") sleep($waitPing) endif TraySetState()icons are in the same directory as the exe.Are tray icons any different than regular icons?I used icoFX to create them and they work fine individually if compiled to the script. [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2011 Moderators Share Posted March 13, 2011 JAFN,Try adding the full path as I suggested: TraySetIcon(@ScriptDir & "\DropBeepUncom.ico")You could also store the icons inside your exe using #AutoIt3Wrapper_Res_Icon_Add - then you can use them like this:TraySetIcon(@ScriptFullPath, $iIcon_Index)The SciTE help file will tell you more - look under <Extra Utilties - AutoIt3Wrapper - Directives Available>. You do need the full SciTE4Autoit3 installation - if you have not got it you can download it here. Well worth the effort - lots of goodies to help you code in Autoit. 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...
JAFN Posted March 13, 2011 Author Share Posted March 13, 2011 full path did not work. I had previously tried using: FileInstall(".\DropBeepCon.ico","..\DropBeepCon.ico",1) FileInstall(".\DropBeepUncon.ico","..\DropBeepUncon.ico",1) without success I will try to figure your other suggestions and get back to you on the amount of success. Thank you so much for your time. [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2011 Moderators Share Posted March 13, 2011 JAFN, Post your icons here (or send them in a PM if you prefer) and I will see if I can get them to work on my machine. 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...
JAFN Posted March 13, 2011 Author Share Posted March 13, 2011 Oh man have I justified my handle. Such a stupid mistake that I blame on my bad eyes. I spelled the icon file names wrong. So sorry to have wasted your time though I did learn a lot. [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2011 Moderators Share Posted March 13, 2011 JAFN, Join the club! Glad you got it working. 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...
Xander Posted March 24, 2011 Share Posted March 24, 2011 Can anyone give me a clue as to why this isn't working?#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=d:\temp\temp.exe #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Icon_Add=D:\Media\Icons\Cleanup.ico #AutoIt3Wrapper_Res_Icon_Add=D:\Media\Icons\PureRa.ico #AutoIt3Wrapper_Res_Icon_Add=D:\Media\Icons\JavaRa.ico #AutoIt3Wrapper_Res_Icon_Add=D:\Media\Icons\Defragmentation.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** While 1 TraySetIcon(@ScriptFullPath,1) Sleep(500) TraySetIcon(@ScriptFullPath,2) Sleep(500) TraySetIcon(@ScriptFullPath,3) Sleep(500) TraySetIcon(@ScriptFullPath,4) Sleep(500) TraySetIcon() Sleep(500) WEndI'm working on a cleanup script and want to be able to show which phase the script is in based on the active icon. When run, it just shows the default icon and nothing else. I've even used an icon extraction program to confirm that the icons are, indeed, embedded. I'm also assuming the default AutoIt icon is "0". This is just a sample code, obviously; I want to make sure I get the concept right before putting into my main script. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 24, 2011 Moderators Share Posted March 24, 2011 Xander,AutoIt uses the first 5 icons (0 to -4) so the first icon added by #AutoIt3Wrapper_Res_Icon_Add is indexed as -5, the second as -6, etc. So you need to use those indices. Try this:While 1 TraySetIcon(@ScriptFullPath, -5) Sleep(500) TraySetIcon(@ScriptFullPath, -6) Sleep(500) TraySetIcon(@ScriptFullPath, -7) Sleep(500) TraySetIcon(@ScriptFullPath, -8) Sleep(500) TraySetIcon() Sleep(500) WEndM23 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...
Xander Posted March 24, 2011 Share Posted March 24, 2011 Argh. I had a feeling it was something simple. I'm surprised, then, that the icon extraction program didn't pull out 4 more icons (1-4). If it had, that would probably have tipped me off.Plan B was to use the icons from the running Exes themselves but I wanted to get this info into my brain. Thanks. 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