Home > VPet-Simulator > VPet-Simulator AHK script to remove the window from the ALT-Tab list

VPet-Simulator AHK script to remove the window from the ALT-Tab list

I keep accidentally tabbing into the vpet window instead of the application I want to, I figured since its always on top it doesn’t need an alt tab entry.

How it works:

The script modifies the window type into a palette window which by default doesnt have an alt-tab entry.
To use it:

  • Launch the script using autohotkey
  • Press CTRL+ALT+F12 while the vpet is the focused window
  • You can now safely exit the script from your system tray

Also useful to know that you can toggle it back on with the same keyboard shortcut

The script:

; Initialize an empty object to store window data
data := {}

; Define the hotkey Ctrl + Alt + F12
^!f12::
  ; Get the ID of the active window
  WinGet, hw, ID, A

  ; Check if the window ID is valid and not 0
  if ((hw != "") && (hw != 0)) {
    ; Check if the window data exists for this window ID
    if (data[hw]) {
      ; If window data exists, remove the specified extended style from the window
      WinSet, ExStyle, % data[hw], ahk_id %hw%
      data.Delete(hw) ; Remove the window data entry
    } else {
      ; If no window data exists, get the current extended style of the window
      WinGet, es, ExStyle, ahk_id %hw%
      ; Store the current extended style in the data object
      data[hw] := es
      ; Add a specific extended style (0x80) to the window's extended style
      WinSet, ExStyle, % (es | 0x80), ahk_id %hw%
    }
  }
return ; End of the hotkey subroutine

Further explanation:

The WinSet function is used to modify various window attributes. In this script, it’s primarily used to manipulate the extended style of windows. The extended style (ExStyle) of a window controls various visual aspects and behaviors. By toggling the extended style value using the | (bitwise OR) operator, the script can add or remove specific attributes from the window’s ExStyle, effectively changing its appearance or behavior.

Extended styles are a set of attributes that control various visual and behavioral aspects of a window. These styles can be manipulated using the `ExStyle` parameter of the `WinSet` function in AutoHotkey. In this script, the `winset exstyle` command is used to add or remove the extended style associated with the value `0x80` from the window’s existing extended style.

The specific extended style being manipulated here, `0x80`, corresponds to the `WS_EX_TOOLWINDOW` style. This style affects how the window is displayed in the taskbar and Alt+Tab switcher.

`WS_EX_TOOLWINDOW` (0x80):

  • This style makes a window a tool window, which means it won’t appear in the Alt+Tab switcher by default.
  • Tool windows are intended for auxiliary dialogs or floating tool palettes that should not appear in the taskbar or Alt+Tab list.
  • By adding this style to a window, you’re essentially hiding it from the Alt+Tab list.

In summary, the script uses the `WinSet` function to toggle the `WS_EX_TOOLWINDOW` extended style on and off for a specified window, effectively controlling whether that window appears in the Alt+Tab switcher or not. When the script adds this style to a window’s extended style, the window is hidden from the Alt+Tab list, and when the style is removed, the window reappears in the Alt+Tab list.

Source for the awesome code is here: reddit

Written by April

Leave a Comment