Buttons and Clicks

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
06vsanti
Newbie
Posts: 3
Joined: Sat Oct 07, 2006 5:26 pm

Buttons and Clicks

Post by 06vsanti » Sat Oct 07, 2006 5:29 pm

Hello everyone,
I am trying to make a script where the following hapens...
If I press the LEFT button, click on certain part of the screen.
I want to do that with the space left right down and up keys. Can anyone supply me an example on how to do it on Macro Scheduler or give me some ideas?

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Oct 07, 2006 6:15 pm

To clarify what you want to do ...

For five keys, you want them to do a LeftClick at a specific screen position, a different position for each of the keys.
The five keys to do the left click are
space bar (VK32)
left arrow (VK37)
up arrow (VK38)
right arrow (VK39)
down arrow (VK40)

Is that correct?
============================
And how will the positions for each of these be determined? Use specific screen coordinates, or a position relative to something else, or a field or a button, or a particular screen color, or a random spot, something else?
===========================
You will probably be using some loops consisting of something like this

WaitKeyDown>VKxxx
SetFocus>WindowName*
WaitReady>1
MouseMove>X,Y
LClick

For VKxxx, see http://www.mjtnet.com/vkcodes.htm for identification of VirtualKeys. Have been included above for the five in your request.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

06vsanti
Newbie
Posts: 3
Joined: Sat Oct 07, 2006 5:26 pm

Post by 06vsanti » Sat Oct 07, 2006 6:29 pm

Ok, I have the following code, but it doesn't work:

Code: Select all

WaitKeyDown>VK37
WaitReady>1
MouseMove>850,295
LClick

WaitKeyDown>VK38
WaitReady>1
MouseMove>800,295
LClick

WaitKeyDown>VK39
WaitReady>1
MouseMove>875,300
LClick

WaitKeyDown>VK40
WaitReady>1
MouseMove>825,295
LClick

WaitKeyDown>VK32
WaitReady>1
MouseMove>820,512
LClick
Do I have anything wrong? Also, I am running this on an IE page, so whenever I press the down key, will it only do the down key action, or will it also scroll down?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Oct 07, 2006 6:50 pm

I would use OnEvent and KEY_DOWN. Create an event handler for each key you want to detect and have the subroutine issue the commands required.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

06vsanti
Newbie
Posts: 3
Joined: Sat Oct 07, 2006 5:26 pm

Post by 06vsanti » Sat Oct 07, 2006 6:53 pm

Can someone help me with the actual scripting? I am completely new to scripting and need some help with this. I also need it to not stop...for example if I press left, to be able to then press up and then left again without having to run the program again, but I dont know how to do a loop that will last forever.

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sat Oct 07, 2006 8:32 pm

Here is a sample script that does more or less what you are asking for. This will loop until you press Shift + Esc. It uses OnEvent> so you must be using version 8.0 or newer.

Code: Select all

OnEvent>KEY_DOWN,VK37,0,srt1
OnEvent>KEY_DOWN,VK38,0,srt2
OnEvent>KEY_DOWN,VK39,0,srt3
OnEvent>KEY_DOWN,VK40,0,srt4
OnEvent>KEY_DOWN,VK32,0,srt5

/*
Following is the continuous loop.  it does nothing but wait one hundredth
of a second then start over.  When one of the five specified keys
is pressed,  OnEvent runs a subroutine.  When the subroutine is
 complete,  the script returns to the continuous loop.
*/

Label>start
Wait>0.01
Goto>start

SRT>srt1
MouseMove>850,295
LClick
END>srt1

SRT>srt2
MouseMove>800,295
LClick
END>srt2

SRT>srt3
MouseMove>875,300
LClick
END>srt3

SRT>srt4
MouseMove>825,295
LClick
END>srt4

SRT>srt5
MouseMove>820,512
LClick
END>srt5
Hope this is helpful,
Dick

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