GUI on different monitors
-
- Posts: 112
- Joined: 06 Jun 2016, 21:32
GUI on different monitors
How to get uniform size of text, pic, and window for different monitors??
Re: GUI on different monitors
example depending screensize in procent %
example with edit / buttons ...
Code: Select all
;- GUI example depending screensize % ( e.g. FHD-1920*1080 or 4K-3840*2160 )
;- modified= 20180906
;- created = 20180906
;------------------------------------------------------
#warn
#NoEnv
#singleinstance,force
SendMode, Input
SetWorkingDir, %A_ScriptDir%
SetBatchLines, -1
SplitPath,a_scriptfullpath, name, dir, ext, name_no_ext, drive
name1=%name_no_ext%
Gui,2:default
Gui,2: -DPIScale
SS_REALSIZECONTROL := 0x40
Gui,2:Color,Black
Gui,2:Color,ControlColor, Black
Gui,2:Font,s12 cYellow,Lucida Console
;A_GuiFont := GuiDefaultFont()
;A_GuiFontSize := A_LastError
;aac:= a_screendpi ;- 168 at 4k
WinGetPos, TTX, TTY, TTW, TrayHeight, ahk_class Shell_TrayWnd,,,
ha :=(A_screenheight-TrayHeight)
;ha:=A_screenHeight
wa :=A_screenwidth
xx :=100.5 ;- a little bit smaller
GW :=(wa*100) /xx
GH :=(ha*100) /xx
Picture =C:\windows\web\wallpaper\theme1\img1.jpg
Gui,2: Add, Picture, gImageButton , %Picture%
Gui,2:show, x0 y0 w%gw% h%gh% ,%name1%
return
;-----------------------
esc::exitapp
;-----------------------
2Guiclose:
exitapp
ImageButton:
msgbox, 262208, ,You clicked on %A_ThisLabel%, 1
Return
Code: Select all
;- GUI example depending screensize % ( e.g. FHD-1920*1080 or 4K-3840*2160 )
;- arrays ( 4-columns*8-Rows ) , ROW:1=text / ROW:2-7=edit / ROW:8=buttons
;- modified= 20180906
;- created = 20180906
;------------------------------------------------------
#warn
#NoEnv
#singleinstance,force
SendMode, Input
SetWorkingDir, %A_ScriptDir%
SetBatchLines, -1
SplitPath,a_scriptfullpath, name, dir, ext, name_no_ext, drive
name1=%name_no_ext%
Gui,2:default
Gui,2: -DPIScale
SS_REALSIZECONTROL := 0x40
Gui,2:Color,Black
Gui,2:Color,ControlColor, Black
Gui,2:Font,s12 cYellow,Lucida Console
;A_GuiFont := GuiDefaultFont()
;A_GuiFontSize := A_LastError
;aac:= a_screendpi ;- 168 at 4k
WinGetPos, TTX, TTY, TTW, TrayHeight, ahk_class Shell_TrayWnd,,,
ha :=(A_screenheight-TrayHeight)
;ha:=A_screenHeight
wa :=A_screenwidth
xx :=100.5 ;- a little bit smaller
GW :=(wa*100) /xx
GH :=(ha*100) /xx
;=================================================
; Example 4 columns / 8 -rows
; Row 1 = text
; Row 2-7 = edit ED1...ED24
; Row 8 = Button 1-4
sectA=Column-1,Column-2,Column-3,Column-4 ;- column-name
stringsplit,k,sectA,`,
columns:=k0 ;- total columns 4
SectB=AHK-Help,notepad,Calc,Charmap ;- button-name
stringsplit,b,sectB,`,
;--------- ( 4*8 ) ------------
rows:=8
all :=(rows*columns) ;- 8*4 = 32
;------------------------------
d :=(wa*.3)/xx ;- difference
h :=(ha* 2)/xx ;- height
w :=(wa*11)/xx ;- width
i:=0
r:=0
e:=0
q:=0
s:=3
Loop,%all%
{
;-----------------
M:=mod(i,columns)
if m=0 ;- skip to next line/ROW
R++
;-----------------
;--- (ROW Line-1) first line text
if (m=0 and R=1)
{
x :=(wa*.5)/xx
y :=(ha* 1)/xx
Gui,2:add,text,section x%x% y%y% w0 h0,
}
if (R=1)
Gui,2:Add,text,ys x+%d% h%h% w%w% ,% k%a_index%
;--- (ROW's Line 2-7 )second line begin with EDIT ED1... ED24
if (m=0 and R>1 and R<8)
{
x :=(wa*.5)/xx
y :=(ha* s)/xx
s :=(s+2.7) ;- add difference vertikal
Gui,2:add,text,section x%x% y%y% w0 h0,
}
if (R>1 and R<8)
{
e++
Gui,2:Add,Edit , ys x+%d% w%w% h%h% vED%e% readonly left,%e%
}
;------------ ROW Line 8 4-color buttons ------------
if (m=0 and R>7 and R<9)
{
x :=(wa*.5)/xx
y :=(ha* s)/xx
s :=(s+2.7)
Gui,2:add,text,section x%x% y%y% w0 h0,
}
if (R>7 and R<9)
{
q++
;Gui,2:add,button, ys x+%d% w%w% h%h% gStart2,% b%q%
Gui,2:Add,Progress,ys x+%d% w%w% h%h% Disabled BackgroundGray
if (q<2)
Gui,2:Add,Text, xp yp wp hp cYellow BackgroundTrans Center 0x200 gStart2 ,% b%q%
else
Gui,2:Add,Text, xp yp wp hp cBlack BackgroundTrans Center 0x200 gStart2 ,% b%q%
}
i++
}
;----
Gui,2:show, x0 y0 w%gw% h%gh% ,%name1%
loop,%all%
{
if (a_index>4 or a_index<25)
Guicontrol,2:,ed%a_index%, This is edit ED%a_index%
}
return
;-----------------------
esc::exitapp
;-----------------------
2Guiclose:
exitapp
;-----------------------
Start2:
gui,2:submit,nohide
r:= a_guicontrol
goto,%r%
return
ahk-help:
try
run,%a_programfiles%\AutoHotkey\AutoHotkey.chm
return
notepad:
run,%r%
return
calc:
run,%r%
return
charmap:
run,%r%
return
;=====================================================================================