How NOT to display AHK icon on the taskbar when script is running?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
slishnevsky
Posts: 26
Joined: 07 Mar 2024, 06:50

How NOT to display AHK icon on the taskbar when script is running?

29 Mar 2024, 19:45

How NOT to display AHK icon on the taskbar when script is running?

image.png
image.png (331.41 KiB) Viewed 164 times

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.
gregster
Posts: 9035
Joined: 30 Sep 2013, 06:48

Re: How NOT to display AHK icon on the taskbar when script is running?

29 Mar 2024, 21:06

The taskbar button can be hidden by using the ToolWindow option for GUIs:

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.
User avatar
mikeyww
Posts: 26982
Joined: 09 Sep 2014, 18:38

Re: How NOT to display AHK icon on the taskbar when script is running?

29 Mar 2024, 21:23

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
}
User avatar
Seven0528
Posts: 346
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

Re: How NOT to display AHK icon on the taskbar when script is running?

29 Mar 2024, 21:46

 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.)

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")
    }
}
20240330_114724.png
20240330_114724.png (5.48 KiB) Viewed 127 times
  • English is not my native language. Please forgive any awkward expressions.
  • 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: No registered users and 33 guests