 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Antonimo
Joined: 28 Apr 2006 Posts: 53
|
Posted: Sun Jul 05, 2009 6:17 pm Post subject: Display Greek Characters in Message Box |
|
|
I am using a very simple script that reads a random line from a text file and displays it in a message box when the hotkey is pressed.
The problem is that lines in the text file contain Greek and English words. When the message box appears, the Greek letters are not right:
άλογο - horse
instead of
άλογο - horse
How can I get the message box to display the Greek letters correctly? Please can somebody help me? |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 722 Location: Iowa, USA
|
Posted: Sun Jul 05, 2009 7:06 pm Post subject: |
|
|
I don't believe AHK currently supports Unicode characters - see here
For example, copy this: άλογο - horse | Code: | | MsgBox % Clipboard ; displays ????? - horse |
Edit - also see How to Unicode//Ascii in a MsgBox???
Last edited by jethrow on Sun Jul 05, 2009 7:18 pm; edited 4 times in total |
|
| Back to top |
|
 |
YMP
Joined: 23 Dec 2006 Posts: 329 Location: Russia
|
Posted: Sun Jul 05, 2009 7:09 pm Post subject: |
|
|
| The file is apparently saved in UTF-8. Save it as ANSI, e.g. in Notepad. |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 2342
|
Posted: Sun Jul 05, 2009 11:31 pm Post subject: |
|
|
I hope you don't mind looking up the codes for unicode characters...
| Code: | msgbox % MsgBoxW( 2, "{√Ⅹ∃}", "άλογο - horse" )
MsgBoxW( msg0, title="", text="" ) ; the "W" is for 'wide' chars
{ ; Function by [VxE]. A wrapper for the MessageBoxW function, which takes
; wide-char strings (unicode). Since AHK doesn't like unicode, the strings need
; to be converted (hence the A2W function).
; Before you ask... no, I don't know how to make it have a time limit
; function info @ http://msdn.microsoft.com/en-us/library/ms645511(VS.85).aspx
static OwnerHWND, ResultList
If !OwnerHWND
{
odhw = %A_DetectHiddenWindows%
DetectHiddenWindows, on
OwnerHWND := WinExist("Ahk_PID " . DllCall("GetCurrentProcessId"))
DetectHiddenWindows, %odhw%
}
If !ResultList
ResultList = OK,CANCEL,ABORT,RETRY,IGNORE,YES,NO,CLOSE,HELP,TRYAGAIN,CONTINUE,TIMEOUT
If (title = "" && text = "" )
{ ; mode 1
title := A_ScriptName
text := msg0
msg0 := 0
}
A2W( text )
A2W( title )
result := DllCall( "MessageBoxW"
, UInt, OwnerHWND
, UInt, &text
, UInt, &title
, UInt, msg0 )
Loop, Parse, ResultList, `,
If (A_Index = result)
return A_LoopField
return result
}
A2W( byref str ) ; Ascii to Wide-char. Version 2.0
{ ; function by [VxE], returns a string in unicode format. Uses html-style
; codes for unicode characters (i.e. ሴ or 〹 ). Intended for
; external functions (via DllCall). Return value is the number of characters.
text := str
u := v := pos := 0
Loop
If (pos := InStr( text, "&#", 0, pos+1 ))
&& (pos2 := InStr( text, "`;", 0, pos ))
{
If (num := Abs("0" . SubStr( text, pos+2, pos2-pos-2 )))
{
u++
u%u% := num
StringReplace, text, text, % SubStr(text, pos, pos2-pos+1), % chr(4)
}
}
Else Break
VarSetCapacity(str, 2+2*len:=StrLen(text), 0) ; make space and wipe bits
Loop, Parse, text
If (num := Asc(A_LoopField)) = 4
v++, NumPut( u%v%, str, 2*A_Index-2, "UShort" )
Else NumPut( num, str, 2*A_Index-2, "UShort" )
return len
} |
_________________ My Home Thread
Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags ! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|