AutoHotkey Community

It is currently May 26th, 2012, 4:58 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: March 27th, 2008, 5:50 pm 
Offline

Joined: August 24th, 2005, 5:29 pm
Posts: 549
Location: Berlin / Germany
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:


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 27th, 2008, 5:51 pm 
Offline

Joined: February 18th, 2008, 8:26 pm
Posts: 442
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 27th, 2008, 5:58 pm 
Offline

Joined: August 24th, 2005, 5:29 pm
Posts: 549
Location: Berlin / Germany
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:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 27th, 2008, 6:17 pm 
Offline

Joined: February 18th, 2008, 8:26 pm
Posts: 442
It works for me at 0% load (tested with notepad.exe). Have you tried using Process, Priority, , L and SetBatchLines in your script?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 6th, 2010, 12:37 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 6th, 2010, 12:40 pm 
Offline

Joined: June 14th, 2009, 7:48 pm
Posts: 331
oups, posted unlogged as our often here friend "Guest"
:oops: :lol:


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, Exabot [Bot], Google [Bot] and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group