Jump to content

Recommended Posts

Posted

here you go....  :bye:

#include<Misc.au3>
#include <Timers.au3>

Global $o_ClickCnt = 0

__ExampleA()
Func __ExampleA()
    HotKeySet("a", "__ButtonClick")
    HotKeySet("{ESC}", "__Quit")
    MsgBox(0, "", "Start clicking button 'A'" & @CRLF & _
                  "and Esc to exit")

    Local $iIdleTime
    Local $Xflag = False
    Local $o_ClickTime = 160        ;<<<<<<<< speed adjust

    While 1
        If ($o_ClickCnt = 1) Then
            $iIdleTime = _Timer_GetIdleTime()
            $Xflag = True
        Endif

        If ($Xflag) And ($iIdleTime > $o_ClickTime) Then
            ConsoleWrite("+  Single Key Press ......" & @CRLF)
            $o_ClickCnt = 0
            $Xflag = False
        Endif

        Sleep(10)
    WEnd
EndFunc

Func __ButtonClick()
    Local Static $o_Flag = False
    If $o_Flag Then Return
    $o_Flag = True

    Local Static $o_DClickTimer
    Local $o_ClickTime = 160        ;<<<<<<<< speed adjust
    Local $o_GetTime
    Local $o_GetDCTime
    Local $o_Timer = TimerInit()

    $o_GetDCTime = int(TimerDiff($o_DClickTimer))
    While _IsPressed('41')
        Sleep(10)
    WEnd

    $o_GetTime = int(TimerDiff($o_Timer))
    If ($o_GetTime > $o_ClickTime) And ($o_ClickCnt = 0) Then
        ConsoleWrite("-  Long Key Press......" & @CRLF)
        $o_Flag = False
        Return
    EndIf

    If ($o_GetDCTime <= $o_ClickTime) And ($o_ClickCnt > 0) Then
        ConsoleWrite(">  Double Key Press ......" & @CRLF)
        $o_ClickCnt = 0
        $o_Flag = False
        Return
    EndIf

    $o_ClickCnt += 1
    $o_DClickTimer = TimerInit()
    $o_Flag = False
EndFunc

Func __Quit()
    Exit
EndFunc

 

  • 2 years later...
Posted (edited)
On 3/26/2020 at 3:09 PM, Nine said:

Streamlined on @Deye's idea :

That is working for all letters :)

ps.  I copy @hotkeypressed into $char at the beginning to avoid conflict with another hot key.

Yes, I know it's an old thread, but what can I do, I need this script and it almost works.

Just changed some Sleep, added console output:

#include <Misc.au3>
#include <MsgBoxConstants.au3>

Global Const $hDLL = DllOpen("user32.dll")
Global Const $sList = "abcdefghijklmnopqrstuvwxyz"
Global Const $aList = StringSplit($sList,"",$STR_NOCOUNT)
Global $bTreat = False

OnAutoItExitRegister (_Bye)

HotKeySet ("{ESC}", _Exit)
For $c in $aList
  HotKeySet ($c,_Alpha)
Next

While True
  Sleep (10)
WEnd

Func _Alpha()
  If $bTreat Then Return
  $bTreat = True
  Local Const $iStart = Asc ("a"), $iVK = Dec("41"), $char = @HotKeyPressed
  Local $sVK = Hex(Asc($char) - $iStart + $iVK,2), $iCount = 0
  HotKeySet (@HotKeyPressed)
  While _IsPressed($sVK, $hDLL)
    $iCount += 1
    Sleep (10)
  WEnd
  ConsoleWrite($iCount*10 & " ms.")
  Send ($iCount > 3 ? StringUpper($char) : $char)
  HotKeySet ($char, _Alpha)
  $bTreat = False
EndFunc

Func _Exit ()
  Exit
EndFunc

Func _Bye ()
  DllClose ($hDLL)
EndFunc

Now the problem.

Here's a sample output

Quote

H40 ms.h20 ms.h30 ms.h30 ms.h30 ms.H40 ms.hhhhhhhhhhhhhhhhhhhhhH600 ms.h30 ms.H50 ms.H50 ms.H40 ms.H40 ms.H40 ms.H50 ms.h30 ms.h30 ms.h30 ms.H40 ms.H50 ms.H50 ms.H50 ms.h30 ms.H40 ms.hhhhhhhhhhhhhhhH490 ms.

This was all done with CAPS off.

Single / quick press = upper letter most of the times.

Long press = a row of lower case + last letter upper.

I just need the script to pass the lettrs exactly (upper / lower). The count (long/short press) is working just fine for me.

Thanks.

Edited by queensoft

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...