Jump to content
Sign in to follow this  
Guest yuhe

send UNICODE characters

Recommended Posts

Guest yuhe

I just downloaded autoit v3. and interested in feeding google search box with chinese characters :) from an application.

In autoit documentation, it says:

To send UNICODE characters enter the character code, for example this sends a Chinese character

Send("{ASC 2709}")

I tried to put the line

Send("{ASC 2709}")

inside Examples\notepad1.au3, it did not work.

I also tried sending some other chinese unicode to

google search input box, and never see any chinese show. please help.

Share this post


Link to post
Share on other sites

I just downloaded autoit v3. and interested in feeding google search box with chinese characters :)  from an application.

In  autoit documentation, it says:

To send UNICODE characters enter the character code, for example this sends a Chinese character

    Send("{ASC 2709}")

I tried to put  the line

    Send("{ASC 2709}")

inside Examples\notepad1.au3, it did not work.

I also tried sending some other chinese unicode to

google search input box, and never see any chinese show. please help.

<{POST_SNAPBACK}>

Just tried the Send("{ASC 2709}"), and i gives me an 'o' with a apostrophe over it...

Share this post


Link to post
Share on other sites

I just downloaded autoit v3. and interested in feeding google search box with chinese characters :)  from an application.

In  autoit documentation, it says:

To send UNICODE characters enter the character code, for example this sends a Chinese character

    Send("{ASC 2709}")

I tried to put  the line

    Send("{ASC 2709}")

inside Examples\notepad1.au3, it did not work.

I also tried sending some other chinese unicode to

google search input box, and never see any chinese show. please help.

<{POST_SNAPBACK}>

hi, i'm kerean :D

korean,chinese use 2byte languge.(also japanese)

autoit can't send 2byte languge using send()

you must use ControlSetText()

Share this post


Link to post
Share on other sites

I don't know if dok_do has the right answer.

What I am for sure as an AutoIt dev is what has been written by JON (AutoIT Chief Officer) is right (unless we introduce a BUG)

Make sure the window you are sending char to is active. So your code must look like

WinWaitActive("title")
Send("{ASC 2709}")

I have no idea what should appear in the windows "title" because 2709 does not mean anything to me.

"title" is what appear in the windows bar.

You can use too the ControlSend which does not need to have the windows active but require to know the control your are sending to.

Good luck :)

Share this post


Link to post
Share on other sites
Guest yuhe

hi, i'm kerean  :)

korean,chinese use 2byte languge.(also japanese)

autoit  can't  send  2byte languge using send()

you must use ControlSetText()

<{POST_SNAPBACK}>

Share this post


Link to post
Share on other sites
Guest yuhe

hi, i'm kerean  :)

korean,chinese use 2byte languge.(also japanese)

autoit  can't  send  2byte languge using send()

you must use ControlSetText()

<{POST_SNAPBACK}>

I am not sure how to express unicode inside .au3 file, I tried {ASC 2709}, chr(2709), and '\u2709", neither worked, and finally I let the chinese as input parameter, like the following.

Run("notepad.exe")

WinWait("Untitled -")

ControlSetText("Untitled -", "", "Edit1", $CmdLine[1])

and run from start->run with a chinese character as input parameter, but got a '?' inside notepad.

Share this post


Link to post
Share on other sites

To send unicode your system should, of course, first be set up to input and display unicode characters. A chinese user named Robie Zhou (robiezhou@gmail.com) has written a user function to send unicode.

;======================================================

;

; Function Name: _SendUnicode("string")

; Description: Send a unicode or an ASCII string.

; Parameter(s): $string is the string you want to send.

; Requirement(s): String Input.

; Return Value(s): None

; Author(s): Robie Zhou (robiezhou@gmail.com)

;

;======================================================

Func _SendUnicode($string)

Local $char

Local $code

For $i = 1 to StringLen($string)

$char = StringMid($string, $i, 1)

$code = Asc($char)

If $code > 127 Then

$code = $code * 256

$i = $i + 1

$char = StringMid($string, $i, 1)

$code = $code + Asc($char)

EndIf

Send("{ASC " & $code & "}")

Next

EndFunc

Save the above script as "Chinese.au3" in the include folder.

To test it run the following.

#include <Chinese.au3>

Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

_SendUnicode("這是中文")

Send("{ENTER}")

If this helps you can send a note to Robie Zhou (robiezhou@gmail.com) to thank him.

Share this post


Link to post
Share on other sites

Yes, here is the solution I posted in another forum.

If you can read Chinese, you can see it in https://d4e.org/showthread.php?t=54252

I paste the UDF here

;======================================================
;
; Function Name:    _SendUnicode("string")
; Description:    Send a unicode or an ASCII string.
; Parameter(s):  $string is the string you want to send.
; Requirement(s):   String Input.
; Return Value(s):  None
; Author(s):        Robie Zhou (robiezhou@gmail.com)
;
;======================================================
Func _SendUnicode($string)
    Local $char
    Local $code
    
    For $i = 1 to StringLen($string)
        $char = StringMid($string, $i, 1)
        $code = Asc($char)
        If $code > 127 Then
            $code = $code * 256
            $i  = $i + 1
            $char = StringMid($string, $i, 1)
            $code = $code + Asc($char)
        EndIf
        Send("{ASC " & $code & "}")
    Next
EndFunc

And this is an example (Can only run in a Chinese version of windows system)

#include <String.au3>

Run("notepad.exe")
WinWaitActive("未定标题")
_SendUnicode("测试一下AutoIt对于Unicode的支持")
Send("{ENTER}")

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...