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 

AHK 1.0.47.06 - Bug in Process, Waitclose ?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
nick



Joined: 24 Aug 2005
Posts: 549
Location: Berlin / Germany

PostPosted: Thu Mar 27, 2008 4:50 pm    Post subject: AHK 1.0.47.06 - Bug in Process, Waitclose ? Reply with quote

Hello,

this simple script
Code:
#NoEnv
Loop,
{
   Process, Wait, AutoHotkey.exe
   Process, WaitClose, AutoHotkey.exe
}
ExitApp
produces a CPU load about 30 % on my office system.

Has anyone any idea why? Maybe a bug?
_________________
nick Wink
Back to top
View user's profile Send private message
Oberon



Joined: 18 Feb 2008
Posts: 442

PostPosted: Thu Mar 27, 2008 4:51 pm    Post subject: Re: AHK 1.0.47.06 - Bug in Process, Waitclose ? Reply with quote

nick wrote:
Has anyone any idea why? Maybe a bug?
You haven't put any sleeps in your loop so it runs at extremely high frequency. This is not a bug, just bad practice.
Back to top
View user's profile Send private message
nick



Joined: 24 Aug 2005
Posts: 549
Location: Berlin / Germany

PostPosted: Thu Mar 27, 2008 4:58 pm    Post subject: Reply with quote

Oberon wrote:
You haven't put any sleeps in your loop so it runs at extremely high frequency. This is not a bug, just bad practice.


AHK Helpfile wrote:
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.

For Wait and WaitClose: Processes are checked every 100 milliseconds; the moment the condition is satisfied, the command stops waiting. In other words, rather than waiting for the timeout to expire, it immediately sets ErrorLevel as described above, then continues execution of the script. Also, while the command is in a waiting state, new threads can be launched via hotkey, custom menu item, or timer.

_________________
nick Wink
Back to top
View user's profile Send private message
Oberon



Joined: 18 Feb 2008
Posts: 442

PostPosted: Thu Mar 27, 2008 5:17 pm    Post subject: Reply with quote

It works for me at 0% load (tested with notepad.exe). Have you tried using Process, Priority, , L and SetBatchLines in your script?
Back to top
View user's profile Send private message
Guest






PostPosted: Sat Feb 06, 2010 11:37 am    Post subject: Reply with quote

Hi,
I'm encountering an issue about this kind of commands and at the same time I saw this post and thought that this code may need correction :
Instead of this :
Code:
Loop,
{
   Process, Wait, AutoHotkey.exe
   Process, WaitClose, AutoHotkey.exe
}
ExitApp

this is enough :
Code:

   Process, Wait, AutoHotkey.exe
   Process, WaitClose, AutoHotkey.exe

No need to Loop then no CPU load.

Because the process command will wait by itself and proceed to the next line when the first contition (AutoHotkey.exe process existing) will be met.
The the second instruction will go to next line (wathever it is) , when the condition (AutoHotkey.exe process closing) will be met too.

Correct me if it's wrong
Back to top
awannaknow



Joined: 14 Jun 2009
Posts: 324

PostPosted: Sat Feb 06, 2010 11:40 am    Post subject: Reply with quote

oups, posted unlogged as our often here friend "Guest"
Embarassed Laughing
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
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