How can I programmed batch file at windows xp that it will perform combination of keys? for example: win+L to switch user or other combinations.
+4
A:
I'm not sure how easy it is to do this with sending key sequences but just about any action can be done by calling the appropriate executable.
For example,
rundll32.exe user32.dll, LockWorkStation
will do what WinL normally does.
This site shows quite a number of possibilities.
paxdiablo
2010-02-21 10:52:39
+1. Creating a mechanism that simulates keystrokes would be a huge effort - much easier to call the associated commands.
Pekka
2010-02-21 11:03:42
+2
A:
Have you considered that a batch file may not be the best approach? The Windows Scripting Host has a "SendKeys" function which can be called from VBScript.
- http://msdn.microsoft.com/en-us/library/8c6yea83%28VS.85%29.aspx
- http://www.devguru.com/Technologies/wsh/quickref/wshshell_SendKeys.html
IIRC, WSH can be called from other scripting languages too.
Steve314
2010-02-21 11:03:21
+1 And if the OP wants, he/she can have a batch file that triggers JScript or VBScript via `cscript.exe`: `cscript.exe /nologo scriptname "keys to send"`, for instance, if the script accepts the keys to send as a string (accessible from `WScript.Arguments`).
T.J. Crowder
2010-02-21 11:13:08