Hi all,
I am fairly sure that AHK can do this, but being an AHK newbie, I don't really know where to start, let alone know what the best way to do this is. What I want is to create a key combination that will allow me to maximize the currently active application so that it appears in fullscreen; that is, you only see the client area of the window, with the window title bar, borders, etc, hidden, and the taskbar out of view. Essentially I am trying to achieve the effect of apps such as Dark Room (http://they.misled.us/dark-room), but with an arbitrary application---well, I specifically want to replicate this effect with my favourite text editor, Vim...
Any help in getting the ball rolling would be greatly appreciated.
script to fullscreen any app?
Started by
mackal2
, May 15 2007 05:15 AM
13 replies to this topic
#1
-
Posted 15 May 2007 - 05:15 AM
You can maximize windows pretty easily with WinMaximize or WinMove.
But it is more difficult to make a window bigger then the screen resolution. (Try to drag a window larger then it, by moving it first partly out of the screen to the lower right, then drag it bigger. It stops to get bigger at around screen resolution.)
Best solution would be to serach if that app supports full screen mode. Like F11 in Internet Explorer.
At the end you could try to use WinSet. Either hide parts of the window, but I'm not sure if you can then make the window larger. Or by sending Style,N or ExStyle,N. Maybe there is a Style that does what you want.
But it is more difficult to make a window bigger then the screen resolution. (Try to drag a window larger then it, by moving it first partly out of the screen to the lower right, then drag it bigger. It stops to get bigger at around screen resolution.)
Best solution would be to serach if that app supports full screen mode. Like F11 in Internet Explorer.
At the end you could try to use WinSet. Either hide parts of the window, but I'm not sure if you can then make the window larger. Or by sending Style,N or ExStyle,N. Maybe there is a Style that does what you want.
#2
-
Posted 15 May 2007 - 06:32 AM
Ciao
toralf
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.
toralf
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.
You can WinMove to get the title bar and borders out of screen.
Example, with semi-random offsets:
Example, with semi-random offsets:
Run Notepad.exe, , , npPID WinWait ahk_pid %npPID% WinMove ahk_pid %npPID%, , -5, -40, A_ScreenWidth + 40, A_ScreenHeight + 50
#3
-
Posted 15 May 2007 - 08:44 AM
Run, %A_Windir%\Notepad.exe,,Min, PID WinWait, ahk_pid %PID% ID := WinExist("ahk_pid " PID) WinMove, ahk_id %ID%,, 0,0 WinSet, Style, -0xC00000, ahk_id %ID% ; Remove Titlebar : WS_CAPTION WinSet, Style, -0x40000 , ahk_id %ID% ; Remove Borders : WS_SIZEBOX WinSet, AlwaysOnTop , On, ahk_id %ID% WinMaximize, ahk_id %ID%
#4
-
Posted 15 May 2007 - 09:12 AM
It is clever as it is independent of decoration (caption, borders) size.
I don't see why you use ID instead of PID, both work fine, don't they?
I don't see why you use ID instead of PID, both work fine, don't they?
#5
-
Posted 15 May 2007 - 09:26 AM
Using ID instead of PID makes the script more easily adaptable - for example, instead of:It is clever as it is independent of decoration (caption, borders) size.
I don't see why you use ID instead of PID, both work fine, don't they?
ID := WinExist("ahk_pid " PID)you could put
ID := WinActive("A")to work with the active window. Of course, in this case you may as well replace "ahk_id %ID%" with "A"...
That's how I see it, anyway.
#6
-
Posted 15 May 2007 - 11:38 PM
I don't see why you use ID instead of PID, both work fine, don't they?
They would. It is just my habit of using ahk_pid only for Process related operations. For Window/control related commands, I always use ahk_id even it costs me an extra line.
Also
In the code I had given, I know Notepad has only one GUI. There might be cases where the process can have more than two windows and the one that has focus will be returned.
You can test it with the following code:
PID := DllCall("GetCurrentProcessId") Gui, 1:Show, x0 y0 w400 h100 , GUI 1 Gui, 2:Show, x420 y0 w400 h100 , GUI 2 Return ^F2::MsgBox, % WinExist( "ahk_pid " PID ) #x::ExitApp
So it is safe to fetch the ahk_id of the correct window and use it,
like: ^F2::MsgBox, % WinExist( "GUI 1 ahk_pid " PID )
Experimenting a bit on it, I find that if a process has an additional hidden GUI and DetectHidden windows is on, then ahk_pid might even report the ID of the hidden GUI.
#Persistent DetectHiddenWindows, On PID := DllCall("GetCurrentProcessId") WinShow, % "ahk_id " WinExist( "ahk_pid " PID )
ID := WinActive("A")
It is less reliable! There is a minimal chance that someother app could take the focus resulting with undesired window ID.
#7
-
Posted 16 May 2007 - 12:08 AM
If you mean it is less reliable to use WinActive after launching Notepad, I understand. My intention was to demonstrate how to use the active window, instead of a newly launched notepad.It is less reliable! There is a minimal chance that someother app could take the focus resulting with undesired window ID.
IMHO, it's generally more useful to be able to "fullscreen any app" than to launch a specific app into fullscreen. If you're working with the active window, it doesn't matter how many windows the process has.In the code I had given, I know Notepad has only one GUI. There might be cases where the process can have more than two windows and the one that has focus will be returned.
Btw, it isn't necessary to call WinSet,Style more than once when removing multiple styles:
WinSet, Style, -0xC40000, ahk_id %ID% ; Remove Titlebar : WS_CAPTION=0xC00000 and Borders : WS_SIZEBOX=0x40000But I suppose having seperate command-calls is clearer, and easier to modify for those not familiar with styles.
I have a habit of using the Last Found Window feature as much as possible. For example, you can do away with "ID":It is just my habit of using ahk_pid only for Process related operations.
Run, %A_Windir%\Notepad.exe,,Min, PID WinWait, ahk_pid %PID% WinExist("ahk_pid " PID) ; alternatively, replace the above THREE lines with: WinActive("A") ; to fullscreen the active window WinMove, 0,0 ; I'm not sure what the purpose of this line is... WinSet, Style, -0xC40000 ; Remove Titlebar and Borders (WS_CAPTION | WS_SIZEBOX) WinSet, AlwaysOnTop , On ; This doesn't seem quite necessary either, see below. WinMaximizePersonally, I'd leave out AlwaysOnTop, so that the user can switch to another app while a window is "fullscreen." It seems that removing WS_SIZEBOX|WS_CAPTION and maximizing notepad causes it to hide the taskbar even when it isn't always-on-top (on Windows XP, at least.) When fullscreen notepad loses the focus, the taskbar returns...
Edit: Window positioning is a bit off if the window was already maximized, probably because the position is reported as -4,-4.
#8
-
Posted 16 May 2007 - 06:14 AM
Thanks, Skan, it makes sense... :-D
I replied to Helpy and it is Grumpy who is thanking me
#10
-
Posted 16 May 2007 - 08:24 AM
Because I too was enlightened by your thinking, oh dear guru...
#11
-
Posted 16 May 2007 - 08:33 AM
Just in case: The discussion on (and code for) this can be found over at the DonationCoder.com forums.
Also, when I find the time, I might use these methods in my Screen Switcher script...
Also, when I find the time, I might use these methods in my Screen Switcher script...
#12
-
Posted 28 May 2007 - 06:25 AM
Improving my world, one script at a time.
Join the AutoHotkey IRC channel: irc.freenode.net #autohotkey
Join the AutoHotkey IRC channel: irc.freenode.net #autohotkey
Nice topic! I've been dealing with similar problem some time ago and this is what I came with:
I tried to hide the taskbar, however that didn't help. Any ideas?
; ------------------------------------------------------------------------------ ; active app full screen mode toggle ; prerequisite: window has to be maximized #1:: WinGet, acw_m, MinMax, A if (acw_m = 1) { WinActive("A") WinGet, acw_s, Style if (acw_s & 0xC00000) { WinSet, Style, -0xC40000 WinMove, , , 0, 0, %A_ScreenWidth%, %A_ScreenHeight% } else { WinSet, Style, +0xC40000 } } returnAs you can see, I made it work only on maximized active windows. I still have one problem: I have vertical taskbar on the left side of screen. Some applications, when made fullscreen using this script, offset their main menu popup menus horizontally to avoid the taskbar (even though it isn't visible as it is covered by the fullscreen window).
I tried to hide the taskbar, however that didn't help. Any ideas?
#13
-
Posted 04 January 2008 - 11:34 AM
I landed up with the following code after checking this topic and Winsupermaximize
Now, I would like to modify the code in such a manner that, when the hotkey is pressed, the title bar of all open windows and any window that may be opened later will have the titlebar hidden..
And again when the hotkey is pressed, titlebar of all the windows are shown as usual.
Thanks in advance
#SingleInstance ignore #`::TitleGo() TitleGo() { global WinActive("A") WinGet, winId, ID if (isTitleGone_%winId% = 1) { WinSet, Style, +0x800000 isTitleGone_%winId% = 0 } else { WinSet, Style, -0x800000 isTitleGone_%winId% = 1 } }
Now, I would like to modify the code in such a manner that, when the hotkey is pressed, the title bar of all open windows and any window that may be opened later will have the titlebar hidden..
And again when the hotkey is pressed, titlebar of all the windows are shown as usual.
Thanks in advance
#14
-
Posted 15 May 2009 - 10:15 AM