I have been attempting to create a macro which presses the W key, and then holds it down for 10 seconds, however, when I use Record the program fails to measure any keyboard strokes. Rather it only finds mouse movement.
I also tried writing my own program, and it still does not execute the keyboard commands, only the mouse.
My keyboard is a logitech!
Thanks!
Keyboard Accessible?
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Do you want the W key to be HELD down, or SENT for 10 seconds. There is a difference. Using the standard Send command, the key is sent which means the key is pressed and released in one go. So if you want to HOLD the key down for 10 seconds you have to use more advanced code. Here are both methods.
To send it for 10 seconds:
To HOLD it down use the code described at:
http://www.mjtnet.com/forum/viewtopic.php?t=1991
As follows:
To send it for 10 seconds:
Code: Select all
VBSTART
VBEND
//focus notepad - put a few lines in notepad and set cursor to first line
SetFocus>Notepad*
//Press Down Arrow for 10 seconds
VBEval>Timer,stTime
Let>StopTime=stTime+10
Label>send_loop
Send>w
VBEval>Timer,elapsed
If>elapsed<StopTime,send_loop
http://www.mjtnet.com/forum/viewtopic.php?t=1991
As follows:
Code: Select all
VBSTART
VBEND
//Key codes at http://www.mjtnet.com/vkcodes.htm
Let>VK_W=87
Let>ExtendedKey=1
Let>KeyUp=2
//focus notepad - put a few lines in notepad and set cursor to first line
SetFocus>Notepad*
//Press W for 10 seconds
VBEval>Timer,stTime
Let>StopTime=stTime+10
Label>press_loop
LibFunc>user32.dll,keybd_event,r,VK_W,0,0,0
VBEval>Timer,elapsed
If>elapsed<StopTime,press_loop
//Now release W
Let>FLAGS={%ExtendedKey% OR %KeyUp%}
LibFunc>user32.dll,keybd_event,r,VK_DOWN,0,%KeyUp%,0
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?