Page 1 of 1

Gui, Show first time bigger than screen size?

Posted: 15 Sep 2018, 04:06
by Scoox
Quick question:

My display is 2376 pixels wide. I'm able to display a GUI that's wider than 2376 pixels if I explicitly define its width thus:

Code: Select all

Gui, Margin, 15, 15
Gui, Add, Edit, w3000
Gui, Show, w3200 ;<<<
However, the following code shows a GUI that's 2376 pixels wide, which seems wrong because the help file says: "If there is no previous size, the window will be auto-sized according to the size and positions of the controls it contains."

Code: Select all

Gui, Margin, 15, 15
Gui, Add, Edit, w3000
Gui, Show
The following code also shows a GUI that's 2376 pixels wide, which seems even wronger because you I'm explicitly telling it to autosize:

Code: Select all

Gui, Margin, 15, 15
Gui, Add, Edit, w3000
Gui, Show, Autosize ;<<<
I'm currently using the following code as a workaround:

Code: Select all

Gui, Margin, 15, 15
Gui, Add, Edit, w3000
Gui, Show ;<<<
Gui, Show, Autosize ;<<<
Am I misinformed? Thanks

Re: Gui, Show first time bigger than screen size?

Posted: 15 Sep 2018, 05:15
by garry
no answer , just idea , GUI example depending screensize % ( e.g. FHD-1920*1080 or 4K-3840*2160 )

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

Re: Gui, Show first time bigger than screen size?

Posted: 15 Sep 2018, 05:21
by Scoox
@garry In my case the problem is that my GUI has to be physically big because it relies on small clickable areas on an image. If it's too small, it becomes too difficult to aim for these areas. I plan to run my script on a bigger screen but I'm currently on the road and only have my small laptop to work with.

Just wondering whether this is a bug or a feature, and if it's a feature then I'm obviously misreading it.

Re: Gui, Show first time bigger than screen size?

Posted: 15 Sep 2018, 10:47
by just me
Scoox wrote:... which seems wrong because the help file says: "If there is no previous size, the window will be auto-sized according to the size and positions of the controls it contains."
From my experience that's not true. If you don't specify the GUI's width or height, AHK apparently restricts it to the width or height of the primary monitor's working area.

Re: Gui, Show first time bigger than screen size?

Posted: 16 Sep 2018, 00:13
by lexikos
Yes, AutoHotkey limits the automatic size to the width and height determined via SystemParametersInfo(SPI_GETWORKAREA, 0, &work_rect, 0);, but...
Chris wrote:// Seems best to restrict window size to the size of the desktop whenever explicit sizes
// weren't given, since most users would probably want that. But only on first use of
// "Gui Show" (even "Gui, Show, Hide"):
So...

Code: Select all

Gui, Margin, 15, 15
Gui, Add, Edit, w3000
Gui, Show, Hide  ; First use
Gui, Show, AutoSize  ; Second use
Windows also prevents windows from becoming (much?) larger than the virtual screen, but not with complete consistency. For instance, if I make the window resizable, attempting to resize it limits it to 1942 pixels wide with my 1920x1080 screen.
Scoox wrote:In my case the problem is that my GUI has to be physically big because it relies on small clickable areas on an image. If it's too small, it becomes too difficult to aim for these areas. I plan to run my script on a bigger screen but I'm currently on the road and only have my small laptop to work with.
I don't think that explains why you need the GUI to be larger than your screen. You can't see what's not on the screen. I'd guess that you move the window around in order to view different parts of the image, but I think allowing the image to scroll or move within the GUI would make more sense and be easier to use (it just wouldn't be as easy to implement).

One way would be to allow dragging the picture with the mouse. You can detect left-click by monitoring WM_LBUTTONDOWN with OnMessage, or use a hotkey, and then monitor the mouse position with a timer or loop and move the control within the GUI correspondingly.

Re: Gui, Show first time bigger than screen size?

Posted: 16 Sep 2018, 13:19
by Scoox
Thank you Lexikos for the detailed reply and everyone else for chiming in. That answers my question. By 'bigger' I meant 'more pixels' (e.g. 4K) so as to accommodate the entire UI without it spilling past the screen edges and without re-scaling. As you guessed, I am moving the window around to be able to see the bits that fell outside the screen. A scrollable UI would be very good and I've needed it some times in the past but it seemed more hassle than it was worth, add to that he fact that I'm not a programmer, so I tend to choose the path of least resistance that gets the job done.

Re: Gui, Show first time bigger than screen size?

Posted: 18 Sep 2018, 17:52
by techmania
Scoox wrote:@garry In my case the problem is that my GUI has to be physically big because it relies on small clickable areas on an image. If it's too small, it becomes too difficult to aim for these areas. I plan to run my script on a bigger screen but I'm currently on the road and only have my small laptop to work with.

Just wondering whether this is a bug or a feature, and if it's a feature then I'm obviously misreading it.
It is problem due to significant accessibility and image create particular areas of an image into links. So you can check it and change its setting to solve your problem