plankoe

u/plankoe


r/AutoHotkey•

This script forces Windows 11 to open file explorer in a new tab instead of a new window:

#Requires AutoHotkey v2.0

Persistent

ForceOneExplorerWindow()

class ForceOneExplorerWindow {

    static __New() {
        this.FirstWindow := 0
        this.hHook := 0
        this.pWinEventHook := CallbackCreate(ObjBindMethod(this, 'WinEventProc'),, 7)
        this.IgnoreWindows := Map()
    }

    static Call() {
        this.MergeWindows()
        if !this.hHook {
            this.hHook := DllCall('SetWinEventHook', 'uint', 0x8000, 'uint', 0x8002, 'ptr', 0, 'ptr', this.pWinEventHook
                                , 'uint', 0, 'uint', 0
1631

r/AutoHotkey•

Infinite scroll wheel script

Tool / Script Share

Some mice have a free-spinning mouse wheel. This script can be used to emulate that feature. When you flick the mouse wheel up or down, it will scroll infinitely in that direction. The cursor icon will change if auto-scroll is on. Auto-scroll can be stopped by pressing any button or moving the mouse. The script also increases the scroll speed if scrolled consecutively, but not fast enough to trigger auto-scroll.

#Requires AutoHotkey v2.0

*WheelUp::Scroll(-1)
*WheelDown::Scroll(1)

Scroll(Direction) {
    static scrollCount := 0, level := 1, maxLevel := 15, timeout := 350, levelTickCount := 0, lastMousePos
        , StartingShiftState := 0, scrollingState := 0, fl
10

r/AutoHotkey•

ANSI escape codes can be used to change the formatting and color of OutputDebug. I made a function (DColor), to create these codes more easily. The parameter is a list of format options separated by space. To reset the format option, call DColor without a parameter. All the options are listed in the switch-case of the function. Examples of format options:

DColor()                    ; reset format option
DColor("bold")              ; bold text
DColor("b")                 ; bold text short version
DColor("underline")         ; or DColor("u") to underline

; Remove the formatting by putting - in front
DColor("-bol
43

r/AutoHotkey•

Countdown function

Tool/Script Share

When using SetTimer with a long period, it's hard to tell when its function will be called. I wrote a function to show the remaining time in a gui. This is for AHK v2.

The function takes 3 parameters:

  • fn - function object to run when time runs out. It's the same as SetTimer's first parameter.
  • period - Integer or string. Integer period is same as SetTimer's period parameter. If period is a string, you can specify time by days, hours, minutes, and seconds by writing a number followed by d, h, m, or s in this order. Use a minus sign in front to run once.
  • CustomName - Name of the timer. If there's no CustomName, Func.Name property will be used as the timer name.

Integer peri

69


r/AutoHotkey•

Getting the caret position using A_CaretX and A_CaretY is not always reliable. Acc or UIA can be used if A_CaretX/Y is not found. Chromium apps work with Acc, but UWP apps work better with UIA. I made a function that will try to get the caret location using UIA, Acc, and the default A_CaretX/Y.

Example of showing a Menu at the caret location:

F1::
    CoordMode Menu, Screen
    GetCaret(X, Y,, H)
    Menu, MyMenu, Add, Menu Item 1, MenuHandler
    Menu, MyMenu, Add, Menu Item 2, MenuHandler
    Menu, MyMenu, Add, Menu Item 3, MenuHandler
    Menu, MyMenu, Show, % X, % Y + H
Return

MenuHandler:
    ; do something
Return

Here's the GetCaret Fun

119

r/AutoHotkey•

This script shows a gui fading in when the user logs in, with the message: Welcome back, (username).

DllCall("wtsapi32.dll\WTSRegisterSessionNotificationEx", "Ptr", 0, "Ptr", A_ScriptHwnd, "UInt", 1)
OnMessage(0x02B1, "WM_WTSSESSION_CHANGE")

WM_WTSSESSION_CHANGE(wParam, lParam) {
    static WTS_SESSION_UNLOCK := 0x8
    if (wParam = WTS_SESSION_UNLOCK) {

        ;; show an animated welcome screen on log in
        WelcomeTrayTip()
    }
}

WelcomeTrayTip() {
    static GuiCreated := 0
    static HwndWelcomeScreen
    static MonRight, MonBottom
    if !GuiCreated  {
        GuiCreated := 1
        Gui, WelcomeScreen:New, +Alwa
44

r/AutoHotkey•

It uses PixelGetColor to check if cursor is over an empty taskbar. It also works if the taskbar color is not completely solid. The variation level can be changed in the parameter of the function. Example: MouseIsOverEmptyTaskbar(10) for 10 levels of variation. The minimum is 0 and the maximum is 100. The default variation level is set to 5.

; example #If directive
#If MouseIsOverEmptyTaskbar()

    WheelUp::Volume_Up
    WheelDown::Volume_Down
    MButton::Volume_Mute
    
#If

; check if mouse is over empty taskbar
; returns 1 if true, 0 if false
MouseIsOverEmptyTaskbar(Tolerance:=5)
{
    static lx := "", ly := "", result := 0
1018

You've reached the end of this feed.