Modify

Opened 11 years ago

Closed 9 years ago

#462 closed Feature Request (Completed)

Send() can't send Unicode characters.

Reported by: anonymous Owned by: Jon
Milestone: 3.3.5.2 Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

I'm trying to send
ChrW(0x03B8) which is θ ( small theta), but even in notepad, it's not shown up correctly:

$process = Run("notepad.exe")

$NotepadHWND = "Untitled - " ; EN
;~ $NotepadHWND = "Unbenannt - " ; DE

WinActivate($NotepadHWND)
WinWaitActive($NotepadHWND)
$text = ChrW(0x03B8)
Send($text,1)

InputBox("It should be:","It should be this char: Copy it to Notpad and see, that it is accepted",$text)

I think Sned doesn't support Unicode and that should be changed.

Attachments (3)

unicode_test.au3 (1.0 KB) - added by sorin.sbarnea+autoit@… 11 years ago.
unicode_test.2.au3 (1.1 KB) - added by sorin.sbarnea+autoit@… 11 years ago.
autoit_unicode_bug_screenshot.png (7.5 KB) - added by sorin.sbarnea+autoit@… 11 years ago.

Download all attachments as: .zip

Change History (21)

comment:1 Changed 11 years ago by Valik

  • Resolution set to No Bug
  • Status changed from new to closed

You can't possible care about sending UNICODE characters. If you really cared, you would have bothered to read the documentation.

Closing as no bug.

comment:2 Changed 11 years ago by sorin.sbarnea+autoit@…

Sorry, but I consider this a valid bug, even if it's documented. It could be considered a non- bug only if the name of the function would be SendAscii.

In fact there is a solution for solving this: we need to parse the string and for every character(including ASCII ones!) we can generate "ALT+" unicode sequences.

Unicode text input it's a problem and the only way I see this resolved and not depending on the current keyboard layout is to use Alt+numpad sequences.

Example:
Let's say we have the Unicode+0219 (hex) character. This can be entered using:
Send("{ALTDOWN}{NUMPADADD}{NUMPAD0}{NUMPAD2}{NUMPAD1}{NUMPAD9}{ALTUP}")

  • Remember to allways put a numpad0 after the plus so Windows will know not to generate keyboard events when pressing ALT-A/B/C/D (when entering hex numbers).

For more information consult: http://www.fileformat.info/tip/microsoft/enter_unicode.htm

PS. If you do not have time to implement this, please give a hint on where the code should be included and I might find some time to write this code.

comment:3 Changed 11 years ago by Valik

You're an idiot and I wouldn't take any code from you. Why do I call you an idiot? Because I told you to read the documentation - Something you did not do or you would encounter this informative little piece of text:

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}")

Well look at that! You can send UNICODE characters. And you can find that information in the documentation - exactly like I said.

Next time somebody tells you to read the documentation - read it.

comment:4 follow-up: Changed 11 years ago by sorin.sbarnea+autoit@…

It will try to skip over you language and try to show you that you are really wrong.

0xA95 is not a Chinese character, in fact it is GUJARATI LETTER KA - you can check at: http://www.fileformat.info/info/unicode/char/0a95/index.htm

Or better you could use the free software named BabelMap for navigating the Unicode Character Map.

I will attach a test file that contains the same text introduced in 3 methods: clipboard(works), ASC(doesnt), ALT(works).

Changed 11 years ago by sorin.sbarnea+autoit@…

comment:5 in reply to: ↑ 4 Changed 11 years ago by Valik

  • Resolution No Bug deleted
  • Severity changed from None to Blocking
  • Status changed from closed to reopened

Wow, there actually is a bug, it's just not being reported very well. It's taken over 5 months for it to come out what the real issue is. Bravo.

Anyway, it appears that for whatever reason only the last two characters of Send()'s ASC are actually being used. Simple script that reproduces the problem:

Send("{ASC 0x41}")	; Send A
Send("{ASC 0x1141}")	; Sends A, too, though it shouldn't

comment:6 Changed 11 years ago by Valik

  • Owner set to Jon
  • Status changed from reopened to assigned

comment:7 Changed 11 years ago by Jon

Two issues here:

  1. Send indeed doesn't send Unicode characters easily - you have to use the ASC sequences instead. This is mentioned in the limitations section about unicode at http://www.autoitscript.com/autoit3/docs/intro/unicode.htm - I'll try and make it more clear in the Send() documentation as well. It's been on my "to do" list to make it work perfectly for a while so I'll change this bug into a feature request. I usually suggest that Send() is a last resort and you should use ControlSetText() wherever possible which works perfectly with Unicode characters.
  1. The ASC code was a bit broken in that I was always adding a leading 0. So if you specified 0x41 (Dec:65) then this was actually sent as "ALT+065". This is incorrect so I've fixed this and the change will be in the next beta.

comment:8 Changed 11 years ago by Sorin Sbarnea <sorin.sbarnea+autoit@…>

Please take a look at my article from http://blog.i18n.ro/automation-and-unicode-text-input-under-windows/

I would really like to see AutoIt being able to convert any Unicode character that cannot be converted using VkKeyScan to a keystroke intro a ALT+number sequence.

This would make Send() Unicode compatible and will help make people testing the input of foreign characters.

Also: can you enable account creation on Trac? It's really bad that I cannot receive a notification on a response.

comment:9 Changed 11 years ago by sorin.sbarnea+autoit@…

I have bad news regarding this bug - I think there are two of them.

I've extended a little bit the test by adding ASC-decimal version and the result is not well. Also I will attach the new script and a screenshot of the results. Normally it should display the same thing between [].

Changed 11 years ago by sorin.sbarnea+autoit@…

Changed 11 years ago by sorin.sbarnea+autoit@…

comment:10 Changed 11 years ago by Jon

I can't even reproduce the characters when doing it manually with ALT. I certainly don't get the characters you describe at the top of the script.
I get: ↓♥←

comment:11 Changed 11 years ago by Jon

  • Severity changed from Blocking to None
  • Type changed from Bug to Feature Request

comment:12 Changed 11 years ago by TicketCleanup

  • Version 3.2.13.5 deleted

Automatic ticket cleanup.

comment:13 Changed 11 years ago by sorin.sbarnea+autoit@…

I've added to the comments inside the test files that you need to install European Union Font Expansion Pack if you are running XP.
http://www.microsoft.com/downloads/details.aspx?familyid=0EC6F335-C3DE-44C5-A13D-A1E7CEA5DDEA&displaylang=en

This is because two of the 3 characters tested here are not included in default fonts from Windows XP.

comment:14 Changed 11 years ago by sorin.sbarnea+autoit@…

Oops, something had happened. Now it doesn't work on my computer!

I will investigate this further. Anyway: the clipboard part of the test should look fine if you install the font patch.

It's clearly that we have here a Windows issue (something worked, as you see in the screenshot and after few days it doesn't).

Anyway I would recommend you to use the http://www.babelstone.co.uk/Software/BabelMap.html for testing Unicode related issues.

I will come back with new information.

comment:15 Changed 11 years ago by anonymous

A bit difficult to chat easily on here. I've created this thread for further talk:

http://www.autoitscript.com/forum/index.php?showtopic=86602

comment:16 Changed 11 years ago by Jon

That was me, btw :)

comment:17 Changed 9 years ago by Jon

I've done an update to this in the 3.3.5.1 beta that may either help or break everything. Have a look.

comment:18 Changed 9 years ago by Jon

  • Milestone set to 3.3.5.2
  • Resolution set to Completed
  • Status changed from assigned to closed

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jon.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.