Hi all,
I am completely new ao AHK and would very much appreciate some help.
Often I have 30 notepad.exe or chrome open on my computer.
I would like a script which would find all the notepad.exe or perhaps a maximum number of them and tile them over all available monitors.
The reason for this is that I would then close the ones I dont want and not save them but you can see which ones you can close straight away.
I would also like to do it with chrome.
Can anyone offer a script for this please?
Your help is much appreciated, I tried searching the forums but couldnt find something.
Many thanks in advance.
Newman
Tiling notepad.exe
Re: Tiling notepad.exe
Right click your task bar and choose "windows side by side", Viola..
Re: Tiling notepad.exe
I only ever use one monitor, however it may be that this script can be adapted to multiple monitors.
If anyone has written similar scripts to this, please share a link. Cheers.
If anyone has written similar scripts to this, please share a link. Cheers.
Code: Select all
q:: ;tile Notepad/Chrome windows
DetectHiddenWindows, Off
WinGet, vWinList, List
vList := "", vCount := 0
Loop, % vWinList
{
hWnd := vWinList%A_Index%
;WinGetClass, vWinClass, % "ahk_id " hWnd
WinGet, vPName, ProcessName, % "ahk_id " hWnd
;if (vPName = "notepad.exe")
;if (vPName = "chrome.exe")
if RegExMatch(vPName, "^(notepad.exe|chrome.exe)$")
vList .= hWnd "`n", vCount += 1
}
vList := SubStr(vList, 1, -1)
Loop
{
vNum := A_Index
if (vCount <= vNum**2)
break
}
WinGetPos,,,, vTaskbarH, ahk_class Shell_TrayWnd
vWinW := A_ScreenWidth / vNum
;vWinH := A_ScreenHeight / vNum
vWinH := (A_ScreenHeight-vTaskbarH) / vNum
vX := 0, vY := 0
oArray := StrSplit(vList, "`n")
Loop, Parse, vList, `n
{
;hWnd := oArray[A_Index]
hWnd := oArray[oArray.Length()+1-A_Index]
vWinX := vX*vWinW
vWinY := vY*vWinH
WinMove, % "ahk_id " hWnd,, % vWinX, % vWinY, % vWinW, % vWinH
vX++
if (vX = vNum)
vX := 0, vY += 1
}
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Tiling notepad.exe
It was running a bit slower than I expected, and it turns out that the script pauses for 100 milliseconds after each WinMove based on SetWinDelay, so I've amended the script, setting the delay to 0 temporarily.
There are one or two other slight changes: activating each window, and actuating the original window at the end, but only if it was a Notepad/Chrome window.
[1900th post]
There are one or two other slight changes: activating each window, and actuating the original window at the end, but only if it was a Notepad/Chrome window.
Code: Select all
q:: ;tile Notepad/Chrome windows
DetectHiddenWindows, Off
WinGet, hWnd2, ID, A
hWnd3 := 0
WinGet, vWinList, List
vList := "", vCount := 0
Loop, % vWinList
{
hWnd := vWinList%A_Index%
if (hWnd = hWnd2)
hWnd3 := hWnd2
;WinGetClass, vWinClass, % "ahk_id " hWnd
WinGet, vPName, ProcessName, % "ahk_id " hWnd
;if (vPName = "notepad.exe")
;if (vPName = "chrome.exe")
if RegExMatch(vPName, "^(notepad.exe|chrome.exe)$")
vList .= hWnd "`n", vCount += 1
}
vList := SubStr(vList, 1, -1)
Loop
{
vNum := A_Index
if (vCount <= vNum**2)
break
}
WinGetPos,,,, vTaskbarH, ahk_class Shell_TrayWnd
vWinW := A_ScreenWidth / vNum
;vWinH := A_ScreenHeight / vNum
vWinH := (A_ScreenHeight-vTaskbarH) / vNum
vX := 0, vY := 0
oArray := StrSplit(vList, "`n")
vWD := A_WinDelay
SetWinDelay, 0
Loop, % oArray.Length()
{
;hWnd := oArray[A_Index]
hWnd := oArray[oArray.Length()+1-A_Index]
vWinX := vX*vWinW
vWinY := vY*vWinH
;WinSet, Top,, % "ahk_id " hWnd
;WinShow, % "ahk_id " hWnd
WinActivate, % "ahk_id " hWnd
;WinSet, AlwaysOnTop, Toggle, % "ahk_id " hWnd
WinMove, % "ahk_id " hWnd,, % vWinX, % vWinY, % vWinW, % vWinH
;WinSet, AlwaysOnTop, Toggle, % "ahk_id " hWnd
vX++
if (vX = vNum)
vX := 0, vY += 1
}
SetWinDelay, % vWD
if hWnd3
WinActivate, % "ahk_id " hWnd3
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Tiling notepad.exe
jeeswg wrote: [...] [1900th post]
Who is online
Users browsing this forum: Bing [Bot], peter_ahk and 162 guests