Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Holding down key for "blank" amount of time


  • Please log in to reply
5 replies to this topic
torchmega
  • Members
  • 4 posts
  • Last active: Jul 15 2011 12:27 AM
  • Joined: 15 Jul 2011
Im currently writing a script, and by no means am I asking for a hand out. Ive spent the last hour searching over tuts and forums for any info but have came up empty handed.

What im trying to figure out is how to have AHK hold down a button for a certain amount of time.. For Example..


Hold space bar 10milli
sleep 10000
hold space bar 15milli
ect...

I know the syntax for everything just have no idea how to tell AHK to hold my spacebar for a certain amount of time. Any help or a point in the right direction would be great. Thanks

codybear
  • Members
  • 600 posts
  • Last active: Feb 09 2015 12:41 PM
  • Joined: 15 Sep 2009
<!-- m -->http://www.autohotke... ... highlight=<!-- m -->

Send {Space Down}
sleep 10000 ;Sleeps ten seconds and then sends spacebar up
Send {Space Up}

You may have to play with the different sends at the above link depending on what you're trying to send space to (ie if it's a game).
Disclaimer: I'm not an expert by any means; I just try to help out where I can.

torchmega
  • Members
  • 4 posts
  • Last active: Jul 15 2011 12:27 AM
  • Joined: 15 Jul 2011
Ok this is a few things I have tried all of which failed. I Noticed its not even playing my send commands. Any help ?
Loop
{
 ^space::Pause
 Send, {{SPACE} Down}
 Sleep 2000
 Send, {{SPACE} Up}
 sleep 1500
}

Loop
{
 ^space::Pause
 Send, {SPACE Down}
 Sleep 2000
 Send, {SPACE Up}
 sleep 1500
}

This should do as follows... If I hit Ctrl+Spacebar it should pause the script

Otherwise be holding down spacebar for 2 seconds then waiting 1.5 seconds and keep looping

torchmega
  • Members
  • 4 posts
  • Last active: Jul 15 2011 12:27 AM
  • Joined: 15 Jul 2011

http://www.autohotkey.com/forum/viewtopic.php?t=516&highlight=

Send {Space Down}
sleep 10000 ;Sleeps ten seconds and then sends spacebar up
Send {Space Up}

You may have to play with the different sends at the above link depending on what you're trying to send space to (ie if it's a game).


Im trying to send it to game. However, I don't see why that would matter. I just want it to send the keystroke spacebar as if i actually hit spacebar.

I hate not understanding things, lol thanks for the help

torchmega
  • Members
  • 4 posts
  • Last active: Jul 15 2011 12:27 AM
  • Joined: 15 Jul 2011
Ok for I got it to work, Only thing is It Wont do the loop if i have the

^Space::pause

In OR outside the loop. NOTE: even though the loop wont run with this line in the script the line itself still functions and pauses and resumes the script as intended

any ideas or work arounds?

codybear
  • Members
  • 600 posts
  • Last active: Feb 09 2015 12:41 PM
  • Joined: 15 Sep 2009
Loop
{
 Send, {SPACE Down}
 Sleep 2000
 Send, {SPACE Up}
 sleep 1500
}
return

^space::Pause

The code you had was just running the ^space hotkey and was sending the pause command.
Also, it's {space down} and {space up}. If you send {{space} up} it was sending a space and the word up.



Also, for why it matters with a game, read this <!-- m -->http://www.autohotke... ... =FAQ#Games<!-- m -->
specifically the troubleshooting if it still doesn't work as I tested it out in my text editor and it worked.
Disclaimer: I'm not an expert by any means; I just try to help out where I can.