unicodeautoit

Sending unicode characters from the clipboard using ClipGet()


So, currently I'm basically copying a name of the folder using the Ctrl+C that I'm sending to a window explorer. The text that gets copied is usually full of Unicode characters. Then, I'm using ClipGet() like this:

$data = ClipGet()
Send($data)

Unfortunately, the ClipGet() command does not work well with Unicode, so instead of sending the correct title of the folder, I get a bunch of ? characters. I'm really not sure what should I do to Send() the proper text filled with Unicode characters.


Solution

  • Clip get works perfectly. Send() is the problem.

    From the forum

    ;======================================================
    ;
    ; 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