Jump to content

IsPressed_UDF ! v2.3 | Advanced keypress


FireFox
 Share

Recommended Posts

I ment there are things like "Left MENU" and "Right Menu".. MENU, Menu. It's a difference.

Hum....ok this isnt very important for me...but i will fix it :)

@AlmarM

My results :

Generating random numbers.. Done.
Doing test A.. Done.
Doing test B.. Done.
Doing test C.. Done.

Results:
Test A: 10767.1671091271
Test B: 10746.4060246911
Test C: 16560.3291530244
Link to comment
Share on other sites

Added new function _GetKeyByHex with string Split :) ...

Seems to be particular dramatic or I've done mistake :

----------SHORT TEST----------
Generating random numbers...Done !
Doing test A...Done ! Result : 1.06979 sec(s)
Doing test B...Done ! Result : 0.24735 sec(s)
Doing test C...Done ! Result : 4.47162 sec(s)

----------LONG TEST----------
Generating random numbers...Done !
Doing test A...Done ! Result : 10.7112 sec(s)
Doing test B...Done ! Result : 2.56738 sec(s)
Doing test C...Done ! Result : 45.3638 sec(s)

#Region short test
ConsoleWrite(@CRLF & "----------SHORT TEST----------")
Global $numtest = 10000
_Test()
#EndRegion short test

Func _longtest()
    #Region long test
    ConsoleWrite(@CRLF & @CRLF & "----------LONG TEST----------")
    Global $numtest = 100000
    _Test()
    #EndRegion long test
EndFunc   ;==>_longtest

Func _Test()
    #Region Number ------------------------------
    Local $random[$numtest]
    ConsoleWrite(@CRLF & "Generating random numbers...")

    For $i = 0 To $numtest - 1
        $random[$i] = Random(1, Dec("A5"), 1)
    Next

    ConsoleWrite("Done !" & @CRLF)
    #EndRegion Number ------------------------------

    #Region Test A ----------------------------------
    ConsoleWrite("Doing test A...")

    $testAStart = TimerInit()
    For $i = 0 To $numtest - 1
        _GetKeyByHex_Original($random[$i])
    Next
    $testAFinish = StringLeft(TimerDiff($testAStart) * 0.001, 7)

    ConsoleWrite("Done ! " & "Result : " & $testAFinish & " sec(s)" & @CRLF)
    #EndRegion Test A ----------------------------------

    #Region Test B ----------------------------------
    ConsoleWrite("Doing test B...")
    $testBStart = TimerInit()

    For $i = 0 To $numtest - 1
        _GetKeyByHex_SwitchNumber($random[$i])
    Next

    $testBFinish = StringLeft(TimerDiff($testBStart) * 0.001, 7)
    ConsoleWrite("Done ! " & "Result : " & $testBFinish & " sec(s)" & @CRLF)
    #EndRegion Test B ----------------------------------

    #Region Test C ------------------------------
    ConsoleWrite("Doing test C...")

    $testCStart = TimerInit()
    For $i = 0 To $numtest - 1
        __GetKeyTypeModified($random[$i])
    Next
    $testCFinish = StringLeft(TimerDiff($testCStart) * 0.001, 7)

    ConsoleWrite("Done ! " & "Result : " & $testCFinish & " sec(s)" & @CRLF)
    #EndRegion Test C ------------------------------

    If $numtest = 100000 Then
        Exit
    Else
        _longtest()
    EndIf
EndFunc   ;==>_Test

; #FUNCTION# ===================================================================
; Name :            Functions
; Author(s):        FireFox
;===============================================================================
Func _GetKeyByHex_Original($sHexKey)
    If $sHexKey = "01" Then Return "LeftMouse"
    If $sHexKey = "02" Then Return "RightMouse"
    If $sHexKey = "04" Then Return "MiddleMouse"
    If $sHexKey = "05" Then Return "X1Mouse"
    If $sHexKey = "06" Then Return "X2Mouse"
    If $sHexKey = "08" Then Return "BACKSPACE"
    If $sHexKey = "09" Then Return "TAB"
    If $sHexKey = "0C" Then Return "CLEAR"
    If $sHexKey = "0D" Then Return "ENTER"
    If $sHexKey = "10" Then Return "SHIFT"
    If $sHexKey = "11" Then Return "CTRL"
    If $sHexKey = "12" Then Return "ALT"
    If $sHexKey = "13" Then Return "PAUSE"
    If $sHexKey = "14" Then Return "CAPSLOCK"
    If $sHexKey = "1B" Then Return "ESC"
    If $sHexKey = "20" Then Return "SPACEBAR"
    If $sHexKey = "21" Then Return "PAGE UP"
    If $sHexKey = "22" Then Return "PAGE DOWN"
    If $sHexKey = "23" Then Return "END"
    If $sHexKey = "24" Then Return "HOME"
    If $sHexKey = "25" Then Return "LEFT"
    If $sHexKey = "26" Then Return "UP"
    If $sHexKey = "27" Then Return "RIGHT"
    If $sHexKey = "28" Then Return "DOWN"
    If $sHexKey = "29" Then Return "SELECT"
    If $sHexKey = "2A" Then Return "PRINT"
    If $sHexKey = "2B" Then Return "EXECUTE"
    If $sHexKey = "2C" Then Return "PRINT SCREEN"
    If $sHexKey = "2D" Then Return "INS"
    If $sHexKey = "2E" Then Return "DEL"
    If $sHexKey = "30" Then Return "0"
    If $sHexKey = "31" Then Return "1"
    If $sHexKey = "32" Then Return "2"
    If $sHexKey = "33" Then Return "3"
    If $sHexKey = "34" Then Return "4"
    If $sHexKey = "35" Then Return "5"
    If $sHexKey = "36" Then Return "6"
    If $sHexKey = "37" Then Return "7"
    If $sHexKey = "38" Then Return "8"
    If $sHexKey = "39" Then Return "9"
    If $sHexKey = "41" Then Return "A"
    If $sHexKey = "42" Then Return "B"
    If $sHexKey = "43" Then Return "C"
    If $sHexKey = "44" Then Return "D"
    If $sHexKey = "45" Then Return "E"
    If $sHexKey = "46" Then Return "F"
    If $sHexKey = "47" Then Return "G"
    If $sHexKey = "48" Then Return "H"
    If $sHexKey = "49" Then Return "I"
    If $sHexKey = "4A" Then Return "J"
    If $sHexKey = "4B" Then Return "K"
    If $sHexKey = "4C" Then Return "L"
    If $sHexKey = "4D" Then Return "M"
    If $sHexKey = "4E" Then Return "N"
    If $sHexKey = "4F" Then Return "O"
    If $sHexKey = "50" Then Return "P"
    If $sHexKey = "51" Then Return "Q"
    If $sHexKey = "52" Then Return "R"
    If $sHexKey = "53" Then Return "S"
    If $sHexKey = "54" Then Return "T"
    If $sHexKey = "55" Then Return "U"
    If $sHexKey = "56" Then Return "V"
    If $sHexKey = "57" Then Return "W"
    If $sHexKey = "58" Then Return "X"
    If $sHexKey = "59" Then Return "Y"
    If $sHexKey = "5A" Then Return "Z"
    If $sHexKey = "5B" Then Return "LWin"
    If $sHexKey = "5C" Then Return "RWin"
    If $sHexKey = "60" Then Return "0'"
    If $sHexKey = "61" Then Return "1'"
    If $sHexKey = "62" Then Return "2'"
    If $sHexKey = "63" Then Return "3'"
    If $sHexKey = "64" Then Return "4'"
    If $sHexKey = "65" Then Return "5'"
    If $sHexKey = "66" Then Return "6'"
    If $sHexKey = "67" Then Return "7'"
    If $sHexKey = "68" Then Return "8'"
    If $sHexKey = "69" Then Return "9'"
    If $sHexKey = "6A" Then Return "Multiply"
    If $sHexKey = "6B" Then Return "Add"
    If $sHexKey = "6C" Then Return "Separator"
    If $sHexKey = "6D" Then Return "Subtract"
    If $sHexKey = "6E" Then Return "Decimal"
    If $sHexKey = "6F" Then Return "Divide"
    If $sHexKey = "70" Then Return "F1"
    If $sHexKey = "71" Then Return "F2"
    If $sHexKey = "72" Then Return "F3"
    If $sHexKey = "73" Then Return "F4"
    If $sHexKey = "74" Then Return "F5"
    If $sHexKey = "75" Then Return "F6"
    If $sHexKey = "76" Then Return "F7"
    If $sHexKey = "77" Then Return "F8"
    If $sHexKey = "78" Then Return "F9"
    If $sHexKey = "79" Then Return "F10"
    If $sHexKey = "7A" Then Return "F11"
    If $sHexKey = "7B" Then Return "F12"
    If $sHexKey = "7C" Then Return "F13"
    If $sHexKey = "7F" Then Return "F16"
    If $sHexKey = "90" Then Return "NUM LOCK"
    If $sHexKey = "91" Then Return "SCROLL LOCK"
    If $sHexKey = "A0" Then Return "LSHIFT"
    If $sHexKey = "A1" Then Return "RSHIFT"
    If $sHexKey = "A2" Then Return "LCTRL"
    If $sHexKey = "A3" Then Return "RCTRL"
    If $sHexKey = "A4" Then Return "LMENU"
    If $sHexKey = "A5" Then Return "RMENU"
    If $sHexKey = "" Then Return -1
    Return -1
EndFunc   ;==>_GetKeyByHex_Original

Func _GetKeyByHex_SwitchNumber($sHexKey)
    $sHexKey = Dec($sHexKey)
    Switch $sHexKey
        Case 1
            Return "LeftMouse"
        Case 2
            Return "RightMouse"
        Case 4
            Return "MiddleMouse"
        Case 5
            Return "X1Mouse"
        Case 6
            Return "X2Mouse"
        Case 8
            Return "BACKSPACE"
        Case 9
            Return "TAB"
        Case 12
            Return "CLEAR"
        Case 13
            Return "ENTER"
        Case 16
            Return "SHIFT"
        Case 17
            Return "CTRL"
        Case 18
            Return "ALT"
        Case 19
            Return "PAUSE"
        Case 20
            Return "CAPSLOCK"
        Case 27
            Return "ESC"
        Case 32
            Return "SPACEBAR"
        Case 33
            Return "PAGE UP"
        Case 34
            Return "PAGE DOWN"
        Case 35
            Return "END"
        Case 36
            Return "HOME"
        Case 37
            Return "LEFT"
        Case 38
            Return "UP"
        Case 39
            Return "RIGHT"
        Case 40
            Return "DOWN"
        Case 41
            Return "SELECT"
        Case 42
            Return "PRINT"
        Case 43
            Return "EXECUTE"
        Case 44
            Return "PRINT SCREEN"
        Case 45
            Return "INS"
        Case 46
            Return "DEL"
        Case 48
            Return "0"
        Case 49
            Return "1"
        Case 50
            Return "2"
        Case 51
            Return "3"
        Case 52
            Return "4"
        Case 53
            Return "5"
        Case 54
            Return "6"
        Case 55
            Return "7"
        Case 56
            Return "8"
        Case 57
            Return "9"
        Case 65
            Return "A"
        Case 66
            Return "B"
        Case 67
            Return "C"
        Case 68
            Return "D"
        Case 69
            Return "E"
        Case 70
            Return "F"
        Case 71
            Return "G"
        Case 72
            Return "H"
        Case 73
            Return "I"
        Case 74
            Return "J"
        Case 75
            Return "K"
        Case 76
            Return "L"
        Case 77
            Return "M"
        Case 78
            Return "N"
        Case 79
            Return "O"
        Case 80
            Return "P"
        Case 81
            Return "Q"
        Case 82
            Return "R"
        Case 83
            Return "S"
        Case 84
            Return "T"
        Case 85
            Return "U"
        Case 86
            Return "V"
        Case 87
            Return "W"
        Case 88
            Return "X"
        Case 89
            Return "Y"
        Case 90
            Return "Z"
        Case 91
            Return "LWin"
        Case 92
            Return "RWin"
        Case 96
            Return "0'"
        Case 97
            Return "1'"
        Case 98
            Return "2'"
        Case 99
            Return "3'"
        Case 100
            Return "4'"
        Case 101
            Return "5'"
        Case 102
            Return "6'"
        Case 103
            Return "7'"
        Case 104
            Return "8'"
        Case 105
            Return "9'"
        Case 106
            Return "Multiply"
        Case 107
            Return "Add"
        Case 108
            Return "Separator"
        Case 109
            Return "Subtract"
        Case 110
            Return "Decimal"
        Case 111
            Return "Divide"
        Case 112
            Return "F1"
        Case 113
            Return "F2"
        Case 114
            Return "F3"
        Case 115
            Return "F4"
        Case 116
            Return "F5"
        Case 117
            Return "F6"
        Case 118
            Return "F7"
        Case 119
            Return "F8"
        Case 120
            Return "F9"
        Case 121
            Return "F10"
        Case 122
            Return "F11"
        Case 123
            Return "F12"
        Case 124
            Return "F13"
        Case 127
            Return "F16"
        Case 144
            Return "NUM LOCK"
        Case 145
            Return "SCROLL LOCK"
        Case 160
            Return "LSHIFT"
        Case 161
            Return "RSHIFT"
        Case 162
            Return "LCTRL"
        Case 163
            Return "RCTRL"
        Case 164
            Return "LMENU"
        Case 165
            Return "RMENU"
    EndSwitch
    Return -1
EndFunc   ;==>_GetKeyByHex_SwitchNumber


; #FUNCTION# ===================================================================
; Name :               __GetKeyType
; Description:      Returns Hexadecimal or Aplha key for specified key
; Parameter(s):     None
; Requirement(s):   None
; Return Value(s):  On Success - Returns Key
;                   On Failure - Returns 0
; Author(s):        Valuater, FireFox
; Note(s):          Thanks Valuater... 8)
;===============================================================================
Func __GetKeyTypeModified($iKeyIn)
    If $iKeyIn = "" Then Return -1

    Local $ikey, $hKey = "01,02,04,05,06,08,09,0C,0D,10,11,12,13,14,1B," & _
            "20,21,22,23,24,25,26,27,28,29,2A,2B,2C,2D,2E,30,31,32,33,34,35,36," & _
            "37,38,39,41,42,43,44,45,46,47,48,49,4A,4B,4C,4D,4E,4F,50,51,52,53," & _
            "54,55,56,57,58,59,5A,5B,5C,60,61,62,63,64,65,66,67,68,69,6A,6B,6C," & _
            "6D,6E,6F,70,71,72,73,74,75,76,77,78,79,7A,7B,7C,7D,7E,7F,80H,81H," & _
            "82H,83H,84H,85H,86H,87H,90,91,A0,A1,A2,A3,A4,A5"
    Local $nKey = "LeftMouse,RightMouse,MiddleMouse,X1Mouse,X2Mouse," & _
            "BACKSPACE,TAB,CLEAR,ENTER,SHIFT,CTRL,ALT,PAUSE,CAPS LOCK,ESC," & _
            "SPACEBAR,PAGE UP,PAGE DOWN,END,HOME,LEFT,UP,RIGHT,DOWN,SELECT," & _
            "PRINT,EXECUTE,PRINT SCREEN,INS,DEL,0,1,2,3,4,5,6,7,8,9,A,B,C," & _
            "D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Left Windows," & _
            "Right Windows,Num 0,Num 1,Num 2,Num 3,Num 4,Num 5,Num 6,Num 7," & _
            "Num 8,Num 9,Multiply,Add,Separator,Subtract,Decimal,Divide," & _
            "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18," & _
            "F19,F20,F21,F22,F23,F24,NUM LOCK,SCROLL LOCK,Left SHIFT,Right SHIFT," & _
            "Left CTRL,Right CTRL,Left MENU,Right Menu"
    
    $hKey = StringSplit($hKey, ",")
    $nKey = StringSplit($nKey, ",")

    For $ikey = 1 To $hKey[0]
        If $iKeyIn = $hKey[$ikey] Then Return $nKey[$ikey]
    Next

    Return -1
EndFunc   ;==>__GetKeyTypeModified
Edited by FireFox
Link to comment
Share on other sites

Added new function _GetKeyByHex with string Split :) ...

Seems to be particular dramatic or I've done mistake :

Generating random numbers...Done !
 Doing test A...Done ! Result : 10691.9477540843
 Doing test B...Done ! Result : 16487.128355161
 Doing test C...Done ! Result : 67119.4343435665
I'm getting about the same:

Generating random numbers...Done !

Doing test A...Done ! Result : 11749.6195745549

Doing test B...Done ! Result : 18855.157848274

Doing test C...Done ! Result : 75209.2257535525

StringSplit is slow compared to doing normal Switch statements (obviously). I don't know who ever thought of using it..

Edit: All of these tests are dumb. More than one variable changes during tests and they blame it on things that have nothing to do with it completely. I think we need to stop this, before anyone gets hurt.

Edited by Manadar
Link to comment
Share on other sites

:)

----------SHORT TEST----------
  Generating random numbers...Done !
  Doing test A...Done ! Result : 2.87393 sec(s)
  Doing test B...Done ! Result : 0.60042 sec(s)
  Doing test C...Done ! Result : 1.49647 sec(s)
  
  
  ----------LONG TEST----------
  Generating random numbers...Done !
  Doing test A...Done ! Result : 28.0482 sec(s)
  Doing test B...Done ! Result : 6.56867 sec(s)
  Doing test C...Done ! Result : 16.4629 sec(s)

#Region short test
ConsoleWrite(@CRLF & "----------SHORT TEST----------")
Global $numtest = 10000
_Test()
#EndRegion short test

Func _longtest()
    #Region long test
    ConsoleWrite(@CRLF & @CRLF & "----------LONG TEST----------")
    Global $numtest = 100000
    _Test()
    #EndRegion long test
EndFunc   ;==>_longtest

Func _Test()
    #Region Number ------------------------------
    Local $random[$numtest]
    ConsoleWrite(@CRLF & "Generating random numbers...")

    For $i = 0 To $numtest - 1
        $random[$i] = Random(1, Dec("A5"), 1)
    Next

    ConsoleWrite("Done !" & @CRLF)
    #EndRegion Number ------------------------------

    #Region Test A ----------------------------------
    ConsoleWrite("Doing test A...")

    $testAStart = TimerInit()
    For $i = 0 To $numtest - 1
        _GetKeyByHex_Original($random[$i])
    Next
    $testAFinish = StringLeft(TimerDiff($testAStart) * 0.001, 7)

    ConsoleWrite("Done ! " & "Result : " & $testAFinish & " sec(s)" & @CRLF)
    #EndRegion Test A ----------------------------------

    #Region Test B ----------------------------------
    ConsoleWrite("Doing test B...")
    $testBStart = TimerInit()

    For $i = 0 To $numtest - 1
        _GetKeyByHex_SwitchNumber($random[$i])
    Next

    $testBFinish = StringLeft(TimerDiff($testBStart) * 0.001, 7)
    ConsoleWrite("Done ! " & "Result : " & $testBFinish & " sec(s)" & @CRLF)
    #EndRegion Test B ----------------------------------

    #Region Test C ------------------------------
    ConsoleWrite("Doing test C...")

    $testCStart = TimerInit()
    For $i = 0 To $numtest - 1
        __GetKeyType($random[$i])
    Next
    $testCFinish = StringLeft(TimerDiff($testCStart) * 0.001, 7)

    ConsoleWrite("Done ! " & "Result : " & $testCFinish & " sec(s)" & @CRLF)
    #EndRegion Test C ------------------------------
    

    If $numtest = 100000 Then
        Exit
    Else
        _longtest()
    EndIf
EndFunc   ;==>_Test

; #FUNCTION# ===================================================================
; Name :            Functions
; Author(s):        FireFox
;===============================================================================
Func _GetKeyByHex_Original($sHexKey)
    If $sHexKey = "01" Then Return "LeftMouse"
    If $sHexKey = "02" Then Return "RightMouse"
    If $sHexKey = "04" Then Return "MiddleMouse"
    If $sHexKey = "05" Then Return "X1Mouse"
    If $sHexKey = "06" Then Return "X2Mouse"
    If $sHexKey = "08" Then Return "BACKSPACE"
    If $sHexKey = "09" Then Return "TAB"
    If $sHexKey = "0C" Then Return "CLEAR"
    If $sHexKey = "0D" Then Return "ENTER"
    If $sHexKey = "10" Then Return "SHIFT"
    If $sHexKey = "11" Then Return "CTRL"
    If $sHexKey = "12" Then Return "ALT"
    If $sHexKey = "13" Then Return "PAUSE"
    If $sHexKey = "14" Then Return "CAPSLOCK"
    If $sHexKey = "1B" Then Return "ESC"
    If $sHexKey = "20" Then Return "SPACEBAR"
    If $sHexKey = "21" Then Return "PAGE UP"
    If $sHexKey = "22" Then Return "PAGE DOWN"
    If $sHexKey = "23" Then Return "END"
    If $sHexKey = "24" Then Return "HOME"
    If $sHexKey = "25" Then Return "LEFT"
    If $sHexKey = "26" Then Return "UP"
    If $sHexKey = "27" Then Return "RIGHT"
    If $sHexKey = "28" Then Return "DOWN"
    If $sHexKey = "29" Then Return "SELECT"
    If $sHexKey = "2A" Then Return "PRINT"
    If $sHexKey = "2B" Then Return "EXECUTE"
    If $sHexKey = "2C" Then Return "PRINT SCREEN"
    If $sHexKey = "2D" Then Return "INS"
    If $sHexKey = "2E" Then Return "DEL"
    If $sHexKey = "30" Then Return "0"
    If $sHexKey = "31" Then Return "1"
    If $sHexKey = "32" Then Return "2"
    If $sHexKey = "33" Then Return "3"
    If $sHexKey = "34" Then Return "4"
    If $sHexKey = "35" Then Return "5"
    If $sHexKey = "36" Then Return "6"
    If $sHexKey = "37" Then Return "7"
    If $sHexKey = "38" Then Return "8"
    If $sHexKey = "39" Then Return "9"
    If $sHexKey = "41" Then Return "A"
    If $sHexKey = "42" Then Return "B"
    If $sHexKey = "43" Then Return "C"
    If $sHexKey = "44" Then Return "D"
    If $sHexKey = "45" Then Return "E"
    If $sHexKey = "46" Then Return "F"
    If $sHexKey = "47" Then Return "G"
    If $sHexKey = "48" Then Return "H"
    If $sHexKey = "49" Then Return "I"
    If $sHexKey = "4A" Then Return "J"
    If $sHexKey = "4B" Then Return "K"
    If $sHexKey = "4C" Then Return "L"
    If $sHexKey = "4D" Then Return "M"
    If $sHexKey = "4E" Then Return "N"
    If $sHexKey = "4F" Then Return "O"
    If $sHexKey = "50" Then Return "P"
    If $sHexKey = "51" Then Return "Q"
    If $sHexKey = "52" Then Return "R"
    If $sHexKey = "53" Then Return "S"
    If $sHexKey = "54" Then Return "T"
    If $sHexKey = "55" Then Return "U"
    If $sHexKey = "56" Then Return "V"
    If $sHexKey = "57" Then Return "W"
    If $sHexKey = "58" Then Return "X"
    If $sHexKey = "59" Then Return "Y"
    If $sHexKey = "5A" Then Return "Z"
    If $sHexKey = "5B" Then Return "LWin"
    If $sHexKey = "5C" Then Return "RWin"
    If $sHexKey = "60" Then Return "0'"
    If $sHexKey = "61" Then Return "1'"
    If $sHexKey = "62" Then Return "2'"
    If $sHexKey = "63" Then Return "3'"
    If $sHexKey = "64" Then Return "4'"
    If $sHexKey = "65" Then Return "5'"
    If $sHexKey = "66" Then Return "6'"
    If $sHexKey = "67" Then Return "7'"
    If $sHexKey = "68" Then Return "8'"
    If $sHexKey = "69" Then Return "9'"
    If $sHexKey = "6A" Then Return "Multiply"
    If $sHexKey = "6B" Then Return "Add"
    If $sHexKey = "6C" Then Return "Separator"
    If $sHexKey = "6D" Then Return "Subtract"
    If $sHexKey = "6E" Then Return "Decimal"
    If $sHexKey = "6F" Then Return "Divide"
    If $sHexKey = "70" Then Return "F1"
    If $sHexKey = "71" Then Return "F2"
    If $sHexKey = "72" Then Return "F3"
    If $sHexKey = "73" Then Return "F4"
    If $sHexKey = "74" Then Return "F5"
    If $sHexKey = "75" Then Return "F6"
    If $sHexKey = "76" Then Return "F7"
    If $sHexKey = "77" Then Return "F8"
    If $sHexKey = "78" Then Return "F9"
    If $sHexKey = "79" Then Return "F10"
    If $sHexKey = "7A" Then Return "F11"
    If $sHexKey = "7B" Then Return "F12"
    If $sHexKey = "7C" Then Return "F13"
    If $sHexKey = "7F" Then Return "F16"
    If $sHexKey = "90" Then Return "NUM LOCK"
    If $sHexKey = "91" Then Return "SCROLL LOCK"
    If $sHexKey = "A0" Then Return "LSHIFT"
    If $sHexKey = "A1" Then Return "RSHIFT"
    If $sHexKey = "A2" Then Return "LCTRL"
    If $sHexKey = "A3" Then Return "RCTRL"
    If $sHexKey = "A4" Then Return "LMENU"
    If $sHexKey = "A5" Then Return "RMENU"
    If $sHexKey = "" Then Return -1
    Return -1
EndFunc   ;==>_GetKeyByHex_Original

Func _GetKeyByHex_SwitchNumber($sHexKey)
    $sHexKey = Dec($sHexKey)
    Switch $sHexKey
        Case 1
            Return "LeftMouse"
        Case 2
            Return "RightMouse"
        Case 4
            Return "MiddleMouse"
        Case 5
            Return "X1Mouse"
        Case 6
            Return "X2Mouse"
        Case 8
            Return "BACKSPACE"
        Case 9
            Return "TAB"
        Case 12
            Return "CLEAR"
        Case 13
            Return "ENTER"
        Case 16
            Return "SHIFT"
        Case 17
            Return "CTRL"
        Case 18
            Return "ALT"
        Case 19
            Return "PAUSE"
        Case 20
            Return "CAPSLOCK"
        Case 27
            Return "ESC"
        Case 32
            Return "SPACEBAR"
        Case 33
            Return "PAGE UP"
        Case 34
            Return "PAGE DOWN"
        Case 35
            Return "END"
        Case 36
            Return "HOME"
        Case 37
            Return "LEFT"
        Case 38
            Return "UP"
        Case 39
            Return "RIGHT"
        Case 40
            Return "DOWN"
        Case 41
            Return "SELECT"
        Case 42
            Return "PRINT"
        Case 43
            Return "EXECUTE"
        Case 44
            Return "PRINT SCREEN"
        Case 45
            Return "INS"
        Case 46
            Return "DEL"
        Case 48
            Return "0"
        Case 49
            Return "1"
        Case 50
            Return "2"
        Case 51
            Return "3"
        Case 52
            Return "4"
        Case 53
            Return "5"
        Case 54
            Return "6"
        Case 55
            Return "7"
        Case 56
            Return "8"
        Case 57
            Return "9"
        Case 65
            Return "A"
        Case 66
            Return "B"
        Case 67
            Return "C"
        Case 68
            Return "D"
        Case 69
            Return "E"
        Case 70
            Return "F"
        Case 71
            Return "G"
        Case 72
            Return "H"
        Case 73
            Return "I"
        Case 74
            Return "J"
        Case 75
            Return "K"
        Case 76
            Return "L"
        Case 77
            Return "M"
        Case 78
            Return "N"
        Case 79
            Return "O"
        Case 80
            Return "P"
        Case 81
            Return "Q"
        Case 82
            Return "R"
        Case 83
            Return "S"
        Case 84
            Return "T"
        Case 85
            Return "U"
        Case 86
            Return "V"
        Case 87
            Return "W"
        Case 88
            Return "X"
        Case 89
            Return "Y"
        Case 90
            Return "Z"
        Case 91
            Return "LWin"
        Case 92
            Return "RWin"
        Case 96
            Return "0'"
        Case 97
            Return "1'"
        Case 98
            Return "2'"
        Case 99
            Return "3'"
        Case 100
            Return "4'"
        Case 101
            Return "5'"
        Case 102
            Return "6'"
        Case 103
            Return "7'"
        Case 104
            Return "8'"
        Case 105
            Return "9'"
        Case 106
            Return "Multiply"
        Case 107
            Return "Add"
        Case 108
            Return "Separator"
        Case 109
            Return "Subtract"
        Case 110
            Return "Decimal"
        Case 111
            Return "Divide"
        Case 112
            Return "F1"
        Case 113
            Return "F2"
        Case 114
            Return "F3"
        Case 115
            Return "F4"
        Case 116
            Return "F5"
        Case 117
            Return "F6"
        Case 118
            Return "F7"
        Case 119
            Return "F8"
        Case 120
            Return "F9"
        Case 121
            Return "F10"
        Case 122
            Return "F11"
        Case 123
            Return "F12"
        Case 124
            Return "F13"
        Case 127
            Return "F16"
        Case 144
            Return "NUM LOCK"
        Case 145
            Return "SCROLL LOCK"
        Case 160
            Return "LSHIFT"
        Case 161
            Return "RSHIFT"
        Case 162
            Return "LCTRL"
        Case 163
            Return "RCTRL"
        Case 164
            Return "LMENU"
        Case 165
            Return "RMENU"
    EndSwitch
    Return -1
EndFunc   ;==>_GetKeyByHex_SwitchNumber


; #FUNCTION# ===================================================================
; Name :               __GetKeyType
; Description:      Returns Hexadecimal or Aplha key for specified key
; Parameter(s):     None
; Requirement(s):   None
; Return Value(s):  On Success - Returns Key
;                   On Failure - Returns 0
; Author(s):        Valuater, FireFox
; Note(s):          Thanks Valuater... 8)
;===============================================================================

Func __GetKeyType($iKeyIn)
    If $iKeyIn = "" Then Return -1
    
    Local $s_String = "01LeftMouse,02RightMouse,04MiddleMouse,05X1Mouse,06X2Mouse,08BACKSPACE,09TAB,0CCLEAR," & _
            "0DENTER,10SHIFT,11CTRL,12ALT,13PAUSE,14CAPS LOCK,1BESC,20SPACEBAR,21PAGE UP,22PAGE DOWN," & _
            "23END,24HOME,25LEFT,26UP,27RIGHT,28DOWN,29SELECT,2APRINT,2BEXECUTE,2CPRINT SCREEN,2DINS,2EDEL," & _
            "300,311,322,333,344,355,366,377,388,399,41A,42B,43C,44D,45E,46F,47G,48H,49I,4AJ,4BK,4CL,4DM,4EN

," & _
            "4FO,50P,51Q,52R,53S,54T,55U,56V,57W,58X,59Y,5AZ,5BLeft Windows,5CRight Windows,60Num 0,61Num 1," & _
            "62Num 2,63Num 3,64Num 4,65Num 5,66Num 6,67Num 7,68Num 8,69Num 9,6AMultiply,6BAdd," & _
            "6CSeparator,6DSubtract,6EDecimal,6FDivide,70F1,71F2,72F3,73F4,74F5,75F6,76F7,77F8,78F9," & _
            "79F10,7AF11,7BF12,7CF13,7DF14,7EF15,7FF16,80HF17,81HF18,82HF19,83HF20,84HF21,85HF22," & _
            "86HF23,87HF24,90NUM LOCK,91SCROLL LOCK,A0Left SHIFT,A1Right SHIFT,A2Left CTRL,A3Right CTRL," & _
            "A4Left MENU,A5Right Menu"
    
    $iKeyIn = StringInStr($s_String, $iKeyIn)+StringLen($iKeyIn)
    $s_String = StringMid($s_String, $iKeyIn, StringInStr($s_String, ",")-$iKeyIn)
    If $s_String <> "" Then Return $s_String
    Return -1
EndFunc   ;==>__GetKeyTypeModified2

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

@Valuater

"Flabbergasted" ! :)

----------SHORT TEST----------
Generating random numbers...Done !
Doing test A...Done ! Result : 1.12724 sec(s)
Doing test B...Done ! Result : 0.26904 sec(s)
Doing test C...Done ! Result : 0.68184 sec(s)


----------LONG TEST----------
Generating random numbers...Done !
Doing test A...Done ! Result : 11.1693 sec(s)
Doing test B...Done ! Result : 2.79893 sec(s)
Doing test C...Done ! Result : 7.07094 sec(s)

Not as fast as case but in few lines its better :o

Link to comment
Share on other sites

@Valuater

As Manadar said, we should stop testing functions :o

__GetKeyTypeModified2 only check for Alpha key thats why its faster :)

Edit : We should focus on create or updating existing functions :D

Edited by FireFox
Link to comment
Share on other sites

----------SHORT TEST----------
Generating random numbers...Done !
Doing test A...Done ! Result : 3.50778 sec(s)
Doing test B...Done ! Result : 0.46565 sec(s)
Doing test C...Done ! Result : 1.15116 sec(s)


----------LONG TEST----------
Generating random numbers...Done !
Doing test A...Done ! Result : 20.7352 sec(s)
Doing test B...Done ! Result : 4.42499 sec(s)
Doing test C...Done ! Result : 11.7288 sec(s)

I think nothing can tip on test B :)

AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

$Info = __GetKeyType("Right SHIFT", 1)

ConsoleWrite($Info & @CRLF)

Func __GetKeyType($iKeyIn, $Type = -1)
    If $iKeyIn = "" Then Return -1

    Local $s_String = "01LeftMouse,02RightMouse,04MiddleMouse,05X1Mouse,06X2Mouse,08BACKSPACE,09TAB,0CCLEAR," & _
            "0DENTER,10SHIFT,11CTRL,12ALT,13PAUSE,14CAPS LOCK,1BESC,20SPACEBAR,21PAGE UP,22PAGE DOWN," & _
            "23END,24HOME,25LEFT,26UP,27RIGHT,28DOWN,29SELECT,2APRINT,2BEXECUTE,2CPRINT SCREEN,2DINS,2EDEL," & _
            "300,311,322,333,344,355,366,377,388,399,41A,42B,43C,44D,45E,46F,47G,48H,49I,4AJ,4BK,4CL,4DM,4EN," &_
            "4FO,50P,51Q,52R,53S,54T,55U,56V,57W,58X,59Y,5AZ,5BLeft Windows,5CRight Windows,60Num 0,61Num 1," & _
            "62Num 2,63Num 3,64Num 4,65Num 5,66Num 6,67Num 7,68Num 8,69Num 9,6AMultiply,6BAdd," & _
            "6CSeparator,6DSubtract,6EDecimal,6FDivide,70F1,71F2,72F3,73F4,74F5,75F6,76F7,77F8,78F9," & _
            "79F10,7AF11,7BF12,7CF13,7DF14,7EF15,7FF16,80HF17,81HF18,82HF19,83HF20,84HF21,85HF22," & _
            "86HF23,87HF24,90NUM LOCK,91SCROLL LOCK,A0Left SHIFT,A1Right SHIFT,A2Left CTRL,A3Right CTRL," & _
            "A4Left MENU,A5Right Menu"
    
    If $Type == -1 Then
        $iKeyIn = StringTrimLeft($s_String, (StringInStr($s_String, $iKeyIn) + StringLen($iKeyIn) - 1))
        $s_String = StringLeft($iKeyIn, (StringInStr($iKeyIn, ",") - 1))
    Else
        $iKeyIn = StringLeft($s_String, StringInStr($s_String, $iKeyIn) - 1)
        $s_String = StringTrimLeft($iKeyIn, StringInStr($iKeyIn, ",", 2, -1))
    EndIf
    If $s_String <> "" Then Return $s_String
    Return -1
EndFunc   ;==>__GetKeyType

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

  • 2 weeks later...

@joseLB

I can post function like you say, but this would be keylogger and as mod says its forbidden thats why I keep it for me....

As mods agree so I will post this function without any 'bad think' on it, its just for good cause :)

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...