使用批处理文件preSS键盘键 [英] Press Keyboard keys using a batch file

查看:321
本文介绍了使用批处理文件preSS键盘键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个批处理文件,它可以自动preSS左箭头和与之间的一些停顿n次右箭头键。任何人都可以请帮我在这?

I am trying to develop a batch file which can automatically press left arrow and right arrow key for n number of times with some pause in between. Could anyone please help me in this?

P.S:我尝试安装自动键盘软件,但我不能安装它们,因为我在工作。我需要这个计划在我的办公室的PC工作。

P.S :I tried installing Auto keyboard softwares but i couldnt install them since i am at work. I need this program to work in my office PC.

推荐答案

哇!这意味着,你必须学会​​不同的编程语言只是两个键发送到键盘?还有更简单的方法为您实现同样的事情。 : - )

Wow! Mean this that you must learn a different programming language just to send two keys to the keyboard? There are simpler ways for you to achieve the same thing. :-)

下面的批处理文件是启动其他程序(在本例中的cmd.exe)的例子,发送一个命令,然后发送一个向上箭头键,该事业恢复最后执行的命令。批处理文件是很简单,可以没有问题明白了,所以你可以修改它来满足您的需求。

The Batch file below is an example that start another program (cmd.exe in this case), send a command to it and then send an Up Arrow key, that cause to recover the last executed command. The Batch file is simple enough to be understand with no problems, so you may modify it to fit your needs.

@if (@CodeSection == @Batch) @then


@echo off

rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"

rem Start the other program in the same Window
start "" /B cmd

%SendKeys% "echo off{ENTER}"

set /P "=Wait and send a command: " < NUL
ping -n 5 -w 1 127.0.0.1 > NUL
%SendKeys% "echo Hello, world!{ENTER}"

set /P "=Wait and send an Up Arrow key: [" < NUL
ping -n 5 -w 1 127.0.0.1 > NUL
%SendKeys% "{UP}"

set /P "=] Wait and send an Enter key:" < NUL
ping -n 5 -w 1 127.0.0.1 > NUL
%SendKeys% "{ENTER}"

%SendKeys% "exit{ENTER}"

goto :EOF


@end


// JScript section

var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));

有关的SendKeys键名称的列表,请参阅:
<一href=\"http://msdn.microsoft.com/en-us/library/8c6yea83(v=vs.84).aspx\">http://msdn.microsoft.com/en-us/library/8c6yea83(v=vs.84).aspx

例如:

LEFT ARROW    {LEFT}
RIGHT ARROW   {RIGHT}

有关该溶液的进一步说明,请参见:<一href=\"http://stackoverflow.com/questions/16823068/gnuwin32-openssl-s-client-conn-to-websphere-mq-server-not-closing-at-eof-hangs/16868982#16868982\">GnuWin32 OpenSSL的康涅狄格州的s​​_client.First到WebSphere MQ服务器在EOF不关闭,挂起

For a further explanation of this solution, see: GnuWin32 openssl s_client conn to WebSphere MQ server not closing at EOF, hangs

这篇关于使用批处理文件preSS键盘键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆