Jump to content

Script Works Fine The First Time Than It Doesnt Work The Second Time


Recommended Posts

Hello everybody on this wonderful community

I will try to make a deatailed description of my problem hopefully someone can help me to find the solution

what i want to do is to create a script that run automatically when windows start than this script call an application and run after the app is run it shows a trayicon so my script will hide it from the trayicons bar

and here is what i did

step 01:

subscribe my app to the windows registry using this trick that i found here on the forum

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName, "REG_SZ", @ScriptFullPath)

step02:

this step consists of writing a script that run my application and hide its trayicon

i searched a lot for this trick and finally found the solution by using this udf library written by tuape a member of this great community

and here is the the thread

http://www.autoitscript.com/forum/index.php?showtopic=13704

here is my script wrote it according to the exampoles provided by tuape the systray_udf owner

#NoTrayIcon
#include "SysTray_UDF.au3"
$st_process = "myapp.exe" ;the process of my app
Run("C:\Program Files\myappdir\mayapp.exe", "")
WinWait("my app title","")
_SysTrayIconRemove (_SysTrayIconIndex ($st_process))

when i compile and run this script it goes very well as i want it to do it runs the app and hide its tray icon

until now there is no problem

the problem occure when i restart the computer if you remember i added my script to thje registry so it will be run automatically

when the computer restarts the application runs but the tray icon is not hided

what i dont understand is when i double click on the script it does his job completly but when the same script is autorunning by the system it does only half of the job it runs the app but it doesnt hide the trayicon

can someone please help me to resolve this problem

many thanks in advance

Link to comment
Share on other sites

To start debugging on this, I would recommend you put a small sleep (maybe 2-5 seconds) in between your Run and WinWait functions. I have had to do this recently as AutoIt was working too fast for me. It was seeing the window before I could see it, and before it had fully opened and initialized so the small sleep would allow it to fully initialize, maybe that is your issue.

I hope this helps,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Hi JSThePatriot

Thank you for your great response i found your solution very logical but when I implented it unfortunately i have'nt any success

I still looking for a solution please help me guys

I am trying to come up with another solution...I would recommend trying some longer wait times just in case as it does sometimes take a while for a system to start up. Maybe put a sleep before the run for like 10 seconds, and then after for another 5-10 seconds...I will continue to try to think of something else. Also putting some debugging message boxes in there to "halt" the script for your input could help see where the issue is.

Regards,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

I am trying to come up with another solution...I would recommend trying some longer wait times just in case as it does sometimes take a while for a system to start up. Maybe put a sleep before the run for like 10 seconds, and then after for another 5-10 seconds...I will continue to try to think of something else. Also putting some debugging message boxes in there to "halt" the script for your input could help see where the issue is.

Regards,

Jarvis

I did tried that also but the result is always the same even i made it for longer periods

anyway thank you and i am waiting for your brilliant solutions ;-)

Link to comment
Share on other sites

I once had a similar problem and solved it by using a loop.

It was something like this:

CODE
#NoTrayIcon

#include "SysTray_UDF.au3"

$st_process = "myapp.exe" ;the process of my app

Run("C:\Program Files\myappdir\mayapp.exe", "")

$appactive = 0

WHILE $appactive == 0

Sleep(100)

IF WinExists ("my app title","")==1 Then

$appactive = 1

ENDIF

WEnd

_SysTrayIconRemove (_SysTrayIconIndex ($st_process))

Feel free to test it...

Link to comment
Share on other sites

I once had a similar problem and solved it by using a loop.

It was something like this:

CODE
#NoTrayIcon

#include "SysTray_UDF.au3"

$st_process = "myapp.exe" ;the process of my app

Run("C:\Program Files\myappdir\mayapp.exe", "")

$appactive = 0

WHILE $appactive == 0

Sleep(100)

IF WinExists ("my app title","")==1 Then

$appactive = 1

ENDIF

WEnd

_SysTrayIconRemove (_SysTrayIconIndex ($st_process))

Feel free to test it...

Dear Famaes...So it does not show The icon on the toolbar beside the clock ??.

I think what the friend would be looking to keep the icon hidden permanently even in boot OS.

I read ... I update ... I learn ...
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...