Hi,
Want to access some key board Button through Batch script.
Example: Suppose open notepad through script,and Want to access
Ctrl+S : For saving the file
Ctrl+P : For Print that file
or some some simple key opertion.
like Write some already define content.
Thanks in Advance
Regards,
Niraj
Key Press through Batch File
Moderator: DosItHelp
Re: Key Press through Batch File
The program AutoIt is a good tool for pressing buttons in an application.
Re: Key Press through Batch File
You can use wscript sendkeys function.and AppActivate to send the keys to an application:
http://social.technet.microsoft.com/wik ... ethod.aspx
here's a sendkeys.bat:
Does not check command line arguments but this can be added easy.First argument is the image name of the .exe you want to send keys to and the second is are the keys:
http://social.technet.microsoft.com/wik ... ethod.aspx
here's a sendkeys.bat:
Code: Select all
@if (@X)==(@Y) @end /* Harmless hybrid line that begins a JScript comment
@echo off
cscript //E:JScript //nologo "%~f0" %*
exit /b 0
***jscript part****/
var WshShell = WScript.CreateObject("WScript.Shell");
var args=WScript.Arguments;
WshShell.AppActivate(args.Item(0));
//sleep(1500)
WshShell.SendKeys(args.Item(1));
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
/*http://social.technet.microsoft.com/wiki/contents/articles/5169.vbscript-sendkeys-method.aspx*/
Does not check command line arguments but this can be added easy.First argument is the image name of the .exe you want to send keys to and the second is are the keys:
Code: Select all
sendkeys.bat notepad {space}{tab}{enter}blabla