Sign in to follow this  
Followers 0
nf67

Sending characters using Unicode

13 posts in this topic

Hi there :evil:,

Is there a way to send a character using its Unicode?

Wikipedia states that U+0115 is the Unicode for ĕ , and &#277 is the "HTML Entity".

I have no idea how to use either, as I have only used ASCII codes so far.

Any help to Send ĕ ?

Thanks a lot :evil:

P.S:

To send UNICODE characters enter the character code (decimal or hex), for example this sends a Chinese character

Send("{ASC 2709}") or Send("{ASC 0xA95}")

Tried Send("{ASC 0115}") but that failed, I don't see any other similarities that the example code and the codes I've found share ;).

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

try: Send(ChrW(0115))

Odd, it outputs an S, maybe I am using the wrong kind of Unicode? Since trying a code with a letter in it (see the table below) gave me an error..

Posted Image

(and just for clarity, my font does support the characters ;))

Edited by nf67

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

looks like you want Hex: 115 so try: ChrW(dec(0115))

Send(ChrW(014F)) gives me an error

Send(ChrW("014F")) gives me some other output, probably containing control (asks if I'd like to save my document)

Send(ChrW(dec(014F))) gives me an error

Send(ChrW(dec("014F"))) gives me the normal o

NŎŎŏŏŏŏŏŏŏŏ! Posted Image

Leaves me clueless

Edited by nf67

Share this post


Link to post
Share on other sites

Does this give anything usefull:

For $x = 1 to 800
    ConsoleWrite( " $X=" & $x & "   Hex=" & hex($x) & "   chrw($x)=" & ChrW($x) & @CRLF)
Next

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Does this give anything usefull:

For $x = 1 to 800
    ConsoleWrite( " $X=" & $x & " Hex=" & hex($x) & " chrw($x)=" & ChrW($x) & @CRLF)
Next

Mm, the ŏ doesn't seem to be there. Then again, if you paste that character into scite it'll just give you a regular o (works fine in notepad). If the console font does this as well, then I might as well miss it, could be one of these:

$X=332 Hex=0000014C chrw($x)=O

$X=333 Hex=0000014D chrw($x)=o

$X=334 Hex=0000014E chrw($x)=O

$X=335 Hex=0000014F chrw($x)=o <= ŏ?

$X=336 Hex=00000150 chrw($x)=O

$X=337 Hex=00000151 chrw($x)=o

Share this post


Link to post
Share on other sites

Send(ChrW(Dec("0000014F")))
also returns the regular o ,could it be that autoit doesn't support these characters?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

To make a hexadecimal number in AutoIt you prefix it with 0x.. The dec function doesn't do anything in this matter.

This worked for me:

Send("{ASC 0x115}")

My SciTE and Notepad both failed to recognize it, though.

Edited by Manadar

Share this post


Link to post
Share on other sites

To make a hexadecimal number in AutoIt you prefix it with 0x.. The dec function doesn't do anything in this matter.

This worked for me:

Send("{ASC 0x115}")

My SciTE and Notepad both failed to recognize it, though.

Mm yeah still the same result, while (as already mentioned above) Notepad and the font do support the character..;)

Share this post


Link to post
Share on other sites

Change the encoding to UTF8 with BOM in SciTE (File -> Encoding -> UDF-8 with BOM) and try the next script:

Global Const $KEYEVENTF_KEYUP =2
Global Const $KEYEVENTF_UNICODE = 4
Global Const $INPUT_KEYBOARD = 1
Global Const $iInputSize = 28

Global Const $tagKEYBDINPUT = _
    'ushort wVk;' & _
    'ushort wScan;' & _
    'dword dwFlags;' & _
    'dword time;' & _
    'ulong_ptr dwExtraInfo'
    
Global Const $tagINPUT = _
    'dword type;' & _
    $tagKEYBDINPUT & _
    ';dword pad;' & _
    'dword pad;'

Global $hDll = DllOpen('user32.dll')
Global $sString = "ĕėĘęĚěĜĝĞğĠġĢģ"

Run("notepad.exe")
WinWaitActive('[CLASS:Notepad]')

_SendEx($sString)

DllClose($hDll)
Exit

Func _SendInputKB($iInputs, $pInputs, $iSize, $hDll = 'user32.dll')
    Local $aRet = DllCall($hDll, 'uint', 'SendInput', 'uint', $iInputs, 'ptr', $pInputs, 'int', $iSize)
    If @error Or Not $aRet[0] Then Return SetError(1, 0, False)
    Return SetError(0, 0, True)
EndFunc

Func _SendEx($sString)
    Local $tINPUTs, $pINPUTs, $iINPUTs
    Local $sStruct
    Local $iFlags, $iStrLen
    
    $iFlags = BitOR($KEYEVENTF_UNICODE, $KEYEVENTF_KEYUP)
    $iStrLen = StringLen($sString)
    
    $sStruct = ''
    
    For $i = 1 To $iStrLen * 2
        $sStruct &= $tagINPUT
    Next
    
    $tINPUTs = DllStructCreate($sStruct)
    $pINPUTs = DllStructGetPtr($tINPUTs)
    $iINPUTs = $iStrLen * 2
    
    For $i = 0 To $iStrLen-1
        Local $Temp = AscW(StringMid($sString, $i+1, 1))
        Local $iOffsetDown = $i * 8
        Local $iOffsetUp   = $i * 16
        
        DllStructSetData($tINPUTs, $iOffsetDown+1, $INPUT_KEYBOARD)
        DllStructSetData($tINPUTs, $iOffsetDown+3, $Temp)
        DllStructSetData($tINPUTs, $iOffsetDown+4, $KEYEVENTF_UNICODE)
        
        DllStructSetData($tINPUTs, $iOffsetUp+9, $INPUT_KEYBOARD)
        DllStructSetData($tINPUTs, $iOffsetUp+11, $Temp)
        DllStructSetData($tINPUTs, $iOffsetUp+12, $iFlags)
    Next
        
    _SendInputKB($iINPUTs, $pINPUTs, $iInputSize, $hDll)
EndFunc

If the encoding is not switched to UTF-8 with BOM right away. Create a new txt file, open with notepad and choose Save As and change the encoding using the dialog, save and rename the file as filename.au3 then open in SciTE.

Share this post


Link to post
Share on other sites

Change the encoding to UTF8 with BOM in SciTE (File -> Encoding -> UDF-8 with BOM) and try the next script:

(...)

If the encoding is not switched to UTF-8 with BOM right away. Create a new txt file, open with notepad and choose Save As and change the encoding using the dialog, save and rename the file as filename.au3 then open in SciTE.

Thanks a lot, I'll try that tomorrow :-)

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  
Followers 0