AutoHotkey Community

It is currently May 27th, 2012, 9:09 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: November 15th, 2011, 9:20 pm 
Offline

Joined: July 10th, 2007, 7:00 pm
Posts: 29
Hi,

I'm new to AutoHotKey, and with a lot of copy/pasting and retrying i finally got the script I should want, but something is wrong with the timeouts work, especially when the get looped/repeated.

The point of my script :
To execute keystroke combination (SPACE followed by cursorDOWN) for a specified multiply of times.
I have some program where i need to check a bunch of tickmarks (using SPACE) and then move down to the next one, and repeat the process.
The routine itself is triggered by pressing the F7 key.

To enhance it some more and not having to run the script over and over again to check another bunch of tickmarks, i added a timeout to the F7 hotkey, so that, after it executed x times SPACE + DOWN, if i press the hotkey F7 again within 5 seconds, the process repeats, otherwise the script must exit.

The problem :
It seems like, with even F7 hotkey press i do, the 5 seconds timeout doesn't get respected, but is actually added up with each run.
Moreover, once in a while during this abnormally long timeout, the process triggers as if i pressed F7, when i did NOT.

The script :

Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; Pop up the Question how many times to repeat the Space + DOWN event.

InputBox, SendCount, Space and Down Repeat, How many time do I loop the Space and Down event ?, , 640, 480
if ErrorLevel
    {
MsgBox, CANCEL was pressed.
    Goto Exit
    }

; Pop up the Question to first highlight the window & place where to start & ask to press F7 to start the process.

MsgBox, Now highlight the window and its item where we need to start the repeating`nand press F7 to start.`nThe repeating will happen %SendCount% times.`n`nTip: If you press F7 again in the next 5 seconds, the process will repeat itself`n,if not, the automation will exit.

KeyWait, F7, D
KeyWait, F7

;Set the delay (waiting time between keypresses) to 50 milliseconds.
SetKeyDelay, 50

DoTheLoop:
Loop %SendCount%
{
  Send {Space} ; Presses the SPACE key.
  Send {Down} ; Presses the DOWN arrow key.
}

; If F7 is pressed again in the next 5 seconds, the process will be repeated.

KeyWait, F7, D T5
KeyWait, F7

if ErrorLevel
    {  ; No more F7 press detected, exitting..
    Goto Exit
    }
else
    {
    Goto DoTheLoop
    }

Exit:
Exit


Attention ! Precautions to take to testrun this script safely.

- Make sure you have notepad running with a blank document open, and in the foreground BEFORE you press F7 !!!



Please, can anyone help me out what could be the problem, or if this could indeed be a bug in the wait the "KeyWait" timeout (or perhaps any timeout) is behaving ?

Thanks for any helpful response.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 15th, 2011, 9:44 pm 
Offline

Joined: July 10th, 2007, 7:00 pm
Posts: 29
Please disregard, it's solved.

Seems like there needed to be another errorlevel check after the KeyWait, F7, D T5 too.

[Moved from Bug Reports. ~jaco0646]


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Google [Bot], Yahoo [Bot] and 68 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:
cron
Powered by phpBB® Forum Software © phpBB Group