CatchFish Posted February 11, 2006 Share Posted February 11, 2006 Here I've uploaded a new version for both WIN_2000 & WIN_XP (also compatible with AutoIt beta 3.1.1.107). SysTray_UDF.au3 And I modified tuape's Example #5 so that the unneccessary click will not be performed. expandcollapse popup#include "SysTray_UDF.au3" ;...... ; -- Example 5 -- ; Left-click Outlook's icon on system tray ; Press hide inactive icon's button part is from Valik's refresh system tray script! $oldMatchMode = Opt("WinTitleMatchMode", 4) $oldChildMode = Opt("WinSearchChildren", 1) $class = "classname=Shell_TrayWnd" $hControl = ControlGetHandle($class, "", "Button2") ; get tray position and move there. Helps if Auto Hide tray option is used. $posTray = WinGetPos(_FindTrayToolbarWindow()) MouseMove($posTray[0], $posTray[1]) $index = _SysTrayIconIndex("Outlook.exe"); Change this to some other application if needed If $index <> -1 Then $pos = _SysTrayIconPos($index) If $pos = -1 Then ; ***** Moved by CatchFish ***** ; If XP and the Hide Inactive Icons mode is active If $hControl <> "" And ControlCommand($class, "", $hControl, "IsVisible","") Then ControlClick($class, "", $hControl) Sleep(250); Small delay to allow the icons to be drawn EndIf ; ****************************** $pos = _SysTrayIconPos($index) If $pos = -1 Then Exit ; ** A real error this time;) End If MouseMove($pos[0], $pos[1]) Sleep(1000) MouseClick("left") EndIf ConsoleWrite(@CRLF & @CRLF & "Pos[0]: " & $pos[0] & "$pos[1]: " & $pos[1]) ; Restore Opt settings Opt("WinTitleMatchMode", $oldMatchMode) Opt("WinSearchChildren", $oldChildMode) Link to comment Share on other sites More sharing options...
CatchFish Posted February 11, 2006 Share Posted February 11, 2006 (edited) The only change is here (except for DllStructDelete()...): Func _FindTrayToolbarWindow() Local $hWnd = DLLCall("user32.dll","hwnd","FindWindow", "str", "Shell_TrayWnd", "int", 0) if @error Then return -1 $hWnd = DLLCall("user32.dll","hwnd","FindWindowEx", "hwnd", $hWnd[0], "int", 0, "str", "TrayNotifyWnd", "int", 0);FindWindowEx(hWnd,NULL,_T("TrayNotifyWnd"), NULL); if @error Then return -1 If @OSVersion <> "WIN_2000" Then $hWnd = DLLCall("user32.dll","hwnd","FindWindowEx", "hwnd", $hWnd[0], "int", 0, "str", "SysPager", "int", 0);FindWindowEx(hWnd,NULL,_T("TrayNotifyWnd"), NULL); if @error Then return -1 EndIf $hWnd = DLLCall("user32.dll","hwnd","FindWindowEx", "hwnd", $hWnd[0], "int", 0, "str", "ToolbarWindow32", "int", 0);FindWindowEx(hWnd,NULL,_T("TrayNotifyWnd"), NULL); if @error Then return -1 Return $hWnd[0] EndFunc Edited February 11, 2006 by CatchFish Link to comment Share on other sites More sharing options...
rbhkamal Posted May 17, 2006 Share Posted May 17, 2006 (edited) Hi This UDF is very use full, thanks. But is there anyway to add another function that gets the text of a tool tip "SystrayIconGetTip()" ? Or if someone can give me a hint on how to do that, please! Thanks RK Edited May 17, 2006 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
malinduta Posted May 26, 2006 Share Posted May 26, 2006 Hello, After I use _SysTrayIconRemove(_SysTrayIconIndex($st_process)) to hide a icon, there is a empty space in the left of the clock (I think there is place for another icon). But if I start another app that has a tray icon, the systray refreshes and there is no empty space. Is there a way to remove that empty space? Here is a pic to be more specific Thank you. Link to comment Share on other sites More sharing options...
slightly_abnormal Posted May 28, 2006 Share Posted May 28, 2006 (edited) This is a nice script but I'm having the same problem as malinduta.. Edited May 28, 2006 by slightly_abnormal Link to comment Share on other sites More sharing options...
JoshDB Posted May 28, 2006 Share Posted May 28, 2006 Nice script, really helpful. Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite Link to comment Share on other sites More sharing options...
tuape Posted May 29, 2006 Author Share Posted May 29, 2006 @gafrost / @catchfish: Thanks for the modifications! They should be now added to the latest version. @rbhkamal and others who need to get tooltip text: See the first post and example. A function to get tooltip text is added. Link to comment Share on other sites More sharing options...
tuape Posted May 30, 2006 Author Share Posted May 30, 2006 * bump * Can someone with Win2000 please try if getting tooltip texts work on that? Thanks. Link to comment Share on other sites More sharing options...
Neoborn Posted June 7, 2006 Share Posted June 7, 2006 (edited) I get an error when testing the example on page 1:\Systray_test.au3(66,50) : ERROR: _SysTrayIconTooltip(): undefined function. MsgBox(0, "Tooltip", _SysTrayIconTooltip($p) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ oÝ÷ Ù©Ýjëh×6 \Systray_test.au3 (59) : ==> Subscript used with non-Array variable.: ConsoleWrite(@CRLF & @CRLF & "Pos[0]: " & $pos[0] & "$pos[1]: " & $pos[1]) ConsoleWrite(@CRLF & @CRLF & "Pos[0]: " & $pos^ ERRORAlso can the first post in this thread contain the most updated version of both the udf and the test program?Thanks and awesome work ( when I get it to work )Neoborn Edited June 7, 2006 by Neoborn ~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT Link to comment Share on other sites More sharing options...
rbhkamal Posted June 27, 2006 Share Posted June 27, 2006 (edited) Why I get an error after running this script for long time?OS: XP Pro SP2AutoIt Beta: 127Edit:I just found out that this script destroys the tray icon for my application even that its still running!!!!!I think that's what made my script fail.Edit:I removed the attachment to save space#include "SysTray_UDF.au3" #include <GUIConstants.au3> #NoTrayIcon Opt( "GUIOnEventMode" , 1 ) WinSetOnTop( GUICreate( "CertClient Tooltip text" , 200 , 80 , 300 , 300 , BitOR($WS_EX_TOPMOST, $WS_OVERLAPPEDWINDOW) ,$WS_EX_TOOLWINDOW ) , '' , 1 ) GUISetOnEvent( -3 , "Quit" ) $Lable = GUICtrlCreateLabel( '' , 2 , 5 , 190 , 70 ) GUISetState() While 1 GUICtrlSetData($Lable , _SysTrayIconTooltip(_SysTrayIconIndex("BRNClientTrayApp.exe"))) Sleep( 400 ) WEnd Func Quit() Exit EndFunc Edited December 11, 2006 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
rbhkamal Posted June 29, 2006 Share Posted June 29, 2006 (edited) Why I get an error after running this script for long time?OS: XP Pro SP2AutoIt Beta: 127Edit:I just found out that this script destroys the tray icon for my application even that it’s still running!!!!!I think that's what made my script fail.Can someone please try to run my script for a long time?just use any application.thanksRKEdit:This is very annoying, I never know when my script is going to crash, it’s not reliable. Edited July 3, 2006 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
tuape Posted July 4, 2006 Author Share Posted July 4, 2006 I get an error when testing the example on page 1: Systray_test.au3(66,50) : ERROR: _SysTrayIconTooltip(): undefined function. MsgBox(0, "Tooltip", _SysTrayIconTooltip($p) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ oÝ÷ Ù©Ýjëh×6 Systray_test.au3 (59) : ==> Subscript used with non-Array variable.: ConsoleWrite(@CRLF & @CRLF & "Pos[0]: " & $pos[0] & "$pos[1]: " & $pos[1]) ConsoleWrite(@CRLF & @CRLF & "Pos[0]: " & $pos^ ERROR Also can the first post in this thread contain the most updated version of both the udf and the test program? Thanks and awesome work ( when I get it to work ) Neoborn What do you mean? _SysTrayIconTooltip() is included on the udf and AFAIK both udf and test are updated. Link to comment Share on other sites More sharing options...
tuape Posted July 4, 2006 Author Share Posted July 4, 2006 Why I get an error after running this script for long time? OS: XP Pro SP2 AutoIt Beta: 127 Edit:I just found out that this script destroys the tray icon for my application even that it's still running!!!!! I think that's what made my script fail. #include "SysTray_UDF.au3" #include <GUIConstants.au3> #NoTrayIcon Opt( "GUIOnEventMode" , 1 ) WinSetOnTop( GUICreate( "CertClient Tooltip text" , 200 , 80 , 300 , 300 , BitOR($WS_EX_TOPMOST, $WS_OVERLAPPEDWINDOW) ,$WS_EX_TOOLWINDOW ) , '' , 1 ) GUISetOnEvent( -3 , "Quit" ) $Lable = GUICtrlCreateLabel( '' , 2 , 5 , 190 , 70 ) GUISetState() While 1 GUICtrlSetData($Lable , _SysTrayIconTooltip(_SysTrayIconIndex("BRNClientTrayApp.exe"))) Sleep( 400 ) WEnd Func Quit() Exit EndFunc I would assume your application, BRNClientTrayApp.exe, is closed at some point and _SysTrayIconIndex returns -1. Then you try to read the tooltip text of icon which index is -1. Link to comment Share on other sites More sharing options...
rbhkamal Posted July 5, 2006 Share Posted July 5, 2006 (edited) I would assume your application, BRNClientTrayApp.exe, is closed at some point and _SysTrayIconIndex returns -1. Then you try to read the tooltip text of icon which index is -1.Maybe , but the process is still running for sure in the task manager, only the tray Icon disappears when you run the script for a long time.I will try this with other applications and see what happens.RKEdit: This problem happens on different apps using different PCsThe icon doesn't disappear (I was wrong) but I always get the same error when running the above script for a long time.The applications never terminate or lose their systray icon when I get that error.Please try it.Let me know if you have any questions. Edited July 10, 2006 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
rbhkamal Posted July 10, 2006 Share Posted July 10, 2006 (edited) * bump * Can someone with Win2000 please try if getting tooltip texts work on that? Thanks.I tired the same script on windows 2K Server Adv. I got a defferent error i(check the attachment) and Scite showed the following in the console: >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /beta /ErrorStdOut /in "C:\Users on the Share\RK\Win2K_Test.au3" /autoit3dir "C:\Program Files\AutoIt3\beta" /UserParams >Running AU3Check params: from:C:\Program Files\AutoIt3\SciTE\au3check\ !>AU3Check ended.rc:128 >Running:(3.1.1.128):C:\Program Files\AutoIt3\beta\autoit3.exe "C:\Users on the Share\RK\Win2K_Test.au3" +>AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 22.632 Any questions? Edited July 10, 2006 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
Foxnolds Posted July 12, 2006 Share Posted July 12, 2006 (edited) I could not wait for fixes so I fixed this version for my own use. I had only one Icon on startup that produced errors. The fix looks like:Local $iMax = _SysTrayIconCount() If $iMax < 2 Then $iMax = 2 ; To fix Badly formatted Array Error Local $aInfo[$iMax]I also added OpenDLL stubs and close because I poll the Icons and I need it to be FAST..;=============================================================================== ; As we don't have a #ifndef $hDLL_User32 ; Do this step on your AU3 Script load ;=============================================================================== Global $hDLL_User32, $hDLL_Kernel32 Func _SysTrayDLL_Init() $hDLL_User32 = DllOpen('user32.dll') $hDLL_Kernel32 = DllOpen('kernel32.dll') EndFunc;==>_SysTrayDLL_Init ;=============================================================================== ; Do this step in your AU3 Script Exit ;=============================================================================== Func _SysTrayDLL_Close() DllClose($hDLL_User32) DllClose($hDLL_Kernel32) EndFunc;==>_SysTrayDLL_CloseThe GetIconPids was returning the wrong owners. Simpler code fixed that!Func _SysTrayIconPids() Local $i Local $iMax = _SysTrayIconCount() If $iMax < 2 Then $iMax = 2 ; To fix Badly formatted Array Error Local $aSysTrayIconPids[$iMax] Local $aRet Local $hWnd For $i=0 to $iMax-1 $aSysTrayIconPids[$i] = -1 $hWnd = _SysTrayIconHandle($i) If Not @error And $hWnd <> -1 Then $aSysTrayIconPids[$i] = WinGetProcess(HWnd($hWnd)) EndIf Next return $aSysTrayIconPids EndFuncI changed some of the variable names for readability and set scope of variables so they don't clash when combining multiple function results etc.I have not tried my mods on Win2K as I only run on XP and Vista.Edit: After applying follow post fixes, this is my working version. It is Opt("MustDeclareVars", 1) friendly.I will merge in enhancements from Post #1 then update this again - probably over the weekend.SysTray_UDF.au3 Edited July 15, 2006 by Foxnolds My UnAttended Event Handler , MsgBoxEx , DriveGetDriveEx and SysTray modified. Link to comment Share on other sites More sharing options...
rbhkamal Posted July 13, 2006 Share Posted July 13, 2006 there is a problem when this function fails. Func _SysTrayIconCount() Local $hWnd = _FindTrayToolbarWindow() Local $count = 0 $count = DLLCall($hDLL_User32,"int","SendMessage", "hwnd", $hWnd, "int", $TB_BUTTONCOUNT, "int", 0, "int", 0) return $count[0] EndFuncoÝ÷ Ú+l¥u·¥G+ºÚ"µÍ[ÈÔÞÕ^RXÛÛÛÝ[ BSØØ[ ÌÍÚÛHÑ[^UÛÛÚ[ÝÊ BSØØ[ ÌÍØÛÝ[ÌWHHÌBIÌÍØÛÝ[HØ[ ÌÍÚÕÙÌ ][ÝÚ[ ][ÝË ][ÝÔÙ[YÜØYÙI][ÝË ][ÝÚÛ ][ÝË ÌÍÚÛ ][ÝÚ[ ][ÝË ÌÍÕÐUÓÓÕS ][ÝÚ[ ][ÝË ][ÝÚ[ ][ÝË BRYÜ[] ÌÍØÛÝ[] ÌÍØÛÝ[ÌB[[oÝ÷ Ù.(!·§¶Ú-¯+aÆ®¶sb6æ6ÇVFRgV÷Cµ75G&õTDbæS2gV÷C°¢6æ6ÇVFRfÇC´uT6öç7FçG2æS2fwC°¢4æõG&6öà ¤÷BgV÷C´uTöäWfVçDÖöFRgV÷C²Â¥vå6WDöåF÷uT7&VFRgV÷C´6W'D6ÆVçBFööÇFFWBgV÷C²Â#ÂÂ3Â3Â&Dõ"b33cµu5ôUõDõÔõ5BÂb33cµu5ôõdU$ÄTEtäDõrÂb33cµu5ôUõDôôÅtäDõrÂb33²b33²Â¤uT6WDöäWfVçBÓ2ÂgV÷CµVBgV÷C²¢b33c´Æ&ÆRÒuT7G&Ä7&VFTÆ&VÂb33²b33²Â"ÂRÂÂs ¤uT6WE7FFR ¥vÆR¢uT7G&Å6WDFFb33c´Æ&ÆRÂõ75G&6öåFööÇFõ75G&6öäæFWgV÷C¶vöövÆWFƲæWRgV÷C²¢6ÆVWC¥tVæ@ ¤gVæ2VB¢W@¤VæDgVæ0 "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
Foxnolds Posted July 13, 2006 Share Posted July 13, 2006 Well spotted rbhkamal! there is a problem when this function fails. it should be like this: Func _SysTrayIconCount() Local $hWnd = _FindTrayToolbarWindow() Local $count[1] = [0] $count = DLLCall($hDLL_User32,"int","SendMessage", "hwnd", $hWnd, "int", $TB_BUTTONCOUNT, "int", 0, "int", 0) If @error Then Return $count return $count[0] EndFunc I use this Function to scan for open VPN connection status. I have not found any other way to quickly determine connection status other than by examining the SysTray ICON . My project I am writing to Learn this tool will be posted soon to this forum for interest sake. I have called it UnAttended.exe that launches from the Startup Folder and handles the MANY dialogs that popup as the PC boots then monitors events as applications crash arround me (mainly Eudora, MS ActiveSync). My UnAttended Event Handler , MsgBoxEx , DriveGetDriveEx and SysTray modified. Link to comment Share on other sites More sharing options...
Neoborn Posted July 14, 2006 Share Posted July 14, 2006 (edited) Any ideas??? \Close Remedy Windows\CloseWindows.au3" C:\Documents and Settings\cjeffery\Desktop\AutoITRelated\Projects\Close Remedy Windows\SysTrayClickApp_UDF.au3 (25) : ==> Subscript used with non-Array variable.: MouseMove($posTray[0], $posTray[1], 0) MouseMove($posTray^ ERROR This problem occurred after I updated to the latest Scite & Beta 130 Edited July 18, 2006 by Neoborn ~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT Link to comment Share on other sites More sharing options...
heibel Posted October 2, 2006 Share Posted October 2, 2006 Hello, nice UDF! I have a request/question: Is it possible to have some _SysTraySETIconTooltip($wintitle)? I'm in need of this. Hope it can be done. Thanks in advance. Harry 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