Capturing the keys that were used to run vbscript

I have an application with "macro" capabilities. When I map some keys on my keyboard to execute a macro, I can also run it instead of vbscript.

What I would like to try to do is, within my vbscript, find out which keys were used to run the script. Can this be done? Could there be a way in vbscript to figure out which keys were last touched on the keyboard, and then I could apply my logic.

The goal of this is to keep the code in a single .vb file instead of multiple separate .vb script files (one for each keyboard mapping, maybe 3-4). Obviously, we are simply maintaining 1 file instead of multiple files with essentially the same code in each one.

I'm leaning towards the idea that this is not possible, but I thought it would be a decent question for the masses of StackOverflow. Thanks everyone for the help!

0


a source to share


2 answers


What you are asking for is not possible.



Can you change your VBScript to accept parameters and then call it with a different parameter based on which the hotkey was selected?

+2


a source


I agree with aphoria, the only way to do something like this is possible is if your keyboard mapping software allows you to assign a script / command with parameters / arguments. For example, if you used

c:\Temp\something.vbs

      

then you would change that to



%WINDIR%\system32\wscript.exe c:\temp\something.vbs "Ctrl-Alt-R"

      

Then, in your vbscript code, you can collect the argument using the collection of wscript.Arguments objects to take actions based on which argument / parameter was passed. For more information see the following two links:

http://msdn.microsoft.com/en-us/library/z2b05k8s(VS.85).aspx http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0915.mspx

0


a source







All Articles