tags:

views:

61

answers:

2

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
+1. Creating a mechanism that simulates keystrokes would be a huge effort - much easier to call the associated commands.
Pekka
+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.

IIRC, WSH can be called from other scripting languages too.

Steve314
+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