Jump to content


Photo

[AHK_L] send not working with unicode


  • Please log in to reply
11 replies to this topic

#1 geekey

geekey
  • Members
  • 7 posts

Posted 19 October 2010 - 08:12 AM

[Moderator's note: Topic split from AutoHotkey_L thread.]

bug on vista ultimate, function that send, snedraw ,sendinput can't work correctly!
Download autohotkey_L from the autohotkey.com
install it in D:\Program Files\AutoHotkey
make an sendunicode.ahk in SciTE, code as blew:

  WinActivate,seen.txt - 记事本
  send,hello你好{Enter}
  sendinput,hello你好{Enter}
  SendRaw,hello你好{enter}
  sendinput,hello你好{Enter}
press"F5" and the output as blew:

hello
hello{enter}
            -notes:nothing displayed

------------------------------------------------------------------
Why the word “你好” between "hello" and "{enter}" can't be printed in notepad?
Any one can check this error or bug? give a method please!!

TKS!!

#2 Lexikos

Lexikos
  • Administrators
  • 8832 posts

Posted 19 October 2010 - 08:30 AM

This has come up numerous times already. Save your script file as UTF-8.

Script File Codepage: Using non-ASCII characters safely in scripts.
Source: Scripts (AutoHotkey_L Documentation)



#3 geekey

geekey
  • Members
  • 7 posts

Posted 19 October 2010 - 11:32 AM

This has come up numerous times already. Save your script file as UTF-8.

Script File Codepage: Using non-ASCII characters safely in scripts.
Source: Scripts (AutoHotkey_L Documentation)

sure i did,but error still occurs
In notepad,I save as the Code in UTF-8,but the same error comes out as above.
How could i get it worked correctly?

#4 Lexikos

Lexikos
  • Administrators
  • 8832 posts

Posted 19 October 2010 - 12:10 PM

In that case, are you using the Unicode build or the ANSI build? If you're not sure, you may run this:
MsgBox % A_IsUnicode ? "Unicode" : "ANSI"
If you add
ListLines
Pause
to the end of your script, do you see those characters in the line listing?

If I copy and paste your code and run it with the Unicode build, I get the following output in both Notepad and SciTE:
hello你好
hello你好
hello你好{enter}hello你好
However, the script outputs the following for me with the ANSI build:
hello??
hello??
hello??{enter}hello??
This is because my system default ANSI code page does not include those characters.

#5 Sean

Sean
  • Members
  • 2462 posts

Posted 19 October 2010 - 03:36 PM

I suggest to retire the ANSI build, it's only causing trouble/confusion. If an user needs ANSI build he can use the old build. And, I suggest for users to use an editor where the default encoding can be set to UTF-8.

#6 jethrow

jethrow
  • Fellows
  • 2549 posts

Posted 19 October 2010 - 03:44 PM

... I suggest for users to use an editor where the default encoding can be set to UTF-8.

For those who use SciTE4AutoHotkey, here's how you set the default encoding to UTF-8.

#7 geekey

geekey
  • Members
  • 7 posts

Posted 19 October 2010 - 05:23 PM

In that case, are you using the Unicode build or the ANSI build? If you're not sure, you may run this:

MsgBox % A_IsUnicode ? "Unicode" : "ANSI"
If you add
ListLines
Pause
to the end of your script, do you see those characters in the line listing?

If I copy and paste your code and run it with the Unicode build, I get the following output in both Notepad and SciTE:
hello你好
hello你好
hello你好{enter}hello你好
However, the script outputs the following for me with the ANSI build:
hello??
hello??
hello??{enter}hello??
This is because my system default ANSI code page does not include those characters.


Firstly,Thank you all the same,but the Problems still occurred:

reply 1:
Yes,the msgbox come out "Unicode"

repy2:
my runing result as below>
--------------------------------------------
002: SendMode,Input
003: SetWorkingDir,%A_ScriptDir%
004: MsgBox,A_IsUnicode ? "Unicode" : "ANSI" (1.64)
005: WinActivate,seen.txt - 记事本 (0.13)
006: Send,hello你好{Enter} (0.08)
007: SendInput,hello你好{Enter} (0.03)
008: SendRaw,hello你好{enter} (0.03)
009: SendInput,hello你好{Enter} (0.03)
010: ListLines

and the output is:

hello
hello
hello{enter}hello


repy3:
Yes,when it is the old version of autohotkey(non_L) my running result is as same as yours above.
hello??
hello??
hello??{enter}hello??
---------------------------------------------
sigh,where is the true reason? Do you mind helping check it and solve it please? or may you share you ahk_L version copy which can work normally to me ,if so,Great thanks ,then I can run to test whether it is my System environment problem or not.
my GM:pesicolar@gmail.com :)

#8 Sean

Sean
  • Members
  • 2462 posts

Posted 20 October 2010 - 12:51 AM

First try to change the font of your target application. If still not work, upload, not copy and paste, your script somewhere, better after compressing it in ZIP. autohotkey.net can be a good place.

BTW, if your target application was opened in ANSI (:in your case, Chinese?) mode, there would be an attempt to translate UNICODE to ANSI, although I don't think it was a problem as you seemed to be a Chinese and your data was also in Chinese.

#9 geekey

geekey
  • Members
  • 7 posts

Posted 20 October 2010 - 02:41 AM

First try to change the font of your target application. If still not work, upload, not copy and paste, your script somewhere, better after compressing it in ZIP. autohotkey.net can be a good place.

BTW, if your target application was opened in ANSI (:in your case, Chinese?) mode, there would be an attempt to translate UNICODE to ANSI, although I don't think it was a problem as you seemed to be a Chinese and your data was also in Chinese.


yeah, my os is vista ultimate of Simple Chinese.
"First try to change the font of your target application"
You mean set the SciTEGlobal.properties files with #encode setting? if so, I have tried with your advice"For those who use SciTE4AutoHotkey, here's how you set the default encoding to UTF-8.",not worked.
" target application" means autohotkey.exe ,ahkscript or anything else?

#10 Sean

Sean
  • Members
  • 2462 posts

Posted 20 October 2010 - 05:25 AM

The target application is what received the sent keys, e.g., notepad etc. Change the font of it to the one that can display fully the UNICODE text, not all fonts can do that. In short, I'm suspecting that the data were actually there, just couldn't be displayed.

#11 geekey

geekey
  • Members
  • 7 posts

Posted 20 October 2010 - 08:41 AM

The target application is what received the sent keys, e.g., notepad etc. Change the font of it to the one that can display fully the UNICODE text, not all fonts can do that. In short, I'm suspecting that the data were actually there, just couldn't be displayed.


Thank you ,I try it but fail.
With your reference ,I find such error may be caused by the TAB"non-Unicode Programing language (system regional)" in the window of "regional and language"
I Google something about "Vista Unicode" ,There is some advice to install Unicode2.5 to vista.Maybe it can fix the error?

#12 Sean

Sean
  • Members
  • 2462 posts

Posted 20 October 2010 - 03:22 PM

Have you checked the characters were really missing? Anyway, there is no evidence that the problem lies on the side of AHK. It looks like more likely on your app or your system side. In that case, it largely depends on your skill to track down the error to solve the issue.