How to display RTL Languages in GUI? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
DanielToward13
Posts: 74
Joined: 18 May 2017, 10:56

How to display RTL Languages in GUI?

12 Dec 2017, 16:20

I am using PleasantNotify code to display some notifications in RTL and LTR languages. I have searched for RTL text in GUI but I couldn't find any solution for that. The result should looks something like this:

Image

I have tried to add 0x00400000L to Gui, Notify: Add, Text, % " x" 20 " y" 56 " w" pnW-20 " h" pnH-56 " vpn_msg" 0x00400000L, % message but it doesn't work. Can you give an example for RTL text display in GUI?

Code: Select all

#SingleInstance force
#NoEnv

MyTitle := "Left"
MyMessage := "Loading, Please wait..."
PleasantNotify(MyTitle, MyMessage , 600, 210, "vc hc", "15")
return

PleasantNotify(title, message, pnW=700, pnH=300, position="b r", time=10) {
    global pn_title, pn_msg, PN_hwnd, w, h
	Notify_Destroy()
	Gui, Notify: +AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
	PN_hwnd := WinExist()
	WinSet, ExStyle, +0x20
	WinSet, Transparent, 0
	Gui, Notify: Color, 0xF2F2F0
	Gui, Notify: Font, c0x07D82F s18 wBold, Segoe UI
	Gui, Notify: Add, Text, % " x" 20 " y" 12 " w" pnW-20 " vpn_title", % title
	Gui, Notify: Font, cBlack s15 wRegular
	Gui, Notify: Add, Text, % " x" 20 " y" 56 " w" pnW-20 " h" pnH-56 " vpn_msg", % message
	RealW := pnW + 50
	RealH := pnH + 20
	Gui, Notify: Show, W%RealW% H%RealH% NoActivate
	WinMove(PN_hwnd, position)
	if A_ScreenDPI = 96
		WinSet, Region,0-0 w%pnW% h%pnH% R40-40,%A_ScriptName%
	/* For Screen text size 125%
	if A_ScreenDPI = 120
		WinSet, Region, 0-0 w800 h230 R40-40, %A_ScriptName%
	*/
	winfade("ahk_id " PN_hwnd,210,5)
	if (time <> "P")
	{
		Closetick := time*1000
		SetTimer, ByeNotify, % Closetick
	}
}

Notify_Destroy() {
	global PN_hwnd
	ByeNotify:
	SetTimer, ByeNotify, Off
    winfade("ahk_id " PN_hwnd,0,5)
    Gui, Notify: Destroy
	return
}

pn_mod_title(title) {
	global pn_title
	GuiControl, Notify: Text,pn_title, % title
}

pn_mod_msg(message) {
	global pn_msg
	GuiControl, Notify: Text,pn_msg, % message
}

WinMove(hwnd,position) {
   SysGet, Mon, MonitorWorkArea
   WinGetPos,ix,iy,w,h, ahk_id %hwnd%
   x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ?  (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
   y := InStr(position,"t") ? MonTop : InStr(position,"vc") ?  (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
   WinMove, ahk_id %hwnd%,,x,y
}

winfade(w:="",t:=128,i:=1,d:=10) {
    w:=(w="")?("ahk_id " WinActive("A")):w
    t:=(t>255)?255:(t<0)?0:t
    WinGet,s,Transparent,%w%
    s:=(s="")?255:s ;prevent trans unset bug
    WinSet,Transparent,%s%,%w%
    i:=(s<t)?abs(i):-1*abs(i)
    while(k:=(i<0)?(s>t):(s<t)&&WinExist(w)) {
        WinGet,s,Transparent,%w%
        s+=i
        WinSet,Transparent,%s%,%w%
        sleep %d%
    }
}
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: How to display RTL Languages in GUI?  Topic is solved

12 Dec 2017, 17:04

Hello DanielToward13,

Try the following:

Code: Select all

marginRight := 40
Gui, Notify: Add, Text, % " x" 20 " y" 56 " w" pnW-marginRight " h" pnH-56 " vpn_msg +Right", % message

[EDIT]
Btw a style value goes in between quotes using expressions:

Code: Select all

SS_BLACKRECT := "0x4"

GUI, Margin, 10, 10
GUI, Add, Text, % "Section w300 h300" . A_Space . SS_BLACKRECT,
GUI, Add, Text, % "0x4 ys w300 h300",
GUI, Show, AutoSize
return
my scripts
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How to display RTL Languages in GUI?

12 Dec 2017, 18:30

Btw AHK doesn't use trailing L's with messages.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
DanielToward13
Posts: 74
Joined: 18 May 2017, 10:56

Re: How to display RTL Languages in GUI?

12 Dec 2017, 18:39

@jeeswg What does that mean?

I have another problem which is how to close the GUI if the user clicks outside of the notification window? I have tried to add the below code but it doesn't work because hWinUM is always different from PN_hwnd. is it because the notification GUI is transparent or NoActivate?

Code: Select all

~LButton::
MouseGetPos,,, hWinUM
MsgBox, %PN_hwnd%
MsgBox, %hWinUM%
if (hWinUM != PN_hwnd){
      MsgBox, outside of the notification area
      Notify_Destroy()
}
return
Update:
I found out that the problem was because of the click-through style of the window. I commented the WinSet, ExStyle, +0x20 line out and it works fine now. This article was very helpful to understand the WinSet and ExStyle.
Last edited by DanielToward13 on 13 Dec 2017, 13:26, edited 2 times in total.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How to display RTL Languages in GUI?

12 Dec 2017, 18:53

This style, 0x00400000L, is used in some programming languages, but not AutoHotkey. You would just use 0x00400000.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Google [Bot], Ineedhelplz, Spawnova and 326 guests