Code: Select all
size := 120
boxSize := 240
myGui := Gui("-SysMenu +ToolWindow +AlwaysOnTop -Caption -DPIScale +E0x20")
myGui.BackColor := 0xBB252525
myGui.SetFont("c0xCC5050 s" size " bold q5", "微软雅黑")
text := myGui.Add("Text", "+Center", "あ")
ControlGetPos(, , &w, &h, text.Hwnd)
offsetX := (boxSize - w) / 2
offsetY := (boxSize - h) / 2
MsgBox(offsetX " " offsetY)
text.Opt("+X" offsetX " +Y" offsetX)
ControlGetPos(&x, &y, , , text.Hwnd)
MsgBox(x " " y)
myGui.Show("NoActivate w240 h240")
How can I modify the position of the text? Or in other words, how can I center the text within the window while restricting its size? (I prefer manually adjusting the coordinates because the baseline of the font I'm using is offset, visually making the entire character appear shifted downwards. However, I haven't found any AHK GUI API specifically for aligning with non-Western characters, so manual adjustment is necessary to achieve the desired effect.)