How NOT to display AHK icon on the taskbar when script is running?
On this screenshot the script is running, and AHK icon is displayed by default in the taskbar, thus intercepting a focus (when you are playing a fullscreen game, for example).
Is there any way NOT to display it?
Is there any way for AHK NOT to intercept focus, so that the PC will not throw me out of the game?
Thanks.
How NOT to display AHK icon on the taskbar when script is running?
-
- Posts: 26
- Joined: 07 Mar 2024, 06:50
Re: How NOT to display AHK icon on the taskbar when script is running?
Disables the showing of a tray icon.
Source: #NoTrayIcon - Syntax & Usage | AutoHotkey v2
Re: How NOT to display AHK icon on the taskbar when script is running?
The taskbar button can be hidden by using the ToolWindow option for GUIs:
The owner option could be another solution:
Code: Select all
MyGui.Opt("+ToolWindow")
https://www.autohotkey.com/docs/v2/lib/Gui.htm#Opt wrote:ToolWindow: Provides a narrower title bar but the window will have no taskbar button. This always hides the maximize and minimize buttons, regardless of whether the WS_MAXIMIZEBOX and WS_MINIMIZEBOX styles are present.
The owner option could be another solution:
Code: Select all
MyGui.Opt("+Owner") ; Make the GUI owned by the script's main window to prevent display of a taskbar button.
Re: How NOT to display AHK icon on the taskbar when script is running?
An example is below.
Code: Select all
#Requires AutoHotkey v2.0
F3:: {
If '' = t := getTimerInterval()
ToolTip
Else ToolTip '===> ' t ' <==='
}
getTimerInterval() {
g := Gui('+ToolWindow', 'Timer'), g.SetFont('s10')
g.AddText , 'Set timer interval (in minutes)'
ed := g.AddEdit('w300')
g.AddButton('w300 Default', 'OK').OnEvent('Click', (btn, info) => (txt := ed.Text, btn.Gui.Destroy()))
g.OnEvent('Escape', (gui) => gui.Destroy())
g.OnEvent('Close' , (gui) => gui.Destroy())
txt := '', g.Show()
WinWaitClose g
Return txt
}
Re: How NOT to display AHK icon on the taskbar when script is running?
Please press F5 to open the window.
I'm not sure if there's a better trick, but I did my best...
No matter how much I think about it, using MyGui.Opt("+Owner") seems like a cleaner approach.
(To ensure that the ownership relationship of the window remains unchanged, refer to my second example using OnMessage.)
I'm not sure if there's a better trick, but I did my best...
No matter how much I think about it, using MyGui.Opt("+Owner") seems like a cleaner approach.
(To ensure that the ownership relationship of the window remains unchanged, refer to my second example using OnMessage.)
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance
myGui:=gui("+AlwaysOnTop +Owner")
myEdit:=myGui.Add("Edit", "w300 r10")
F5:: {
myGui.show("NoActivate")
}
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance
onMessage(0x0201,WM_LBUTTONDOWN)
onMessage(0x00A1,WM_NCLBUTTONDOWN)
myGui:=gui("+AlwaysOnTop +E" WS_EX_NOACTIVATE:=0x08000000)
myEdit:=myGui.Add("Edit", "w300 r10")
F5:: {
myGui.show("NoActivate")
}
WM_LBUTTONDOWN(wParam, lParam, Msg, hWnd) {
static GA_ROOT:=2
switch (rootWnd:=dllCall("User32.dll\GetAncestor", "Ptr",hWnd, "UInt",GA_ROOT, "Ptr"))
{
case myGui.Hwnd:
if (dllCall("User32.dll\GetForegroundWindow", "Ptr")!==rootWnd)
dllCall("User32.dll\SetForegroundWindow", "Ptr",rootWnd, "Ptr")
}
}
WM_NCLBUTTONDOWN(wParam, lParam, Msg, hWnd) {
switch (hWnd)
{
case myGui.Hwnd:
if (dllCall("User32.dll\GetForegroundWindow", "Ptr")!==hWnd)
dllCall("User32.dll\SetForegroundWindow", "Ptr",hWnd, "Ptr")
}
}
- English is not my native language. Please forgive any awkward expressions.
- 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.