![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-03 06:47 |
48,038 topics / 350,123 posts / today 1 new / 48,251 members |
| DOS批处理 & 脚本技术(批处理室) » How to call Windows graphical interface applications and simulate key presses (solved) |
| Printable Version 2,737 / 19 |
| Floor1 kafen | Posted 2006-12-17 00:25 |
| 初级用户 Posts 43 Credits 97 | |
|
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 ] |
|
| Floor2 redtek | Posted 2006-12-17 00:31 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
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 ] |
|
| Floor3 jmz573515 | Posted 2006-12-17 00:55 |
| 银牌会员 Posts 464 Credits 1,212 | |
|
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 "~" |
|
| Floor4 kafen | Posted 2006-12-17 01:09 |
| 初级用户 Posts 43 Credits 97 | |
Originally posted by redtek at 2006-12-17 00:31: |
|
| Floor5 redtek | Posted 2006-12-17 01:24 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
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: 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)
|
|
| Floor6 kafen | Posted 2006-12-17 01:36 |
| 初级用户 Posts 43 Credits 97 | |
|
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!
|
|
| Floor7 kafen | Posted 2006-12-17 02:06 |
| 初级用户 Posts 43 Credits 97 | |
|
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 ] |
|
| Floor8 wydos | Posted 2006-12-17 02:23 |
| 中级用户 Posts 117 Credits 304 | |
|
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}") |
|
| Floor9 kafen | Posted 2006-12-17 02:32 |
| 初级用户 Posts 43 Credits 97 | |
Originally posted by wydos at 2006-12-17 02:23: 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 ] |
|
| Floor10 redtek | Posted 2006-12-17 02:46 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
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.) |
|
| Floor11 kafen | Posted 2006-12-19 09:51 |
| 初级用户 Posts 43 Credits 97 | |
|
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 ] |
|
| Floor12 electronixtar | Posted 2006-12-19 11:07 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
|
1. Download the file I extracted
2. Copy it to the system32\ folder 3. Run regsvr32 Flash9b.ocx Code |
|
| Floor13 kafen | Posted 2006-12-19 11:21 |
| 初级用户 Posts 43 Credits 97 | |
Originally posted by electronixtar at 2006-12-19 11:07: 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 ] |
|
| Floor14 redtek | Posted 2006-12-19 11:42 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
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 ~:) |
|
| Floor15 lisiyuan | Posted 2006-12-19 11:59 |
| 初级用户 Posts 28 Credits 21 | |
|
Yun is dizzy. Don't understand. Need to study hard in the future.
|
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |