Launch an application under all available apps

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
zortanmax
Posts: 32
Joined: 15 Jan 2019, 08:25

Launch an application under all available apps

31 Jan 2019, 18:44

Hi
How can I open a window from the beginning under the rest of active windows.

I used like this:
Run, Notepad
WinSet, Bottom, , test for bottom - Notepad

But When the notepad opens, it will first open as active window and then goes below.
Can we write two commands in a row?
;I am a beginner in
Autokey?
{
HotKey??
AutoHotKey
}
return
gregster
Posts: 9068
Joined: 30 Sep 2013, 06:48

Re: Launch an application under all available apps

31 Jan 2019, 19:43

This works for notepad:

Code: Select all

Run, Notepad, , min
But:
https://autohotkey.com/docs/commands/Run.htm wrote:Note: Some applications (e.g. Calc.exe) do not obey the requested startup state and thus Max/Min/Hide will have no effect.
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Launch an application under all available apps

31 Jan 2019, 20:20

Hi zortanmax,

Code: Select all

SW_SHOWNOACTIVATE := 4 ; Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except that the window is not activated.
; https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-showwindow

!n::
	DetectHiddenWindows, On
	Run, notepad,, Hide, PID ; run notepad initially hidden and stores the program's unique Process ID (PID) in the variable 'PID'
	WinWait, ahk_pid %PID% ; waits until the specified window exists (here we use the PID as matching criterion)
	; If a matching window comes into existence, the command 'WinWait' will update the 'Last Found Window' - that is, teh window to operate on by default when all four window parameters of window commands and functions are omitted - like below:
	WinSet, Bottom
	lastFoundWindow := WinExist()
	; WinExist checks if a matching window exists. If it is, WinExist() returns the Unique ID (HWND) of the first matching window
	; since we've omitted all four parameters it will return the ID of the 'Last Found Window', yet we need the window ID for the 'ShowWindow' API function above
	DllCall("ShowWindow", "Ptr", lastFoundWindow, "Int", SW_SHOWNOACTIVATE)
return

The note quoted by gregster applies with this version too.
my scripts
zortanmax
Posts: 32
Joined: 15 Jan 2019, 08:25

Re: Launch an application under all available apps

01 Feb 2019, 05:20

gregster wrote:
31 Jan 2019, 19:43
This works for notepad:

Code: Select all

Run, Notepad, , min
But:
https://autohotkey.com/docs/commands/Run.htm wrote:Note: Some applications (e.g. Calc.exe) do not obey the requested startup state and thus Max/Min/Hide will have no effect.
Thanks gregster
It works fine for Notepad, but what to do for other programs like Firefox ?
I didn't get anything from your link
;I am a beginner in
Autokey?
{
HotKey??
AutoHotKey
}
return
zortanmax
Posts: 32
Joined: 15 Jan 2019, 08:25

Re: Launch an application under all available apps

01 Feb 2019, 05:33

A_AhkUser wrote:
31 Jan 2019, 20:20
Hi zortanmax,

Code: Select all

SW_SHOWNOACTIVATE := 4 ; Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except that the window is not activated.
; https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-showwindow

!n::
	DetectHiddenWindows, On
	Run, notepad,, Hide, PID ; run notepad initially hidden and stores the program's unique Process ID (PID) in the variable 'PID'
	WinWait, ahk_pid %PID% ; waits until the specified window exists (here we use the PID as matching criterion)
	; If a matching window comes into existence, the command 'WinWait' will update the 'Last Found Window' - that is, teh window to operate on by default when all four window parameters of window commands and functions are omitted - like below:
	WinSet, Bottom
	lastFoundWindow := WinExist()
	; WinExist checks if a matching window exists. If it is, WinExist() returns the Unique ID (HWND) of the first matching window
	; since we've omitted all four parameters it will return the ID of the 'Last Found Window', yet we need the window ID for the 'ShowWindow' API function above
	DllCall("ShowWindow", "Ptr", lastFoundWindow, "Int", SW_SHOWNOACTIVATE)
return

The note quoted by gregster applies with this version too.
Thank you too A_AhkUser
But your code will not run for a program like Firefox. :(
;I am a beginner in
Autokey?
{
HotKey??
AutoHotKey
}
return
gregster
Posts: 9068
Joined: 30 Sep 2013, 06:48

Re: Launch an application under all available apps

01 Feb 2019, 05:44

Depends on the program - some just won't obey...🤷‍♂️

Some programs have command line options for starting minimized, but for Firefox it doesn't look good with this option, it seems. What I find on the internet, doesn't seem to work either (at least not anymore - it might have worked with older versions).
So this might be a good question for the Mozilla Firefox forums...
zortanmax
Posts: 32
Joined: 15 Jan 2019, 08:25

Re: Launch an application under all available apps

01 Feb 2019, 16:08

gregster wrote:
01 Feb 2019, 05:44
Depends on the program - some just won't obey...🤷‍♂️
Thank you for your time gregster
;I am a beginner in
Autokey?
{
HotKey??
AutoHotKey
}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: sanmaodo, ymnaren and 132 guests