AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Extract Informations about TaskButtons
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Tim77
Guest





PostPosted: Tue Nov 27, 2007 3:46 pm    Post subject: script doesn't work on windows startup Reply with quote

Hi,

Sorry to bring up this old topic. It is a very nifty script (icontray.ahk), but I'm experiencing some trouble with it. I modified it to my needs to load a program and then hide the icon from the taskbar. But I have to use sleep so the process exists before it can be hidden. This works when the computer has already started but not after startup.

Code:

Run, csrsmsg.exe, A_WorkingDir, UseErrorLevel
Sleep, 2250

TrayIcons("csrsmsg.exe")


Code:

If !sExeName || (sExeName = sProcess) || (sExeName = pid)
      {
         If sExeName = DUMeter.exe { HideTrayIcon(idn, !(GetTrayIconState(idn) & 0x8))}
         DllCall("ReadProcessMemory", "Uint", hProc, "Uint", iString, "Uint", &wTooltip, "Uint", 128 * 2, "Uint", 0)
         DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wTooltip, "int", -1, "str", sTooltip, "int", 128, "Uint", 0, "Uint", 0)
         sTrayIcons .= "idx: " . A_Index - 1 . " | idn: " . idn . " | Pid: " . pid . " | uID: " . uID . " | MessageID: " . nMsg . " | hWnd: " . hWnd . " | Class: " . sClass . " | Process: " . sProcess . "`n" . "   | Tooltip: " . sTooltip . "`n"
         HideTrayIcon(idn) =>> added this
      }


Might there be a solution for this ? To check if the process exists so I wouldn't have to use the sleep command(which isn't foolproof, and the longer the sleep the greater the chance of the user noticing the icon). Or will does never work while starting up ? Help greatly appreciated.

Thanks,

Tim
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1141

PostPosted: Wed Nov 28, 2007 12:05 am    Post subject: Re: script doesn't work on windows startup Reply with quote

Tim77 wrote:
Might there be a solution for this ? To check if the process exists

May use this:
Code:
Process, Wait, csrsmsg.exe
Back to top
View user's profile Send private message
Tim77
Guest





PostPosted: Wed Nov 28, 2007 1:57 pm    Post subject: Reply with quote

Thanks for the reply, but it doesn't work.

Code:
Run, csrs.exe, A_WorkingDir, UseErrorLevel

=> This should return 0 as ErrorLevel

Wait: Waits up to Param3 seconds (can contain a decimal point) for a matching process to exist. If Param3 is omitted, the command will wait indefinitely. If a matching process is discovered, ErrorLevel is set to its Process ID (PID). If the command times out, ErrorLevel is set to 0.

Exist: Sets ErrorLevel to the Process ID (PID) if a matching process exists, or 0 otherwise. If the PID-or-Name parameter is blank, the script's own PID is retrieved. An alternate, single-line method to retrieve the script's PID is PID := DllCall("GetCurrentProcessId")

Code:
Process, Exist, csrs.exe

=> So this should give me the pid of the process if it exists. Directly afterwards I should be able to use the HideTrayIcon function but it doesn't work. Confused .Anymore suggestions ?

Thanks,

Tim
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1141

PostPosted: Wed Nov 28, 2007 2:44 pm    Post subject: Reply with quote

Tim77 wrote:
Code:
Run, csrs.exe, A_WorkingDir, UseErrorLevel

=> This should return 0 as ErrorLevel

I noticed you used UseErrorLevel with Run, and I don't think Process Wait essentially delays the retrieval any further than it. So if the former doesn't work then the latter may not work either. Anyway, the simplest solution may be just Loop TrayIcons("csrsmsg.exe") itself after tweaking it so as to return true when it really found one.
Back to top
View user's profile Send private message
sashabe



Joined: 09 Oct 2006
Posts: 13

PostPosted: Sun May 11, 2008 5:45 pm    Post subject: Reply with quote

Thanks to the author! Shocked Laughing
Back to top
View user's profile Send private message
infogulch



Joined: 27 Mar 2008
Posts: 64
Location: KC, MO

PostPosted: Mon May 12, 2008 4:04 am    Post subject: Reply with quote

Might this be suitable for the Lib?
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group