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.
-
1This does not belong on superuser - batch files are programming as well, unless you're a programming snob :-)paxdiablo– paxdiablo2010-02-21 10:53:39 +00:00Commented Feb 21, 2010 at 10:53
-
@paxdiablo I am the last person to banish something onto SU - in fact, I frequently fight with people to keep questions here :) I misunderstood the question, I thought he wants to customize his PC, which is obviously not the case.Pekka– Pekka2010-02-21 11:02:39 +00:00Commented Feb 21, 2010 at 11:02
Add a comment
|
2 Answers
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.
1 Comment
Pekka
+1. Creating a mechanism that simulates keystrokes would be a huge effort - much easier to call the associated commands.
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.
1 Comment
T.J. Crowder
+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).