|
kafen
初级用户
 
积分 97
发帖 43
注册 2005-7-25
状态 离线
|
『楼 主』:
如何调用 Windows 图形界面应用程序及模拟按键(已解决)
使用 LLM 解释/回答一下
有个 Windows 图形界面应用程序打开后可以填入一个任意数字,然后点击确定即可,我想写个批处理来调用打开它并能填入指定的数字再自动完成确定,请问如何写这个批处理?多谢啦!
Last edited by kafen on 2006-12-19 at 09:54 PM ]
There is a Windows graphical interface application. After opening it, you can enter an arbitrary number and then click the confirm. I want to write a batch processing to call and open it, and can enter the appointed number and then automatically complete the confirm. How to write this batch processing? Thanks a lot!
Last edited by kafen on 2006-12-19 at 09:54 PM ]
|
|
2006-12-17 00:25 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
If it's a command-line tool, you can refer to the sample code in the following two threads~:)
How to use pipeline commands to input multiple results into the next program
http://www.cn-dos.net/forum/viewthread.php?tid=25707&fpage=2
How to use debug to compile a command for a carriage return?
http://www.cn-dos.net/forum/viewthread.php?tid=25691&fpage=2
If it's calling a Windows graphical interface application and sending numbers and simulating key presses, refer to:
How to simulate key presses with batch in CMD (the sample code on floor 7 of the following link)
http://www.cn-dos.net/forum/viewthread.php?tid=19049&fpage=1&highlight=sendkey
Who can help write a VBS to do an impossible thing (see floor 5 of the post to send information through the clipboard)
http://www.cn-dos.net/forum/viewthread.php?tid=22649&fpage=1&highlight=sendkey
Last edited by redtek on 2006-12-16 at 11:37 AM ]
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-12-17 00:31 |
|
|
jmz573515
银牌会员
    
积分 1212
发帖 464
注册 2006-12-13
状态 离线
|
 『第 3 楼』:
使用 LLM 解释/回答一下
set ws=wscript.createobject("wscript.shell")
ws.run "calc.exe" '这是你要运行的程序,写上完整路径。
wscript.sleep 2000
ws.sendkeys "12321" '这里是你要填入的数字。
ws.sendkeys "~"
set ws = wscript.createobject("wscript.shell")
ws.run "calc.exe" 'This is the program you want to run, write the full path.
wscript.sleep 2000
ws.sendkeys "12321" 'Here are the numbers you want to enter.
ws.sendkeys "~"
|
|
2006-12-17 00:55 |
|
|
kafen
初级用户
 
积分 97
发帖 43
注册 2005-7-25
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
Originally posted by redtek at 2006-12-17 00:31:
如果是命令行工具,兄可以参考如下两个贴子中的示例代码~:)
如何用管道的命令把多个结果输入到后一个程序里
http://www.cn-dos.net/ ...
@echo off
echo set WshShell = CreateObject("WScript.Shell") >>sendkey.vbs
echo WshShell.AppActivate %1 >>sendkey.vbs
echo WshShell.SendKeys "%2" >>sendkey.vbs
:other
if "%3" == "" start sendkey.vbs & exit
echo WshShell.SendKeys "%3" >>sendkey.vbs
shift
goto other
参数一:要发送按键的程序的标题,注意用引号括起来。
参数2-9:要发送的按键。可以发送一些功能键,如ALT,ESC,CTRL等等。。。
因是新手,故对于下面的解释有点看不懂,能否具体以实例解说一下,多谢了!
Originally posted by redtek at 2006-12-17 00:31:
If it's a command-line tool, you can refer to the sample code in the following two threads ~:)
How to use pipe commands to input multiple results into the next program
http://www.cn-dos.net/ ...
@echo off
echo set WshShell = CreateObject("WScript.Shell") >>sendkey.vbs
echo WshShell.AppActivate %1 >>sendkey.vbs
echo WshShell.SendKeys "%2" >>sendkey.vbs
:other
if "%3" == "" start sendkey.vbs & exit
echo WshShell.SendKeys "%3" >>sendkey.vbs
shift
goto other
Parameter 1: The title of the program to send keys to, note to enclose it in quotes.
Parameters 2-9: The keys to send. Can send some function keys, such as ALT, ESC, CTRL, etc...
As a novice, so I don't understand the following explanation very well, can you explain it specifically with an example, thank you!
|
|
2006-12-17 01:09 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
3楼jmz573515兄给出的示例代码非常详细易懂~:)
下面就把jmz573515兄给出的代码解释一下:
set ws=wscript.createobject("wscript.shell")
ws.run "calc.exe" '这是你要运行的程序,写上完整路径。
' 上面这句是运行一个要接收你发送键值的应用程序。上面是启动windows计算器。
wscript.sleep 2000
' 上面是延时(就是等待)2秒钟。那个2000是指毫秒-1秒等于1000毫秒。
ws.sendkeys "12321" '这里是你要填入的数字。
' 上面 ws.SendKey 是发送模拟按键的指令,发送12321这串数字到计算器中。
' 同样也可以发送模拟的按键,如回车等……
ws.sendkeys "~"
兄可以将3楼代码存成一个名为 计算器.VBS 的文件,然后鼠标双击执行。
另:兄5楼所提及代码先不要试验,那是用批处理将VBS代码写成VBS脚本。
所以里面又包含了批处理文件操作技巧,反而又增加了学习难度。
建议只试验3楼代码,先从Windows计算器开始,然后再试着记事本,再试着其它更复杂应用程序的控制。
下面是VBS所能发送的健值代码举例:
(下面键值列表的部分内容取自互联网某网站,原作者不详)
对于SendKeys这个命令可以send什么,我们可以看下面的列表:
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER}or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INSERT} or {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC}
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}
SHIFT +
CTRL ^
ALT %
Brother jmz573515's sample code on the 3rd floor is very detailed and easy to understand~:)
Now let's explain the code given by Brother jmz573515:
set ws=wscript.createobject("wscript.shell")
ws.run "calc.exe" 'This is the program you want to run, write the full path.
' The above sentence is to run an application that will receive the key values you send. The above is to start the Windows calculator.
wscript.sleep 2000
' The above is to delay (that is, wait) for 2 seconds. That 2000 refers to milliseconds - 1 second is equal to 1000 milliseconds.
ws.sendkeys "12321" 'Here is the number you want to fill in.
' The above ws.SendKey is the instruction to send simulated key presses, sending the string 12321 to the calculator.
' Similarly, you can also send simulated keys, such as Enter, etc......
ws.sendkeys "~"
Brother, you can save the code on the 3rd floor as a file named "Calculator.VBS" and then double-click to execute it with the mouse.
Another thing: Brother, don't test the code you mentioned on the 5th floor for now. That is to write VBS code into a VBS script using batch processing.
So it also includes batch file operation skills, which actually increases the learning difficulty.
It is recommended to only test the code on the 3rd floor. Start with the Windows calculator, then try Notepad, and then try to control more complex applications.
The following are examples of key values that VBS can send:
(Part of the following key value list is taken from a certain website on the Internet, the original author is unknown)
For the SendKeys command, what can be sent, we can see the following list:
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER}or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INSERT} or {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC}
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}
SHIFT +
CTRL ^
ALT %
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-12-17 01:24 |
|
|
kafen
初级用户
 
积分 97
发帖 43
注册 2005-7-25
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
多谢楼上两位,试用计算器和记事本成功,接下来再多试试别的,多谢了,我得好好学学啦!
Thanks to the two upstairs, the calculator and notepad have been successfully tested. Next, I'll try more things. Thanks! I really need to learn well!
|
|
2006-12-17 01:36 |
|
|
kafen
初级用户
 
积分 97
发帖 43
注册 2005-7-25
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
可能是涉及到这个应用程序要指定输入框定位问题,还是无法实现,请帮我看看吧。
Last edited by kafen on 2006-12-17 at 02:43 AM ]
It may be related to the input box positioning problem of this application, or it cannot be implemented. Please help take a look.
Last edited by kafen on 2006-12-17 at 02:43 AM ]
|
|
2006-12-17 02:06 |
|
|
wydos
中级用户
  
积分 304
发帖 117
注册 2006-4-4
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
可以用tab键定位指定输入框,按下tab键,看按几下定位到你要的输入框
下面代码是 按tab键按6次
wshshell.sendkeys("{TAB 6}")
You can use the Tab key to locate the specified input box. Press the Tab key and see how many times you need to press it to locate the input box you want. The following code is pressing the Tab key 6 times:
wshshell.sendkeys("{TAB 6}")
|
|
2006-12-17 02:23 |
|
|
kafen
初级用户
 
积分 97
发帖 43
注册 2005-7-25
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
Originally posted by wydos at 2006-12-17 02:23:
可以用tab键定位指定输入框,按下tab键,看按几下定位到你要的输入框
下面代码是 按tab键按6次
wshshell.sendkeys("{TAB 6}")
真的好感谢大家,这里高手真多呀!
因为我上面是用ws.sendkeys,所以这里只能用ws.sendkeys("{TAB 6}"),否则会出现错误提示:找不到wshshell对象。谢谢你的指导!
因为大家的耐心指导,我已解决了问题,感谢jmz573515兄和wydos兄,特别是redtek兄的悉心指导!
set ws=wscript.createobject("wscript.shell")
ws.run "tcpPatch.exe" '这是你要运行的程序,写上完整路径。
wscript.sleep 2000 '这里设置延时时间为2秒钟。
ws.sendkeys("{TAB 1}") '按一下TAB键定位鼠标位置,以此类推!
ws.sendkeys "300" '这里是你要填入的数字。
ws.sendkeys("{TAB 2}") '再按两下TAB键定位应用按钮。
ws.sendkeys "~" '按回车确定应用。
ws.sendkeys("{ESC}") '按ESC退出该程序。
Last edited by kafen on 2006-12-17 at 02:51 AM ]
Originally posted by wydos at 2006-12-17 02:23:
You can use the Tab key to locate the specified input box. Press the Tab key and see how many times you need to press it to locate the input box you want.
The following code is pressing the Tab key 6 times
wshshell.sendkeys("{TAB 6}")
Really thank you all, there are so many experts here!
Because I used ws.sendkeys above, so here I can only use ws.sendkeys("{TAB 6}"), otherwise an error message will appear: The object wshshell was not found. Thank you for your guidance!
Because of everyone's patient guidance, I have solved the problem. Thank you brother jmz573515 and brother wydos, especially the careful guidance of brother redtek!
set ws=wscript.createobject("wscript.shell")
ws.run "tcpPatch.exe" 'This is the program you want to run, write the full path.
wscript.sleep 2000 'Set the delay time here to 2 seconds.
ws.sendkeys("{TAB 1}") 'Press the TAB key once to locate the mouse position, and so on!
ws.sendkeys "300" 'Here is the number you want to enter.
ws.sendkeys("{TAB 2}") 'Press the TAB key twice again to locate the apply button.
ws.sendkeys "~" 'Press Enter to confirm apply.
ws.sendkeys("{ESC}") 'Press ESC to exit the program.
Last edited by kafen on 2006-12-17 at 02:51 AM ]
|
|
2006-12-17 02:32 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
set ws=wscript.createobject("wscript.shell")
上面的 set ws= 大概含义是:将创建的 "wscript.shell” 对象的 引用 赋给变量 ws
所以,你下面就可以引用这个对象来操作一些东东了:)
ws.run "calc.exe"
如果你将变量设置为 set redtek= …………
那么下面就当然是使用 redtek.run …… 什么了:)
(注: 上面我解释的不完全正确,没学过VBS,大概是这个意思,更详细兄再多查些更准确的解释与资料)
set ws=wscript.createobject("wscript.shell")
The above set ws= roughly means: Assign the reference of the created "wscript.shell" object to the variable ws
So you can refer to this object below to operate some things :)
ws.run "calc.exe"
If you set the variable as set redtek= …………
Then of course it's using redtek.run …… and so on :)
(Note: The explanation above is not completely correct. If you haven't learned VBS, it's roughly this meaning. For more detailed and accurate explanations and materials, you can check more.)
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-12-17 02:46 |
|
|
kafen
初级用户
 
积分 97
发帖 43
注册 2005-7-25
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
我晕,为什么以上的方法在做Flash Player 9.0 for IE批处理安装时无法实现?
Flash Player 9.0 for IE下载地址为: http://nj.onlinedown.net/soft/14968.htm
大家帮我看看好吗?谢谢了!
这是这样写的:
set ws=wscript.createobject("wscript.shell")
ws.run "flashIE.exe"
wscript.sleep 1000
ws.sendkeys "~"
存为.vbs文件后运行,安装完无法关闭界面!
Last edited by kafen on 2006-12-19 at 09:54 AM ]
Oh, why can't the above method be implemented when installing Flash Player 9.0 for IE in batch?
The download address of Flash Player 9.0 for IE is: http://nj.onlinedown.net/soft/14968.htm
Can everyone help take a look? Thanks!
This is written like this:
set ws=wscript.createobject("wscript.shell")
ws.run "flashIE.exe"
wscript.sleep 1000
ws.sendkeys "~"
After saving as a.vbs file and running, the interface cannot be closed after installation!
Last edited by kafen on 2006-12-19 at 09:54 AM ]
|
|
2006-12-19 09:51 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
1. 下载我提取的文件
2. 把它复制到 system32\ 文件夹
3. 运行 regsvr32 Flash9b.ocx
代码
copy /y Flash9b.ocx "%windir%\system32\"
regsvr32 Flash9b.ocx
1. Download the file I extracted
2. Copy it to the system32\ folder
3. Run regsvr32 Flash9b.ocx
Code
copy /y Flash9b.ocx "%windir%\system32\"
regsvr32 Flash9b.ocx
|
|
2006-12-19 11:07 |
|
|
kafen
初级用户
 
积分 97
发帖 43
注册 2005-7-25
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
Originally posted by electronixtar at 2006-12-19 11:07:
1. 下载我提取的文件
2. 把它复制到 system32\ 文件夹
3. 运行 regsvr32 Flash9b.ocx
...
谢谢回复,但是我试了,提示错误。我看到别人有个VBS转成的EXE,只是不知他加了什么代码可以安装完退出。我写的那个代码应当跟他差不多,就只是哪里差了一点。
哦,忘记了说一下,我不是在DOS下运行这些的。
Last edited by kafen on 2006-12-19 at 11:24 AM ]
Originally posted by electronixtar at 2006-12-19 11:07:
1. Download the file I extracted
2. Copy it to the system32\ folder
3. Run regsvr32 Flash9b.ocx
...
Thanks for the reply, but I tried it and got an error. I saw someone had a VBS converted to EXE, but I just don't know what code he added to be able to exit after installation. The code I wrote should be almost the same as his, just that there's a little something missing somewhere.
Oh, I forgot to mention that I'm not running these under DOS.
Last edited by kafen on 2006-12-19 at 11:24 AM ]
|
|
2006-12-19 11:21 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
不知道kafen兄试验时所提示的是什么错误?(这个有可能对解决这问题很关键)
如果安装程序都装完了但它自己不会退出(或是无法正常被.sendkey发送的退出等按键所控置),
如果是这样,干脆把那个安装程序用 TaskList 查出来,再用 TaskKill 杀掉~:)
I don't know what error Brother kafen mentioned during the test? (This might be crucial for solving this problem)
If the installation program is completely installed but it doesn't exit by itself (or can't be controlled by exit keys like.sendkey normally),
If that's the case, just find out the installation program using TaskList and then kill it with TaskKill ~:)
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-12-19 11:42 |
|
|
lisiyuan
初级用户
 
积分 21
发帖 28
注册 2006-12-15
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
yun晕 看不懂 以后要努力学习了
Yun is dizzy. Don't understand. Need to study hard in the future.
|
|
2006-12-19 11:59 |
|