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-06-26 04:33
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How can VBS input Chinese? View 1,866 Replies 9
Original Poster Posted 2007-04-25 08:13 ·  中国 湖南 长沙 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
─────────────────── Moderator Record ────────────────────
Handled by: bjsh
Note: Because similar content was posted in , there is no need to make a new thread;
Reminder: For questions with similar content, you can ask them in one post; just modify the title appropriately.
Penalty: No penalty for now; a warning is given; please click here to read the forum posting rules, so as to avoid
making rule-violating posts in future discussions.
─────────────────── Moderator Record ────────────────────



I copied a VBS for automatically logging into Chinagames, but I found that it doesn't work if the username is in Chinese. What should I do?
hjd="""C:\Program Files\Chinagames\iGame\iGame.exe"""
Set Ws=WScript.CreateObject("WScript.Shell")
Ws.Run hjd
WScript.Sleep 2000
Ws.SendKeys "+{TAB 2}"
Ws.SendKeys "{bs 100}"
Ws.SendKeys "//小楼一夜听春雨/"
WScript.Sleep 1000
Ws.SendKeys "{TAB 2}"
Ws.SendKeys "123456"
WScript.Sleep 200
Ws.SendKeys "{ENTER}"

[ Last edited by bjsh on 2007-4-24 at 07:51 PM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
baomaboy -8 2007-04-26 05:02
Floor 2 Posted 2007-04-25 13:11 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
The literal meaning of SendKeys is to send keyboard commands. Chinese won't work, so you can only try a different approach (looking into it...)

If the input line supports Ctrl+A Select All:
Ws.SendKeys "^a{del}" (you can also skip {del} and directly use "^a123456", same below)
then you don't need to use Ws.SendKeys "{bs 100}"

If it does not support Ctrl+A Select All:
If the input cursor is at the far right of the input line: Ws.SendKeys "+{left}{del}"
If the input cursor is at the far left of the input line: Ws.SendKeys "+{right}{del}"

[ Last edited by zh159 on 2007-4-25 at 12:22 AM ]
Floor 3 Posted 2007-04-25 23:25 ·  中国 上海 浦东新区 电信
中级用户
★★
Credits 302
Posts 138
Joined 2007-03-29 02:33
19-year member
UID 83224
Gender Male
Status Offline
Test environment: XP, after switching with ctrl+space the input method is Intelligent ABC
Output result: 小楼一夜听春雨

zhongwen="C:\WINDOWS\system32\cmd.exe"
Set WshShell=WScript.CreateObject("WScript.Shell")
WshShell.Run zhongwen
WScript.Sleep 1000
WshShell.SendKeys "^ xiao"
WScript.Sleep 1000
WshShell.SendKeys "lou "
WScript.Sleep 1000
WshShell.SendKeys "yi "
WScript.Sleep 1000
WshShell.SendKeys "ye "
WScript.Sleep 1000
WshShell.SendKeys "2"
WScript.Sleep 1000
WshShell.SendKeys "ting "
WScript.Sleep 1000
WshShell.SendKeys "chun "
WScript.Sleep 1000
WshShell.SendKeys "yu "
WScript.Sleep 1000
WshShell.SendKeys "5"
Floor 4 Posted 2007-04-25 23:39 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
ctrl+space usually switches to the default first input method. Mine is "Ziguang Pinyin", so you have to switch according to your own usage pattern by using ctrl+space the needed number of times.
Floor 5 Posted 2007-04-26 07:55 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Create an IE object, then you can use the clipboard ^
After copying the Chinese text to the clipboard, use VBS to send SENDKEYS
the ctrl+V combination
Floor 6 Posted 2007-04-26 11:37 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Originally posted by slore at 2007-4-25 18:55:
Create an IE object, then you can use the clipboard ^
After copying the Chinese text to the clipboard, use VBS to send the SENDKEYS
ctrl+V combination

Yes, I wrote one
str = "内容内容$内容内容"
Num = len(str)
Set WshShell=wscript.createobject("Wscript.Shell")
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate("about:blank")

WshShell.run("notepad.exe")
Wscript.Sleep 1000

for i = 1 to Num
Wscript.Sleep 200
var = Mid(str, i, 1)
if var = "$" then var = vbCrLf
objIE.document.parentwindow.clipboardData.SetData "text", var
WshShell.Sendkeys("^v")
next

objIE.Quit
Wscript.Quit
Floor 7 Posted 2007-04-26 12:18 ·  中国 湖南 张家界 电信
初级用户
Credits 69
Posts 37
Joined 2007-01-01 14:22
19-year member
UID 75195
Gender Male
Status Offline
I hope these good things can be explained in detail. A newbie like me still can't understand them.
Floor 8 Posted 2007-04-28 22:57 ·  中国 湖南 长沙 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
Post #6, could you add an explanation after it?
Thanks,
when I run your code, it says the line objIE.Quit has an error. If I remove that line it works, but it opens a blank webpage, very strange!!!!

[ Last edited by 26933062 on 2007-4-28 at 10:03 AM ]
Floor 9 Posted 2007-04-28 23:23 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
It needs IE support (I think IE has to be the default browser)

Actually it's about the same as a batch file, except that with objIE the characters are copied into the clipboard one by one using for
Floor 10 Posted 2007-08-16 16:11 ·  中国 江苏 南京 电信
中级用户
★★
Credits 397
Posts 168
Joined 2006-10-08 10:07
19-year member
UID 64934
Status Offline
Yeah! It seems that if Maxthon is the default browser, then it's difficult!!~~!
Forum Jump: