geekhack

geekhack Community => Other Geeky Stuff => Topic started by: esoomenona on Tue, 04 March 2014, 14:03:17

Title: .
Post by: esoomenona on Tue, 04 March 2014, 14:03:17
.
Title: Re: AHK Possibility? Any help would be appreciated
Post by: N1ne on Tue, 04 March 2014, 20:45:06
I wrote a small application in AutoIt (don't know ahk) to try and help you out.

Basically what it does is send alt down and up as if the numpad dot key was the alt key but it also checks when you release numpad dot if it was held for less than 150 ms (basically a tap) it will send the numpad dot character.

Limitations are you can't hold the dot button to type many dots in a row, other than that it's pretty good.

It may have difficulty with extremely fast usage of alt as a modifier (if you can hit alt as a modifier and the key that you would like to apply it to then release them in under 150ms it will apply alt to the keypress but it will also send the . character)

Code: [Select]
Local $hDLL = DllOpen("user32.dll")

HotKeySet("{NUMPADDOT}", "captureDot")

;Capture NUMPADDOT so the character is only sent when we want it to be.
Func captureDot()
EndFunc

While 1
If _IsPressed("6E", $hDLL) Then
;ConsoleWrite("_IsPressed - Numpad Dot was pressed." & @CRLF) ;debug line
;Simulate ALT down immediately.
Send("{ALT down}")
$presstime = TimerInit()

; Wait until key is released.
While _IsPressed("6E", $hDLL)
Sleep(10)
WEnd

; After key is released check how long it was held, if under 150ms send NUMPADDOT.
Send("{ALT up}")
If TimerDiff($presstime) < 150 Then
HotKeySet("{NUMPADDOT}")
Send("{NUMPADDOT}")
HotKeySet("{NUMPADDOT}", "captureDot")
EndIf

;ConsoleWrite("_IsPressed - Numpad Dot was released. " & TimerDiff($presstime) & @CRLF) ;debug line

;ExitLoop
EndIf
WEnd

Let me know if you need help getting it going, I can also compile it down to an exe if needed.
Title: Re: AHK Possibility? Any help would be appreciated
Post by: angelic_sedition on Wed, 05 March 2014, 01:27:22
Have you seen this thread: http://geekhack.org/index.php?topic=41685.0
and this: https://github.com/lydell/dual
?

I think this is the functionality you are looking for.
Title: Re: AHK Possibility? Any help would be appreciated
Post by: N1ne on Wed, 05 March 2014, 01:43:22
Have you seen this thread: http://geekhack.org/index.php?topic=41685.0
and this: https://github.com/lydell/dual
?

I think this is the functionality you are looking for.

I should have known something so useful would have been created before!!

These are probably more feature rich implementations of the code above, hopefully it's still insightful for someone who wants to know how it works and it can pretty much be dropped in to any AutoIt project and modified to suit other keys.

Incidentally I can write any creative hotkey/key replacement/modifier edit you can think of within the bounds of current computer capabilities so if anyone else wants something bespoke just shoot me a message.