making this script use less cpu?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Nagarules
Junior Coder
Posts: 24
Joined: Tue Nov 21, 2006 9:33 pm

making this script use less cpu?

Post by Nagarules » Thu Jun 28, 2007 9:33 pm

Label>Start

OnEvent>KEY_DOWN,VK50,0,Base
OnEvent>KEY_DOWN,VK49,0,Send

SRT>Base
GetCursorPos>xbase,ybase
END>Base

SRT>Send
GetCursorPos>xcurrent,ycurrent
MouseMove>xbase,ybase
Wait>0.01
RCLICK
MouseMove>xcurrent,ycurrent
END>Send

Goto>Start


The endless loop makes the cpu on my computer rise and I don't like that :VK50
GetcursorPos>xbase,ybase


Label>Start

waitkeydown>VK49
GetCursorPos>xcurrent,ycurrent
MouseMove>xbase,ybase
Wait>0.05
RCLICK
MouseMove>xcurrent,ycurrent


Goto>Start


This doesn't work as well as the other one, because for some reason i have to click on the KEY harder on this one (WaitKeyDown>VK49). On the one with the repetitive loop it does the script instantly.
--

How can i fix the script so it won't do as much loops and it will work just as well?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Jun 28, 2007 9:54 pm

Take the onevents out of the loop and add a wait. the onevents only need to be called once and the wait will cut your cpu use. finally I find it easier to visuallize if the subroutines are located outside the loop.

OnEvent>KEY_DOWN,VK50,0,Base
OnEvent>KEY_DOWN,VK49,0,Send

Label>Start

Wait>0.001
Goto>Start

SRT>Base
GetCursorPos>xbase,ybase
END>Base

SRT>Send
GetCursorPos>xcurrent,ycurrent
MouseMove>xbase,ybase
Wait>0.01
RCLICK
MouseMove>xcurrent,ycurrent
END>Send

Nagarules
Junior Coder
Posts: 24
Joined: Tue Nov 21, 2006 9:33 pm

^_^

Post by Nagarules » Fri Jun 29, 2007 10:59 am

Works great thanks :P.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts