AutoHotkey Community

It is currently May 26th, 2012, 10:43 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: September 15th, 2009, 11:04 pm 
Offline

Joined: July 8th, 2009, 3:14 pm
Posts: 10
Thanks in advance to anyone who can help me out with this one; it goes beyond my skill level with AHK.

I suppose I'll start with exactly what it is I'm trying to do:

I want to press !w:: and have the script continuously hold down the W key --AND-- press the T key once every 7 seconds, forever, until I press !w:: again. And preferably with an active window requirement.

In concept, this seemed like something I could pull-off. So I tried to learn and incorporate loops and breaks, etc. Needless to say, what has resulted so far has been function-less garbage :lol:

Hopefully someone can help me out on this one. Thanks.

Long live AHK.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 15th, 2009, 11:13 pm 
Offline

Joined: December 24th, 2008, 3:25 am
Posts: 1401
Location: :noitacoL
There are hundreds of examples of this found using the term 'toggle', in the search and 'title only' option.

This is the example from the AHK help file, easily adaptable to your needs
Code:
#MaxThreadsPerHotkey 3
#z::  ; Win+Z hotkey (change this hotkey to suit your preferences).
#MaxThreadsPerHotkey 1
if KeepWinZRunning  ; This means an underlying thread is already running the loop below.
{
    KeepWinZRunning := false  ; Signal that thread's loop to stop.
    return  ; End this thread so that the one underneath will resume and see the change made by the line above.
}
; Otherwise:
KeepWinZRunning := true
Loop
{
    ; The next four lines are the action you want to repeat (update them to suit your preferences):
    ToolTip, Press Win-Z again to stop this from flashing.
    Sleep 1000
    ToolTip
    Sleep 1000
    ; But leave the rest below unchanged.
    if not KeepWinZRunning  ; The user signaled the loop to stop by pressing Win-Z again.
        break  ; Break out of this loop.
}
KeepWinZRunning := false  ; Reset in preparation for the next press of this hotkey.
return


quick, untested edit:
Code:

!w::  ; alt W

if KeepWinZRunning 
{
    KeepWinZRunning := false 
    return 
}

KeepWinZRunning := true

Loop
{
   
;send your sleep and 'T' commands here
Send, T
Sleep 7000 ; 1 second = 1000 Milisecond
}
KeepWinZRunning := false  return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 1:09 am 
Offline

Joined: July 8th, 2009, 3:14 pm
Posts: 10
That works great! It taps T every 7 seconds perfectly, forever.

Now it just needs to hold down the W key forever, or alternatively, press the R key once when the script activates, and once when it turns off.

And to that end, the example you've provided never turns off :lol:
I'd do it myself, but I'm not entirely certain how to integrate those two requirements into what you've provided.

Thanks in advance for your help.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], JSLover, Miguel, rbrtryn and 57 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