How to make a macro reacts differently depending on the key

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Guillaume777
Newbie
Posts: 18
Joined: Sun Dec 22, 2002 2:41 am

How to make a macro reacts differently depending on the key

Post by Guillaume777 » Sun Dec 22, 2002 2:59 am

First, I must say that I'm really impressed by Macro Scheduler so far. However, I can't figure out how to do something, so I hope you will be able to help me.

I want my macro to reacts depending on the key pressed. The macro must looks like this : If "k" is pressed go somewhere, elseif "g" is pressed go somewhere else. I also want the user to be able to move the mouse around before pressing a key ( i.e I think the program must be waiting ). If it can't be done with keys then I hope it can be with mouse clicks ( ex : If "LeftMouse" is pressed go somewhere, elseif "RightMouse" is pressed go somewhere else. I suspect I will need some VBscript to accomplish that, but I'm not used to the Macro Scheduler integration of VBscript.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Sun Dec 22, 2002 3:47 am

Guillaume777,

Macro Scheduler is designed for substitution of repetitious manual keystrokes. It assumes:
1. You have a targe application such as Microsoft Office XP, AutoCAD and CorelDraw;
2. You know perfectly a pre-defined keystroke sequence and its approximate timing.

Please let us know whether it's exactly what you want.

Guilaume777

Post by Guilaume777 » Sun Dec 22, 2002 5:44 am

What I wanted is some kind of command/VBscrit like the KeyPress event of Visual Basic, but it doesn't matter now because I found a way around it. However I now have problem with the "WaitKeyDown" command : I can't find the corrects virtual key code since the http://msdn.microsoft.com/library/psdk/ ... s_529f.htm link is down.

Guillaume777
Newbie
Posts: 18
Joined: Sun Dec 22, 2002 2:41 am

Post by Guillaume777 » Sun Dec 22, 2002 6:06 am

By the way according to almost every website I visited so far the virtual key code of Numpad 5 is 65h, yet according to the Command Reference of Macro Scheduler the virtual key code of Numpad 5 is 101, so I am a bit confused.

Guillaume777
Newbie
Posts: 18
Joined: Sun Dec 22, 2002 2:41 am

Post by Guillaume777 » Sun Dec 22, 2002 6:13 am

this web site also says that the virtual key code of Numpad 5 is 101, so I guess thoses are the correct codes :

http://www.eonreality.com/support/manua ... KCodes.htm

Guillaume777
Newbie
Posts: 18
Joined: Sun Dec 22, 2002 2:41 am

Post by Guillaume777 » Sun Dec 22, 2002 6:51 am

ok now I only need to find the virtual key code of the mouse buttons and I'm set !

Guillaume777
Newbie
Posts: 18
Joined: Sun Dec 22, 2002 2:41 am

Post by Guillaume777 » Sun Dec 22, 2002 7:05 am

here another, better side with the key codes

http://www.delphicollection.com/public/ ... odes.shtml

Guillaume777
Newbie
Posts: 18
Joined: Sun Dec 22, 2002 2:41 am

Post by Guillaume777 » Sun Dec 22, 2002 7:05 am

site not side.... bah !

Guillaume777
Newbie
Posts: 18
Joined: Sun Dec 22, 2002 2:41 am

Post by Guillaume777 » Sun Dec 22, 2002 7:15 am

oh well... the virtual key codes of the mouse buttons do not work... I guess there is no WaitMouseDown or something....

Guillaume777
Newbie
Posts: 18
Joined: Sun Dec 22, 2002 2:41 am

Post by Guillaume777 » Sun Dec 22, 2002 7:59 am

hum.... I wonder if its possible to create a macro with VBscript that waits for a mouse click ...

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Sun Dec 22, 2002 11:30 am

Hi Guillaume777

Mr Gullaume was Swiss physicist. He won a 1920 Nobel Prize for his discovery of a steel-nickel alloy.
hum.... I wonder if its possible to create a macro with VBscript that waits for a mouse click ...
Assuming you have the onMouseClick object, you may contemplate the following the hypothetical code:

VBSTART
Function IsMouseClick()
if MouseClick Then
IsMouseClick = 1
else
IsMouseClick = 0
end if
End Function
VBEND

VBeval>IsMouseClick(),Logic
If>Logic=1,doClickMethod
Goto>End
Label>doClickMethod
........
Label>End


Bear in mind, the above code was never tested.
Please keep us posted about your wonderful experiences with Macro Scheduler scripting.

Guillaume777
Newbie
Posts: 18
Joined: Sun Dec 22, 2002 2:41 am

Post by Guillaume777 » Sun Dec 22, 2002 3:44 pm

I sense some kind of sarcasm..... But thanks anyway :wink: !

Guillaume777
Newbie
Posts: 18
Joined: Sun Dec 22, 2002 2:41 am

Post by Guillaume777 » Sun Dec 22, 2002 3:47 pm

Or maybe there is no sarcasm at all.... Nobody ever said I had "wonderful experiences" so I guess I'm not used to it :) .

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Sun Dec 22, 2002 10:09 pm

Guillaume777,

Please remove "wonderful" from my previous email if you won't concur it's a wonderful experience in trying out new programming technuiques.

Please keep us posted about your latest discovery of coding VBscript functions/commands/objects in Macro Scheduler script. Many thanks.

Wish you a Merry Christmas and a Happy New Year.

Guillaume777
Newbie
Posts: 18
Joined: Sun Dec 22, 2002 2:41 am

Post by Guillaume777 » Mon Dec 23, 2002 3:09 am

armsys :

Yes, I have wonderful experiences in trying out new programming techniques with Macro Scheduler. However, what I posted here is
more like a search for the Virtual Key Codes rather then some real programming. To me, searching for the Virtual Key Codes wasn't wonderful, especially because I failed to do what I wanted..... Still, I find Macro Scheduler very fun to use.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts