China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-07 20:42
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Problems with sending keys to the DOS window using VBS under Windows XP View 1,460 Replies 6
Original Poster Posted 2006-11-03 06:47 ·  中国 湖北 武汉 电信
初级用户
Credits 28
Posts 11
Joined 2006-10-12 21:18
19-year member
UID 65492
Status Offline
Below is the VBS script I wrote. The intention was to first open cmd, then use SendKeys to type edit and {ENTER}, so as to enter the edit interface, and then use SendKeys to input other data into edit.

Specifically as follows:


dim wshshell
set wshshell=WScript.CreateObject("WScript.Shell")
wshshell.Run "C:\WINDOWS\system32\cmd.exe"
WScript.Sleep 200

wshshell.SendKeys "edit"
WScript.Sleep 200
wshshell.SendKeys "{ENTER}"
WScript.Sleep 1000

wshshell.AppActivate "C:\WINDOWS\system32\cmd.exe - edit"
WScript.Sleep 2000

Rem The above all work normally and execute effectively, but the next step is not possible:

wshshell.SendKeys "i"



Although the cmd edit window is already in the activated state, the final step of typing "i" never appears in the edit interface, while I can type characters with the keyboard by hand. Please ask the expert, what is the reason?

Thank you!
Floor 2 Posted 2008-03-13 18:48 ·  德国 法兰克福大学
初级用户
Credits 34
Posts 14
Joined 2008-03-12 19:28
18-year member
UID 112774
Gender Male
Status Offline
Bump this post up, please, and see if the experts can solve it. Thanks
Floor 3 Posted 2008-03-13 19:40 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Sending any .SendKeys to the window is not very suitable
第一高手 第二高手

Floor 4 Posted 2008-03-13 19:46 ·  德国 法兰克福大学
初级用户
Credits 34
Posts 14
Joined 2008-03-12 19:28
18-year member
UID 112774
Gender Male
Status Offline
Floor 5 Posted 2008-03-13 20:12 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
The window loses focus, and SendKeys doesn't know where to send it.
第一高手 第二高手

Floor 6 Posted 2008-03-13 20:15 ·  德国 法兰克福大学
初级用户
Credits 34
Posts 14
Joined 2008-03-12 19:28
18-year member
UID 112774
Gender Male
Status Offline
Got it, then I would like to ask fastslz, is there any way to solve this problem? I'm eager to hear the details, thank you
Floor 7 Posted 2008-03-13 20:32 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
It's really very important that you go play with AutoIT scripts.
第一高手 第二高手

Forum Jump: