Hi there,
I wrote a script that defines some keys to be pressed in my main script.
I won't go into detail now but I have come across a problem which I'm sure will be quite easy for more experienced users to solve.
Example:
My main script requires the pressing of the "k" key to open a dialog. Some users already have the "k" key assigned to something else in the application so I give them the option to change the key. and then store their preferred key as a variable.
So:
Send>k
becomes (as an example)
Let>variable_set_by_user=k
Send>%variable_set_by_user%
Now to the problem:
Alot (in fact most) of the key modifiers used in the application are already single keys.
So I need a way to assign "Press" to variables.
I wrote the dialog with a drop down list, allowing them to choose ALT, CTRL, SHIFT etc.
but when sending the variable that contains for example "CTRL" it will not work...
Example
Let>variable_set_by_user=k
Let>key_set_by_user=CTRL
Press %key_set_by_user%
Send>%variable_set_by_user%
Release %key_set_by_user%
Is there a way to store keys such as Control, Shift, Alt etc. into variables?
Sorry if this post seemed long winded but I thought all info may be required.
Thank you.
Saving Keys to press as variables
Moderators: JRL, Dorian (MJT support)
- Phil Pendlebury
- Automation Wizard
- Posts: 543
- Joined: Tue Jan 16, 2007 9:00 am
- Contact:
Saving Keys to press as variables
Phil Pendlebury - Linktree
-
- Macro Veteran
- Posts: 260
- Joined: Fri Apr 15, 2005 8:32 am
I'm much less experienced than most, but I'm not sure if you saw this note from the help file under Press:
There have been reports that Press CTRL, Press SHIFT and Press ALT sometimes fail when running Macro Scheduler under a Citrix environment. This can be fixed by setting SK_LEGACY to 1 prior to issuing these keystroke commands. Some DOS applications also need SK_LEGACY set to 1.
- Phil Pendlebury
- Automation Wizard
- Posts: 543
- Joined: Tue Jan 16, 2007 9:00 am
- Contact:
Yes I did see that thanks but it's not relevant to me.
Just try this:
Let>modkey=ALT
Let>key=F
Press %modkey%
Send>%key%
etc. and see if it works for you.

I will give it another try though.
Just try this:
Let>modkey=ALT
Let>key=F
Press %modkey%
Send>%key%
etc. and see if it works for you.

I will give it another try though.
Phil Pendlebury - Linktree
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
As you have noted Press doesn't accept a variable. Press isn't a command in it's own right. Each Press ... command is a separate command.
Two options:
1. Create a subroutine for each Press ... command you want to use and branch to it based on the user's selection.
2. Do this:
WriteLn>%SCRIPT_DIR%\temp.scp,r,Press %modkey%
Macro>%SCRIPT_DIR%\temp.scp
DeleteFile>%SCRIPT_DIR%\temp.scp
Two options:
1. Create a subroutine for each Press ... command you want to use and branch to it based on the user's selection.
2. Do this:
WriteLn>%SCRIPT_DIR%\temp.scp,r,Press %modkey%
Macro>%SCRIPT_DIR%\temp.scp
DeleteFile>%SCRIPT_DIR%\temp.scp
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?
- Phil Pendlebury
- Automation Wizard
- Posts: 543
- Joined: Tue Jan 16, 2007 9:00 am
- Contact:
Thank you Marcus. I will looking at option 1 I think.
You saved me hours of trial and error there as I was thinking I had done something wrong.

You saved me hours of trial and error there as I was thinking I had done something wrong.

Phil Pendlebury - Linktree