How to start a program and hide it immediately?
-
- Posts: 16
- Joined: 22 Feb 2023, 11:28
How to start a program and hide it immediately?
I want a specific chrome window to start with windows start, and I already know hot to do that, but I also want the window to start already hidden, without autohotkey having to wait for the title to load, so is there a way to start a chrome window (or any other program) with some kind of attribute to make it hidden?
Re: How to start a program and hide it immediately?
If I'm reading the help docs correctly, this should work:
It doesn't seem to be starting minimized though....
Code: Select all
#Requires AutoHotkey v2+
;Note space before webpage.
target := "C:\Program Files\Google\Chrome\Application\chrome.exe" " https://www.autohotkey.com/docs/v2/lib/Run.htm"
Run target,, "Min"
ste(phen|ve) kunkel
Re: How to start a program and hide it immediately?
FYI, this:
...is the same as this:
You are concatenating two literal strings with no real reason to have them separated with two pairs of quotation marks. If you want to have quotes as part of the strings, which is recommended for the Run function in case there are spaces in the paths (although these have no spaces), then you need quotes inside your quoted string like this:
To see the differences/lack of differences:
Code: Select all
target := "C:\Program Files\Google\Chrome\Application\chrome.exe" " https://www.autohotkey.com/docs/v2/lib/Run.htm"
Code: Select all
target := "C:\Program Files\Google\Chrome\Application\chrome.exe https://www.autohotkey.com/docs/v2/lib/Run.htm"
You are concatenating two literal strings with no real reason to have them separated with two pairs of quotation marks. If you want to have quotes as part of the strings, which is recommended for the Run function in case there are spaces in the paths (although these have no spaces), then you need quotes inside your quoted string like this:
Code: Select all
target := '"C:\Program Files\Google\Chrome\Application\chrome.exe" "https://www.autohotkey.com/docs/v2/lib/Run.htm"'
To see the differences/lack of differences:
Code: Select all
#Requires AutoHotkey v2.0
target1 := "C:\Program Files\Google\Chrome\Application\chrome.exe" " https://www.autohotkey.com/docs/v2/lib/Run.htm"
target2 := "C:\Program Files\Google\Chrome\Application\chrome.exe https://www.autohotkey.com/docs/v2/lib/Run.htm"
target3 := '"C:\Program Files\Google\Chrome\Application\chrome.exe" "https://www.autohotkey.com/docs/v2/lib/Run.htm"'
MyGui := Gui()
MyGui.SetFont('s12','Consolas')
MyGui.Add('Text',, target1 '`n' target2 '`n' target3)
MyGui.Show
Re: How to start a program and hide it immediately?
Very nice!boiler wrote: ↑18 Apr 2024, 16:49....To see the differences/lack of differences:Code: Select all
#Requires AutoHotkey v2.0 target1 := "C:\Program Files\Google\Chrome\Application\chrome.exe" " https://www.autohotkey.com/docs/v2/lib/Run.htm" target2 := "C:\Program Files\Google\Chrome\Application\chrome.exe https://www.autohotkey.com/docs/v2/lib/Run.htm" target3 := '"C:\Program Files\Google\Chrome\Application\chrome.exe" "https://www.autohotkey.com/docs/v2/lib/Run.htm"' MyGui := Gui() MyGui.SetFont('s12','Consolas') MyGui.Add('Text',, target1 '`n' target2 '`n' target3) MyGui.Show
Any thoughts on why the "Min" option isn't working?
ste(phen|ve) kunkel
- Noitalommi_2
- Posts: 331
- Joined: 16 Aug 2023, 10:58
Re: How to start a program and hide it immediately?
Hi.
@kunkel321
The Min option doesn't seem to work when Chrome was previously closed as maximized window.
@kunkel321
The Min option doesn't seem to work when Chrome was previously closed as maximized window.
- Noitalommi_2
- Posts: 331
- Joined: 16 Aug 2023, 10:58
Re: How to start a program and hide it immediately?
@Super Foxy
This hides the Chrome window but you have to wait until the window exists.
It didn't work for me without WainWait.
Alternatively, without waiting, you could launch the Chrome window outside of the visible screen area.
This hides the Chrome window but you have to wait until the window exists.
It didn't work for me without WainWait.
Code: Select all
Run("Chrome.exe",,,&pid)
WinWait("ahk_pid" pid)
WinHide
Sleep 1000
WinShow
Code: Select all
F1:: {
global pid
Run("Chrome.exe --window-position=0," A_ScreenHeight+100,,,&pid)
}
F2::WinMove(0, 0,,, "ahk_pid" pid)
Who is online
Users browsing this forum: No registered users and 62 guests