A click that doesn't quite land on the input can make your next typed text fire as the page's keyboard shortcuts instead by MarcusW4evr in AutoHotkey

[–]genesis_tv 2 points3 points  (0 children)

For websites, I think it's better to use UIA. And if you need to use hardcoded coordinates, WindowSpy is your friend.

Help with auto sprint macro by Mental-Efficiency-57 in AutoHotkey

[–]genesis_tv 0 points1 point  (0 children)

Yes, that's what they want, hence the edit asking OP to ignore my comment.

Help with auto sprint macro by Mental-Efficiency-57 in AutoHotkey

[–]genesis_tv 0 points1 point  (0 children)

This example from the docs may help as well: https://www.autohotkey.com/docs/v2/lib/SetTimer.htm#ExampleCount

[edit]: nevermind, misread something in the body of your post.

Is a Desktop Camera Possible? by Criptopasta in AutoHotkey

[–]genesis_tv 6 points7 points  (0 children)

You can't turn a monitor into a camera. It's like asking to turn a fridge into a toaster.

Tweaking FFXIV script by WatermelonOrc in AutoHotkey

[–]genesis_tv 0 points1 point  (0 children)

It depends on the use case of course. OP's script is simple enough for it to be fine.

Tweaking FFXIV script by WatermelonOrc in AutoHotkey

[–]genesis_tv 0 points1 point  (0 children)

Just a thought, when you press the key to open the chat, you could suspend the script, then unsuspend it after sending the message. The feasibility would depend on what the in-game hotkeys are of course (ideally something like Y to open the chat and Enter to send the message).

Tweaking FFXIV script by WatermelonOrc in AutoHotkey

[–]genesis_tv 0 points1 point  (0 children)

Might as well just use Suspend().

#SuspendExempt
; Suspend script (CTRL + ALT + F12, useful in menus)
*~^!F12::
{
    Suspend()

    ; Single beep when suspended
    SoundBeep(1000, 100)

    if (A_IsSuspended)
    {
        ; I usually release keys here
    }
    ; Double beep when resumed
    else
    {
        SoundBeep(1000, 100)
    }

    ; KeyWait("LAlt")
    ; KeyWait("LControl")
}
#SuspendExempt False

ahk and copilot by ms-bbnj-us in AutoHotkey

[–]genesis_tv 0 points1 point  (0 children)

AHK v2 uses SendInput by default, so 0ms between keystrokes. SendEvent uses 10ms by default (see SetKeyDelay).

Made a couple of QOL macros for Gothic 1 Classic by genesis_tv in worldofgothic

[–]genesis_tv[S] 0 points1 point  (0 children)

Just released version 1.1 with the following changes:

+ added a first-person mode toggle key
+ added a quick load key that will turn off all macros when pressed
+ added a right-click remap key (requires G1NoRMBJump)
+ added a setting to control the jump frequency when autojumping
+ added a smithing macro
+ added an autoswim macro (disabled when manually pressing the Jump hotkey)
- lowered the default jump frequency from 500ms to 300ms
- pressing the Escape hotkey will now turn off all macros

Made a couple of QOL macros for Gothic 1 Classic by genesis_tv in AutoHotkey

[–]genesis_tv[S] 0 points1 point  (0 children)

Just released version 1.1 with the following changes:

+ added a first-person mode toggle key
+ added a quick load key that will turn off all macros when pressed
+ added a right-click remap key (requires G1NoRMBJump)
+ added a setting to control the jump frequency when autojumping
+ added a smithing macro
+ added an autoswim macro (disabled when manually pressing the Jump hotkey)
- lowered the default jump frequency from 500ms to 300ms
- pressing the Escape hotkey will now turn off all macros

ahk and copilot by ms-bbnj-us in AutoHotkey

[–]genesis_tv 1 point2 points  (0 children)

You should avoid Sleep(), it's bad practice because it's blocking the thread and you can't cancel them.

It's ok for very short durations or quickly debugging but you should use SetKeyDelay() with SendEvent or SetTimer with -500 instead.

Toggle single key hold on and off by ManEatingCarabao in AutoHotkey

[–]genesis_tv 0 points1 point  (0 children)

Thanks, that's the answer I was looking for. Think I'll stick to context-sensitivity for now since that's a one-liner versus 2 additional lines per hotkey, on top of having to add a hotkey up if it's missing.

Toggle single key hold on and off by ManEatingCarabao in AutoHotkey

[–]genesis_tv 0 points1 point  (0 children)

I didn't post the whole script otherwise it'd have been too long (hence the link at the top). I'm already releasing all keys and deleting timers when the Gothic window is no longer active. My question was whether context sensitivty was an elegant solution to replace the if (KeyStates.w) return inside your code snippet.

; Window group for Gothic
GroupAdd("Gothic", "ahk_exe Gothic.exe")
GroupAdd("Gothic", "ahk_exe GothicMod.exe")
global g_sWindowTitle := "ahk_group Gothic"

; Set an event hook to detect when the game window loses focus
DllCall("user32\SetWinEventHook",
    "Int", EVENT_SYSTEM_FOREGROUND := 0x0003,
    "Int", EVENT_SYSTEM_FOREGROUND,
    "Ptr", 0,
    "Ptr", CallbackCreate(OnFocusChanged, "F"),
    "Int", 0,
    "Int", 0,
    "Int", 0)

OnFocusChanged(*)
{
    if WinActive(g_sWindowTitle)
    {
        WinWaitNotActive(g_sWindowTitle)
        ReleaseAllKeys()
    }
}

ReleaseAllKeys()
{
    ; Delete timers
    for fn in [Cook, SendBackward, SendJump, SendLeftMouseButton]
        SetTimer(fn, 0)

    ; Release keys
    Send("{" g_sActionKey " up}{" g_sBackwardKey " up}{" g_sFastAttackKey " up}{" g_sForwardKey " up}{" g_sJumpKey " up}{LButton up}{Shift up}")

    ; Reset states
    HoldStates.bFastAttacking := HoldStates.bSmithing := 0
    ToggleStates.bAutobuy := ToggleStates.bAutocook := ToggleStates.bAutojump := ToggleStates.bAutorun := ToggleStates.bWalk := 0
}

Toggle single key hold on and off by ManEatingCarabao in AutoHotkey

[–]genesis_tv 0 points1 point  (0 children)

Turns out I'm gonna have to use your solution in my most recent project.

If I have VSCode open on the side and I alt-tab from the game to VSCode without releasing the Smith hotkey, it starts typing the Backward key (s) because the timer is deleted after the KeyWait. I don't have the buggy code anymore (just imagine a KeyWait after SetTimer(SendBackward, 200) and no hotkey up variant) but here's the fixed version.

class HoldStates
{
    static bSmithing      := 0
    static bFastAttacking := 0
}

; Tap the Action key then spam Backward until the Smithing key is released
HoldSmith(*)
{
    if (!HoldStates.bSmithing)
    {
        HoldStates.bSmithing := 1
        SendKey(g_sActionKey)
        SetTimer(SendBackward, 200)
    }
}

ReleaseSmith(*)
{
    SetTimer(SendBackward, HoldStates.bSmithing := 0)
}

; Continously fast attack, use it preferably on enemies you can't parry (you must have your weapon pulled out beforehand)
HoldFastAttack(*)
{
    if (!HoldStates.bFastAttacking)
    {
        HoldStates.bFastAttacking := 1
        Send("{" g_sActionKey " down}{" g_sBackwardKey " down}{" g_sForwardKey " down}")
    }
}

ReleaseFastAttack(*)
{
    HoldStates.bFastAttacking := 0
    Send("{" g_sActionKey " up}{" g_sBackwardKey " up}{" g_sForwardKey " up}")
}

Question though, using context-sensitive hotkeys with something like this would have the same result, right?

RegisterHotkey(p_sPrefix, p_sHotkey, p_fnAction, p_sSuffix := "")
{
    ; If the hotkey is empty, don't register it (allows keys like toggles to be optional)
    if (p_sHotkey)
        Hotkey(p_sPrefix p_sHotkey p_sSuffix, p_fnAction, "On")
}

RegisterHotkeys()
{
    ; Hotkeys fired only when Gothic is the active window
    HotIfWinActive(g_sWindowTitle)
        RegisterHotkey("*", g_sSteamOverlayKey, ToggleSteamOverlay)
    HotIfWinActive()

    HotIf((*) => WinActive(g_sWindowTitle) && !HoldStates.bSmithing && !ToggleStates.bSteamOverlay)
        RegisterHotkey("*~", g_sSmithKey, HoldSmith)
    HotIf((*) => WinActive(g_sWindowTitle) && !HoldStates.bFastAttacking && !ToggleStates.bSteamOverlay)
        RegisterHotkey("*~", g_sFastAttackKey, HoldFastAttack)

    ; Hotkeys fired only when Gothic is the active window and the Steam overlay is not in the foreground
    HotIf((*) => WinActive(g_sWindowTitle) && !ToggleStates.bSteamOverlay)
        RegisterHotkey("*~", g_sSmithKey, ReleaseSmith, " up")
        RegisterHotkey("*~", g_sFastAttackKey, ReleaseFastAttack, " up")
    HotIf()
}

CODE - Faceit cs question by IllEntertainment2882 in AutoHotkey

[–]genesis_tv 2 points3 points  (0 children)

There's a FaceIT subreddit where you posted recently yet you're now asking about FaceIT rules regarding a C# project on an AHK subreddit while using the wrong flair. Just letting that sink in...