Jump to content
Macro Express Forums

Hold Down Any Key For X Seconds?


TsunamiZ

Recommended Posts

It is not possible to hold the key down for a specified amount of time, but you could have Macro Express press the key repeatedly for a specified amount of time. I was able to do it with the code below.

Variable Set Integer %N1% from Current Second
If Variable %N1% >= 30
 Variable Modify Integer: %N2% = %N1% - 30
End If
If Variable %N1% < 30
 Variable Modify Integer: %N2% = %N1% + 30
End If
Repeat Until %N2% = %N1%
 Variable Set Integer %N1% from Current Second
 Text Type: %N1% (%N2%)
 Delay 5 Milliseconds
Repeat End

I had to add a 5 millisecond delay to prevent the keyboard buffer from overflowing. Depending on your system, you may or may not need this delay. When holding down a key, Windows actually presses the key repeatedly as well.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...