 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Tim77 Guest
|
Posted: Tue Nov 27, 2007 3:46 pm Post subject: script doesn't work on windows startup |
|
|
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
|
Posted: Wed Nov 28, 2007 12:05 am Post subject: Re: script doesn't work on windows startup |
|
|
| 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 |
|
 |
Tim77 Guest
|
Posted: Wed Nov 28, 2007 1:57 pm Post subject: |
|
|
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. .Anymore suggestions ?
Thanks,
Tim |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1141
|
Posted: Wed Nov 28, 2007 2:44 pm Post subject: |
|
|
| 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 |
|
 |
sashabe
Joined: 09 Oct 2006 Posts: 13
|
Posted: Sun May 11, 2008 5:45 pm Post subject: |
|
|
Thanks to the author!  |
|
| Back to top |
|
 |
infogulch
Joined: 27 Mar 2008 Posts: 64 Location: KC, MO
|
Posted: Mon May 12, 2008 4:04 am Post subject: |
|
|
Might this be suitable for the Lib? _________________
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|