center a window of a .bat file in the center of a screen without knowing the size of the screen?
center a window of a .bat file in the center of a screen without knowing the size of the screen?
Hi,
I'm looking for an AutoHotkey script to center a window from a .bat file in the center of a screen without knowing the screen size?
If possible integrate it into the .bat
I can not find...
Does anyone have this?!
Thanks
I'm looking for an AutoHotkey script to center a window from a .bat file in the center of a screen without knowing the screen size?
If possible integrate it into the .bat
I can not find...
Does anyone have this?!
Thanks
- CoffeeChaton
- Posts: 37
- Joined: 11 May 2024, 10:50
Re: center a window of a .bat file in the center of a screen without knowing the size of the screen?
Code: Select all
cmd_win_max() {
Hwnd := WinExist("ahk_exe cmd.exe")
; ^^^^^^^^^^ use "WindowSpy.ahk" get it
if (Hwnd == 0x0) {
Return
}
aHwnd := "ahk_id " Hwnd
WinActivate, %aHwnd%
WinMaximize, %aHwnd%
WinMove, %aHwnd%, , A_ScreenWidth / 2 , A_ScreenHeight / 2 ; , W, H
}
just use https://www.autohotkey.com/docs/v1/Variables.htm#Screena screen without knowing the scree?
A_ScreenHeight and A_ScreenWidth
Specifically?center a window from a .bat file
I'm not sure what you mean.
Do you mean to adjust the windows of those files after using .bat to get a bunch of files and open them?
Re: center a window of a .bat file in the center of a screen without knowing the size of the screen?
Code: Select all
@echo off
D:\temp2\centerWindow.ahk "A"
Pause
EXIT
Code: Select all
#Requires AutoHotkey v1.1.33.11
#NoTrayIcon
If A_Args.Length()
centerWindow(A_Args[1])
ExitApp
centerWindow(winTitle) {
If WinExist(winTitle) {
WinGetPos,,, w, h
WinRestore
WinMove (A_ScreenWidth - w) / 2, (A_ScreenHeight - h) / 2
}
}
Re: center a window of a .bat file in the center of a screen without knowing the size of the screen?
Hi,
I would like to launch my "Install.bat" file and have it centered on the main monitor which does not always have the same size
Thanks
I would like to launch my "Install.bat" file and have it centered on the main monitor which does not always have the same size
Thanks
Re: center a window of a .bat file in the center of a screen without knowing the size of the screen?
You can run the script that is posted.
- CoffeeChaton
- Posts: 37
- Joined: 11 May 2024, 10:50
Re: center a window of a .bat file in the center of a screen without knowing the size of the screen?
Code: Select all
Run, % "D:\Install.bat"
cmd_win_max()
MsgBox, % "end"
cmd_win_max() {
WinWait, % "ahk_exe cmd.exe",, 3 ; 3 sec
if ErrorLevel
{
MsgBox, % "WinWait timed out"
return
}
WinGetPos, ,, w, h
WinRestore
WinMove, (A_ScreenWidth - w) / 2, (A_ScreenHeight - h) / 2
}
Re: center a window of a .bat file in the center of a screen without knowing the size of the screen?
Hi,
Thanks, this one works
1st question :
For my information, what is it for (in red)
WinWait, % "ahk_exe cmd.exe",, 3 ; 3 sec
2nd question:
Is it normal for the bat window to randomly launch a shot to the right, a shot to the left very quickly and then center itself?
Thanks, this one works
Code: Select all
Run, % "Install.bat"
cmd_win_max()
MsgBox, % "end"
cmd_win_max() {
WinWait, % "ahk_exe cmd.exe",, 3 ; 3 sec
if ErrorLevel
{
MsgBox, % "WinWait timed out"
return
}
WinGetPos, ,, w, h
WinRestore
WinMove, (A_ScreenWidth - w) / 2, (A_ScreenHeight - h) / 2
}
For my information, what is it for (in red)
WinWait, % "ahk_exe cmd.exe",, 3 ; 3 sec
2nd question:
Is it normal for the bat window to randomly launch a shot to the right, a shot to the left very quickly and then center itself?
- CoffeeChaton
- Posts: 37
- Joined: 11 May 2024, 10:50
Re: center a window of a .bat file in the center of a screen without knowing the size of the screen?
1. 1st question :
Wait up to 3 seconds. If cmd.exe does not appear within 3 seconds, I will think there is something wrong and the user needs to confirm it. https://www.autohotkey.com/docs/v1/lib/WinWait.htm
2. 2nd question:
On my computer, it .just moved the window from point A to the middle.
Wait up to 3 seconds. If cmd.exe does not appear within 3 seconds, I will think there is something wrong and the user needs to confirm it. https://www.autohotkey.com/docs/v1/lib/WinWait.htm
2. 2nd question:
On my computer, it .just moved the window from point A to the middle.
Re: center a window of a .bat file in the center of a screen without knowing the size of the screen?
Hi,
Ok good
Thanks again
Ok good
Thanks again