0

What I want to do is create a script that allows me to disable the effect of the PgDn or PgDn keys while it waits (so it doesn't instantaneously capture the hotkey so there's no override), while not having any effect on the program in that wait duration.

Example scenario: In the 3 seconds that the PgDn key must be held down to activate a (say) MsgBox, it must not cause a browser window, etc. To accept the PgDn input. That is I don't want my webpage scrolling down while I'm pressing down the PgDn key.

This is my code so far.

~PgDn::
If PgDnIsPressed
return

PgDnIsPressed := true
SetTimer, WaitForRelease, 3000
return

~PgDn Up::
SetTimer, WaitForRelease, Off
PgDnIsPressed := false
return

WaitForRelease:
SetTimer, WaitForRelease, Off
msgbox Working
return 

It works, but not without scrolling the webpage in any way.

EDIT: I also ran the following registry script to disable the action of the PgDn and PgUp keys:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,00,00,49,e0,00,00,51,e0,00,00,00,00

But now it seems like AHK too won't accept PgDn and PgUp keys, even if Windows won't.

The idea is to only let AHK get the input.

  • Remove the ~ from each hotkey. Anyway, I don't think your script is optimal in most cases. Can you elaborate on what you're trying to achieve? – MCL Feb 18 '14 at 13:54
0

The following code will allow you to do what you described:

hotkey, $pgDn, keyDelayer
hotkey, $pgUp, keyDelayer

keyDelayer:
    sleep 3000
    thisHotkey := regExReplace(a_thisHotkey, "[^0-9A-Za-z]")
    while getKeyState(thisHotkey, "p")
        send {%thisHotkey%}
return

If PgDn or PgUp is held for under three seconds, nothing happens. Once PgDn or PgUp is held for three seconds, the key begins repeatedly sending itself until it is released.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.