apollo13 Posted July 15, 2012 Posted July 15, 2012 Hi, I have comprised how use "SysTray_UDF" to remove an icon into systray area. I didn't realized that I must add this string: _SysTrayIconRemove (_SysTrayIconIndex ($st_process)) where "$st_process" is the EXE program that creates sysTray icon. Now i have do the script and it runs but i have a small problem. The script run very well but i must insert a pause of 6 seconds after run program and before execute function to remove icon, because in first time that I run program (when i turn-on computer) it spends six seconds to load itself in memory. If i don't insert into script the pause of 6 seconds, icon are not removed because program is not still ready infact icon don't exist for 6 seconds then are showed. If I close program and run script again for 2nd, 3th etc.. time, the program starts immediately and icon immediately are showed in Tray Area (is not necessary wait) but though i must wait 6 seconds to remove systray icon, also if program is already started and ready. I have thinked to change command "Sleep" with these commands: WinWait ( "title" [, "text" [, timeout]] ) ..........or........ WinWaitActive ( "title" [, "text" [, timeout]] ) but program don't open window-task, it runs on background and for this reason command don't take effect. It creates icon systray and add second taskbar in the user position of screen Therefore I have thinked: While not processexists("ObjectDock.exe") sleep(100) wend But don't run because process immediately exist in memory, also if program is not ready for 6 seconds in the first run (therefore script never wait: process: always exist for AutoIT), ================ This is my script ============= #NoTrayIcon #include "SysTray_UDF.au3" $st_process = "ObjectDock.exe" Run("C:\Program Files\ObjectDock\"& $st_process) sleep(6000) _SysTrayIconRemove (_SysTrayIconIndex ($st_process)) =================================================== ------> QUESTION to Forum <------- There is some command that paused the script, until it is ready and its Tray Icon with ToolTip text "ObjectDock Plus" exists ? I want that: - if systray icon spend about 6 seconds to exist: script wait about 6 seconds - if systray icon spends 0 seconds to exist, script immediately run "_SysTrayIconRemove" function and remove icon immediately without wait. Please if you can help me I need some suggestions. Thanks
Crayfish Posted July 15, 2012 Posted July 15, 2012 (edited) Your system sometime load app slower than how autoit calculate sleep. Set your sleep time longer. sleep(20000);//get rid of that fugly icon. An alternative is set it in a continuing loop until it removed then exit. Opt("RunErrorsFatal", 0) While 1 If Not ProcessExists("ObjectDock.exe") Then Run("ObjectDock.exe") If Not @error Then _SysTrayIconRemove (_SysTrayIconIndex ($st_process)) Exit EndIf Sleep (10) WEnd Edited July 16, 2012 by Crayfish
apollo13 Posted July 16, 2012 Author Posted July 16, 2012 Set 20 seconds ?? Also if i don't use autoit script the program in first run take more time to load itself in memory. If i close it and run again the time is more slower than first time. I think that in second time windows load from cache and is more speedly. For this reason i want find a method using AutoIT in order to test when the icon exist in system tray area and only then i remove it using function. While ICON not exist (sleep 50) wend call function_remove_icon I hope that i have better explained my design
apollo13 Posted July 16, 2012 Author Posted July 16, 2012 (edited) There is some error in script. Running it are showed: While without wend Opt("RunErrorsFatal", 0) While 1 If Not ProcessExists("ObjectDock.exe") Then Run("ObjectDock.exe") ENDIF <----- ADDING THIS THERE IS NOT ERROR BUT NOTHING RUN If Not @error Then _SysTrayIconRemove (_SysTrayIconIndex ($st_process)) Exit EndIf Sleep (10) WEnd ------ If i change in this mode ----- Opt("RunErrorsFatal", 0) If Not ProcessExists("ObjectDock.exe") Then Run("ObjectDock.exe") ENDIF While 1 If Not @error Then _SysTrayIconRemove (_SysTrayIconIndex ($st_process)) ELSE EXITLOOP EndIf Sleep (10) WEnd EXIT In this case better run but script is always running in memory Never exit also if i have inserted at the end "Exit" Edited July 16, 2012 by apollo13
Crayfish Posted July 16, 2012 Posted July 16, 2012 Fixed! Opt("RunErrorsFatal", 0) While 1 If Not ProcessExists("ObjectDock.exe") Then Run("ObjectDock.exe") If Not @error Then _SysTrayIconRemove (_SysTrayIconIndex ($st_process)) Exit EndIf EndIf Sleep (10) WEnd
apollo13 Posted July 16, 2012 Author Posted July 16, 2012 (edited) Nothing to do, there is no errors now, ObjectDock start but icon are always present in tray area.If you or other people on forum want test some script solution using version free of ObjectDock in order to help me the site is:http://www.stardock.com/products/objectdock/Question: if in my script that run using sleep(6000), it mean that function found icon after 6 seconds.There is no way to do a loop only to test if icon exist using same SysTray_UDF and only then run function REMOVE ? Edited July 16, 2012 by apollo13
Crayfish Posted July 16, 2012 Posted July 16, 2012 (edited) _SysTrayIconRemove will not work unless you included your trayicon UDF. Did you included with the script? #include <SysTray_UDF.au3> Edited July 16, 2012 by Crayfish
apollo13 Posted July 16, 2012 Author Posted July 16, 2012 (edited) yes sure. If you note in first topic posted in my script is present. My script is: ================ This is my script ============= #NoTrayIcon #include "SysTray_UDF.au3" $st_process = "ObjectDock.exe" Run("C:Program FilesObjectDock"& $st_process) sleep(6000) _SysTrayIconRemove (_SysTrayIconIndex ($st_process)) =================================================== Edited July 16, 2012 by apollo13
apollo13 Posted July 16, 2012 Author Posted July 16, 2012 PROBLEM SOLVED: Found how test ToolTip and only then Remove systray icon #NoTrayIcon #include "SysTray_UDF.au3" $st_process = "ObjectDock.exe" If processexists($st_process) then exit ;Exit immediately if program is already running Run($st_process) while not _SysTrayIconTooltip(_SysTrayIconIndex($st_process))="ObjectDock Plus" sleep (10) wend _SysTrayIconRemove(_SysTrayIconIndex($st_process)) Thanks all forum for help
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