Jump to content
Sign in to follow this  
FireFox

IsPressed_UDF ! v2.3 | Advanced keypress

Recommended Posts

FireFox

IsPressed_UDF is based on original _IsPressed function.

Description :
-This udf can detect if some keys are pressed by user on keyboard or mouse.
-IsPressed functions extend possibility to choice keys to check.
-Keys are specified in functions by their hexadecimal number,
['0D' = 'ENTER'] you can also translate hexadecimal key to alpha key (see functions and examples)

Update : [Latest: 12 Jun 2013]

Version 1.2


_GetKeyByHex ;Thanks to AlmarM for idea
_GetKeyByAlpha


Version 1.3
__KeyPressCheck ;Thanks to Valuater for function


Version 1.4
__GetKeyType ;Thanks to Valuater for function


Version 1.5
Fixed __GetKeyType *No lower case (thanks to Manadar)
*Replaced "Keypad 0-9" to "Num 0-9"

Fixed _IsFuncKeyPressed *Added F13 to F24 keys
*Extended parameters included
*$Extended = 1 then Include F13 to F24 keys

Fixed _IsSpecialKeyPressed *Removed F13 to F24 keys


Version 1.6
Modified __GetKeyType *$Type = 0 Return Alpha
1 Return Hexadecimal


Version 1.7
Modified _IsSpecialKeyPressed;now extended to DD hexadecimal key
Modified __GetKeyType;now extended to DD hexadecimal key


Version 1.8
_IsWhellKeyScroll ;Thanks to MrCreator for function


Version 1.9
Fixed _IsWhellKeyScroll;now returns False after wheel scrolled (thanks to MrCreator)
Added _IsTimeKeyPressed
Added __DLL


Version 2.0
Fixed _IsTimeKeyPressed ;now working
Removed __DLL
Added DllOpen/Close user32.dll


Version 2.1
Changed work Whell to Wheel;Thanks to Paulie
Updated _IsWheelKeyScroll to better function


Version 2.2
Fixed OnAutoItExit function in order to work with the lastest AutoIt3 version


Version 2.3
Removed _IsPressed function and added Misc include to avoid duplicate func error



Functions :


_IsAnyKeyPressed
_IsOrKeyPressed
_IsAndKeyPressed
_IsAlphaKeyPressed
_IsNumKeyPressed
_IsAlphaNumKeyPressed
_IsFuncKeyPressed
_IsArrowKeyPressed
_IsMouseKeyPressed
_IsSpecialKeyPressed
_IsWheelKeyScroll
_IsTimeKeyPressed
_GetKeyByHex
_GetKeyByAlpha


__KeyPressCheck
__GetKeyType
Include _IsPressed



Exemples :


IsAnyKeyPressed
#include <IsPressed_UDF.au3>

; #Example# ===================================================================
; Name : _IsAnyKeyPressed
; Parameter(s) : Check all keys
; Author(s): FireFox
;===============================================================================
While 1
If _IsAnyKeyPressed() Then
MsgBox(64, "_IsAnyKeyPressed", "Key pressed !", 1)
EndIf
WEnd

_IsOrKeyPressed

#include <IsPressed_UDF.au3>

; #Example# ===================================================================
; Name : _IsOrKeyPressed
; Parameter(s) : Check "ESC|ENTER|LEFT CLICK" keys
; Author(s): FireFox
;===============================================================================
While 1
If _IsOrKeyPressed("1B|0D|01") Then
MsgBox(64, "_IsOrKeyPressed", "Key pressed !", 1)
EndIf
WEnd

_IsAndKeyPressed

#include <IsPressed_UDF.au3>

; #Example# ===================================================================
; Name : _IsAndKeyPressed
; Parameter(s) : Check "CTRL|ALT|DEL" keys
; Author(s): FireFox
;===============================================================================
While 1
If _IsAndKeyPressed("11|12|2E") Then
MsgBox(64, "_IsAndKeyPressed", "Key pressed !", 1)
EndIf
WEnd

_IsAlphaKeyPressed

#include <IsPressed_UDF.au3>

; #Example# ===================================================================
; Name : _IsAlphaKeyPressed
; Parameter(s) : Check "Alpha" keys
; Author(s): FireFox
;===============================================================================
While 1
If _IsAlphaKeyPressed() Then
MsgBox(64, "_IsAlphaKeyPressed", "Key pressed !", 1)
EndIf
WEnd

_IsNumKeyPressed

#include <IsPressed_UDF.au3>

; #Example# ===================================================================
; Name : _IsNumKeyPressed
; Parameter(s) : Check "Numeric" keys
; Author(s): FireFox
;===============================================================================
While 1
If _IsNumKeyPressed() Then
MsgBox(64, "_IsNumKeyPressed", "Key pressed !", 1)
EndIf
WEnd

_IsAlphaNumKeyPressed

#include <IsPressed_UDF.au3>

; #Example# ===================================================================
; Name : _IsAlphaNumKeyPressed
; Parameter(s) : Check "Alpha" and "Numeric" keys
; Author(s): FireFox
;===============================================================================
While 1
If _IsAlphaNumKeyPressed() Then
MsgBox(64, "_IsNumKeyPressed", "Key pressed !", 1)
EndIf
WEnd

_IsFuncKeyPressed

#include <IsPressed_UDF.au3>

; #Example# ===================================================================
; Name : _IsFuncKeyPressed
; Parameter(s) : Check "functions" keys
; Author(s): FireFox
;===============================================================================
While 1
If _IsFuncKeyPressed() Then
MsgBox(64, "_IsFuncKeyPressed", "Key pressed !", 1)
EndIf
WEnd

_IsArrowKeyPressed

#include <IsPressed_UDF.au3>

; #Example# ===================================================================
; Name : _IsArrowKeyPressed
; Parameter(s) : Check "arrow" keys
; Author(s): FireFox
;===============================================================================
While 1
If _IsArrowKeyPressed() Then
MsgBox(64, "_IsArrowKeyPressed", "Key pressed !", 1)
EndIf
WEnd

_IsMouseKeyPressed

#include <IsPressed_UDF.au3>

; #Example# ===================================================================
; Name : _IsMouseKeyPressed
; Parameter(s) : Check "mouse" keys
; Author(s): FireFox
;===============================================================================
While 1
If _IsMouseKeyPressed() Then
MsgBox(64, "_IsMouseKeyPressed", "Key pressed !", 1)
EndIf
WEnd

_IsSpecialKeyPressed

#include <IsPressed_UDF.au3>

; #Example# ===================================================================
; Name : _IsSpecialKeyPressed
; Parameter(s) : Check "special" keys
; Author(s): FireFox
;===============================================================================
While 1
If _IsSpecialKeyPressed() Then
MsgBox(64, "_IsSpecialKeyPressed", "Key pressed !", 1)
EndIf
WEnd

__GetKeyType

#include <IsPressed_UDF.au3>

; #Example# ===================================================================
; Name : _GetKeyType
; Parameter(s) : Return Hexadecimal key of specified alpha key
; Author(s): FireFox
;===============================================================================
MsgBox(64,"__GetKeyType",__GetKeyType("ESC",1))

While 1
If _IsOrKeyPressed(__GetKeyType("ESC",1)) Then
MsgBox(64,"__GetKeyByType","Key pressed !", 1)
EndIf
WEnd
#include <IsPressed_UDF.au3>

; #Example# ===================================================================
; Name : __GetKeyType
; Parameter(s) : Return Alpha key of specified Hexadecimal key
; Author(s): FireFox
;===============================================================================

MsgBox(64,"__GetKeyType",__GetKeyType("1B",1))

_IsWhellKeyScroll

#include <IsPressed_UDF.au3>

; #Example# ===================================================================
; Name : _IsWheelKeyScroll
; Parameter(s) : Returns 1 if wheel mouse key scrolled up or down
; Author(s): MrCreator,FireFox
;===============================================================================

While 1
If _IsWheelKeyScroll() Then
MsgBox(64, "_IsWheelKeyScroll", "Key scrolled !", 1)
EndIf
WEnd

_TimeKeyPressed

#include <IsPressed_UDF.au3>

; #Example# ===================================================================
; Name : _IsTimeKeyPressed
; Parameter(s) : Check "01" time down key (leftmouse)
; Author(s): FireFox
;===============================================================================

While 1
$key = _IsTimeKeyPressed("01")
If $key <> -1 Then TrayTip('_IsTimeKeyPressed', $key, 2, 4)
WEnd

IsPressed_UDF 2.3 : IsPressed_UDF.au3
IsPressed_UDF 2.2 : IsPressed_UDF.au3

Add IsPressed_UDF functions to SciTE : IsPressed_Function

Enjoy !
:)

Edited by FireFox
  • Like 1

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
AlmarM

Wauw, I think this realy is some usefull stuff man.. Great job :)

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.

Share this post


Link to post
Share on other sites
FireFox

@AlmarM

Thanks for your support ! I will add some functions like not hexadecimal key for example user tape "ENTER" instead of "0D" this will work :)

FireFox

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
AlmarM

You could use another func for that '_GetKeyByHex' or something, just replace the params :)

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.

Share this post


Link to post
Share on other sites
Valuater

Created an Internal UDF

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
FireFox

Created an Internal UDF

8)

Thanks Valuater ! Updated version 1.3 :)

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
jvanegmond

Instead of using ...

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"

Do a Switch command. They're much faster for these types of statements.

and .. I may be wrong on this, but theoretically if you would convert $sHexKey to a number first, and compare it to other numbers, it would be much faster. ( Numbers compare faster than strings.)

Also, thanks for mentioning my name for something that unimportant.

Edited by Manadar

Share this post


Link to post
Share on other sites
FireFox

Instead of using ...

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"

Do a Switch command. They're much faster for these types of statements.

and .. I may be wrong on this, but theoretically if you would convert $sHexKey to a number first, and compare it to other numbers, it would be much faster. ( Numbers compare faster than strings.)

Examples are welcome !

Also, thanks for mentioning my name for something that unimportant.

No problem :)

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
jvanegmond

Examples are welcome !

I thought you were going to say that... 8)

[autoit]; Generates a bunch of random numbers to perform the tests with

Dim $numtest = 100000

Dim $random[$numtest]

ConsoleWrite("Generating random numbers.. ")

For $i = 0 to $numtest-1

$random[$i] = Random(1, Dec("A5"),1)

Next

ConsoleWrite("Done." & @CRLF)

ConsoleWrite("Doing test A.. ")

$testAStart = TimerInit()

For $i = 0 to $numtest-1

_GetKeyByHex_Original($random[$i])

Next

$testAFinish = TimerDiff($testAStart)

ConsoleWrite("Done." & @CRLF)

ConsoleWrite("Doing test B.. ")

$testBStart = TimerInit()

For $i = 0 to $numtest-1

_GetKeyByHex_Original($random[$i])

Next

$testBFinish = TimerDiff($testBStart)

ConsoleWrite("Done." & @CRLF & @CRLF)

ConsoleWrite("Results:" & @CRLF)

ConsoleWrite("Test A: " & $testAFinish & @CRLF)

ConsoleWrite("Test B: " & $testBFinish & @CRLF)

; #FUNCTION# ===================================================================

; Name : _GetKeyByHex

; Description: Returns Alpha key for specified Hexadecimal key

; Parameter(s): None

; Requirement(s): None

; Return Value(s): On Success - Returns Aplha Key

; On Failure - Returns -1

; Author(s): FireFox

; Note(s): Thanks to AlmarM for idea

;===============================================================================

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 = "80H" Then Return "F17"

If $sHexKey = "87H" Then Return "F24"

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_Switch($sHexKey)

Switch $sHexKey

Case "01"

Return "LeftMouse"

Case "02"

Return "RightMouse"

Case "04"

Return "MiddleMouse"

Case "05"

Return "X1Mouse"

Case "06"

Return "X2Mouse"

Case "08"

Return "BACKSPACE"

Case "09"

Return "TAB"

Case "0C"

Return "CLEAR"

Case "0D"

Return "ENTER"

Case "10"

Return "SHIFT"

Case "11"

Return "CTRL"

Case "12"

Return "ALT"

Case "13"

Return "PAUSE"

Case "14"

Return "CAPSLOCK"

Case "1B"

Return "ESC"

Case "20"

Return "SPACEBAR"

Case "21"

Return "PAGE UP"

Case "22"

Return "PAGE DOWN"

Case "23"

Return "END"

Case "24"

Return "HOME"

Case "25"

Return "LEFT"

Case "26"

Return "UP"

Case "27"

Return "RIGHT"

Case "28"

Return "DOWN"

Case "29"

Return "SELECT"

Case "2A"

Return "PRINT"

Case "2B"

Return "EXECUTE"

Case "2C"

Return "PRINT SCREEN"

Case "2D"

Return "INS"

Case "2E"

Return "DEL"

Case "30"

Return "0"

Case "31"

Return "1"

Case "32"

Return "2"

Case "33"

Return "3"

Case "34"

Return "4"

Case "35"

Return "5"

Case "36"

Return "6"

Case "37"

Return "7"

Case "38"

Return "8"

Case "39"

Return "9"

Case "41"

Return "A"

Case "42"

Return "B"

Case "43"

Return "C"

Case "44"

Return "D"

Case "45"

Return "E"

Case "46"

Return "F"

Case "47"

Return "G"

Case "48"

Return "H"

Case "49"

Return "I"

Case "4A"

Return "J"

Case "4B"

Return "K"

Case "4C"

Return "L"

Case "4D"

Return "M"

Case "4E"

Return "N"

Case "4F"

Return "O"

Case "50"

Return "P"

Case "51"

Return "Q"

Case "52"

Return "R"

Case "53"

Return "S"

Case "54"

Return "T"

Case "55"

Return "U"

Case "56"

Return "V"

Case "57"

Return "W"

Case "58"

Return "X"

Case "59"

Return "Y"

Case "5A"

Return "Z"

Case "5B"

Return "LWin"

Case "5C"

Return "RWin"

Case "60"

Return "0'"

Case "61"

Return "1'"

Case "62"

Return "2'"

Case "63"

Return "3'"

Case "64"

Return "4'"

Case "65"

Return "5'"

Case "66"

Return "6'"

Case "67"

Return "7'"

Case "68"

Return "8'"

Case "69"

Return "9'"

Case "6A"

Return "Multiply"

Case "6B"

Return "Add"

Case "6C"

Return "Separator"

Case "6D"

Return "Subtract"

Case "6E"

Return "Decimal"

Case "6F"

Return "Divide"

Case "70"

Return "F1"

Case "71"

Return "F2"

Case "72"

Return "F3"

Case "73"

Return "F4"

Case "74"

Return "F5"

Case "75"

Return "F6"

Case "76"

Return "F7"

Case "77"

Return "F8"

Case "78"

Return "F9"

Case "79"

Return "F10"

Case "7A"

Return "F11"

Case "7B"

Return "F12"

Case "7C"

Return "F13"

Case "7F"

Return "F16"

Case "80H"

Return "F17"

Case "87H"

Return "F24"

Case "90"

Return "NUM LOCK"

Case "91"

Return "SCROLL LOCK"

Case "A0"

Return "LSHIFT"

Case "A1"

Return "RSHIFT"

Case "A2"

Return "LCTRL"

Case "A3"

Return "RCTRL"

Case "A4"

Return "LMENU"

Case "A5"

Return "RMENU"

EndSwitch

Return -1

EndFunc ;==>_GetKeyByHex_Switch

Edited by Manadar

Share this post


Link to post
Share on other sites
jvanegmond

What I did find in your code that's not right is this:

Helpfile:

7C-7F F13 key - F16 key
80H-87H F17 key - F24 key

This means that:

7C = F13

7D = F14

7E = F15

7F = F16

and the same holds true for 80H to 87H ..

You only check for the first and last, and not those in between.

Share this post


Link to post
Share on other sites
Valuater

Maybe....

; #FUNCTION# ===================================================================
; Name :             _GetKeyByHex
; Description:      Returns Alpha key for specified Hexadecimal key
; Parameter(s):     None
; Requirement(s):   None
; Return Value(s):  On Success - Returns Aplha Key
;                   On Failure - Returns -1
; Author(s):        FireFox
; Note(s):            Thanks to AlmarM for idea
;===============================================================================
Func _GetKeyByHex($sHexKey)
    Return __GetKeyType($sHexKey)
EndFunc   ;==>_GetKeyByHex

; #FUNCTION# ===================================================================
; Name :             _GetKeyByAlpha
; Description:      Returns Hexadecimal key for specified Alpha key
; Parameter(s):     None
; Requirement(s):   None
; Return Value(s):  On Success - Returns Hexadecimal Key
;                   On Failure - Returns 0
; Author(s):        FireFox
; Note(s):            Thanks to AlmarM for idea
;===============================================================================
Func _GetKeyByAlpha($sAlphaKey)
    Return __GetKeyType($sAlphaKey, 1)
EndFunc   ;==>_GetKeyByAlpha


Func __GetKeyType($iKeyIn, $iType = -1)
    
    If $iKeyIn = "" Then Return -1
    
    Local $ikey, $hKey = "01,02,04,05,06" & _
            "continued" ; example
    Local $nKey = "LeftMouse,RightMouse,MiddleMouse,X1Mouse,X2Mouse" & _
            "continued" ; example
    
    $hKey = StringSplit($hKey, ",")
    $nKey = StringSplit($nKey, ",")

    For $ikey = 1 To $hKey[0]
        If $iType == -1 And $iKeyIn = $hKey[$ikey] Then Return $nKey[$ikey]
        If $iType <> -1 And $iKeyIn = $nKey[$ikey] Then Return $hKey[$ikey]
    Next
    
    Return -1
EndFunc   ;==>__GetKeyType

if it is speed you want, this can be split into 2 different loops

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
FireFox

@Manadar

Thanks for your example

Generating random numbers.. Done.
   Doing test A.. Done.
   Doing test B.. Done.
   
   Results:
   Test A: 10789.901169566
   Test B: 10782.8232672745

Seems to be almost same speed on my computer :)

@Valuater

Thanks too for your example I think I will add it to udf :o

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
FireFox

Updated version 1.4 with __GetKeyType function by Valuater and done by me :)


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
FireFox

@SoftVoile

For each function I say what it returns so what is it for and you have many examples :)

I will try to add more descriptions if you want.

FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
jvanegmond

You have an extra spacebar here for no reason:

"Right CTRL, Left MENU,Right Menu"

in front of Left MENU.

Also, use proper (consistent) capitalizing. There are still some people who do their checks case-sensitive.

Don't think I'm nitpicking, I want this to be the best it can.

Share this post


Link to post
Share on other sites
FireFox

@Manadar

"Right CTRL, Left MENU,Right Menu"

Thanks, I will fix it :)

Also, use proper (consistent) capitalizing.

??

Don't think I'm nitpicking, I want this to be the best it can.

Thanks for your support i agree with you dont worry :o

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
FireFox

IsPressed_UDF 1.5 Availiable ! (various beug fixed : see first post)


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
jvanegmond

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

Share this post


Link to post
Share on other sites
AlmarM

I actualy tried it with a 'Select, Case'... Results are dramatic :P

; Generates a bunch of random numbers to perform the tests with

Dim $numtest = 100000

Dim $random[$numtest]

ConsoleWrite("Generating random numbers.. ")

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

ConsoleWrite("Done." & @CRLF)

ConsoleWrite("Doing test A.. ")

$testAStart = TimerInit()
For $i = 0 to $numtest-1
    _GetKeyByHex_Original($random[$i])
Next
$testAFinish = TimerDiff($testAStart)

ConsoleWrite("Done." & @CRLF)

ConsoleWrite("Doing test B.. ")

$testBStart = TimerInit()
For $i = 0 to $numtest-1
    _GetKeyByHex_Original($random[$i])
Next
$testBFinish = TimerDiff($testBStart)

ConsoleWrite("Done." & @CRLF)

ConsoleWrite("Doing test C.. ")

$testCStart = TimerInit()
For $i = 0 to $numtest-1
    _GetKeyByHex_Select($random[$i])
Next
$testCFinish = TimerDiff($testCStart)

ConsoleWrite("Done." & @CRLF & @CRLF)

ConsoleWrite("Results:" & @CRLF)

ConsoleWrite("Test A: " & $testAFinish & @CRLF)
ConsoleWrite("Test B: " & $testBFinish & @CRLF)
ConsoleWrite("Test C: " & $testCFinish & @CRLF)


; #FUNCTION# ===================================================================
; Name :             _GetKeyByHex
; Description:      Returns Alpha key for specified Hexadecimal key
; Parameter(s):     None
; Requirement(s):   None
; Return Value(s):  On Success - Returns Aplha Key
;                   On Failure - Returns -1
; Author(s):        FireFox
; Note(s):      Thanks to AlmarM for idea
;===============================================================================

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

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_Switch

Result

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

Results:
Test A: 20308.6193915707
Test B: 18904.5141212081
Test C: 25406.7145405352

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.

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • caramen
      By caramen
      I am trying to record a ClipGet after Ctrl + C Is stroke.
      Not working. It is possible ? 
      While (1) $msg = GUIGetMsg () Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch Local $hDLL = DllOpen("user32.dll") If _IsPressed ("A2",$hDLL) And _IsPressed ("56",$hDLL) Then Sleep (500) $ClipBoard = ClipGet () ;~ ==========================================Console============================================ _GUICtrlListView_AddItem($ConsoleArea,""&$ClipBoard) _GUICtrlListView_EnsureVisible($ConsoleArea, _GUICtrlListView_GetItemCount($ConsoleArea)-1) ;~ =========================================/Console============================================ EndIf DllClose ($hDLL) WEnd  
    • WoodGrain
      By WoodGrain
      Hi guys,
      I'm learning about GUI's, I'm trying the below code, the idea being if I press the letter "e" while I have the GUI open I want the label color to change to green (I'm using a UDF for label colors). But every time I press "e" on my keyboard I just get a "ding" sound from my speakers and nothing changes with the label.
      I've looked at using something like "While GUIGetMsg() <> $GUI_EVENT_CLOSE" as I've seen it in other code instead of "While 1", but I don't think it's relevant.
      #include <GUIConstantsEx.au3>; for GUI... #include <GUIRichLabel.au3>; UDF for rich text label fonts #include <Misc.au3>; for _IsPressed $myLetter = "e" $hGUI = GUICreate("test", 700, 60) $lbl2 = _GUICtrlRichLabel_Create($hGUI, '<font color="purple">' & $myLetter & '</font>', 10, 10); , 260, 25 GUISetState(@SW_SHOW) Local $hDLL = DllOpen("user32.dll") While 1 if _IsPressed(Hex($myLetter), $hDLL) Then While _IsPressed(Hex($myLetter), $hDLL) Sleep(250) WEnd _GUICtrlRichLabel_SetData($lbl2, '<font color="green">' & $myLetter & '</font>') Sleep(2000) DllClose($hDLL) Exit EndIf Sleep(50) WEnd DllClose($hDLL) I am using an array of letters that I'm wanting to do this for, but as I can't get it to work I've stripped it down to the simplest code I can think of to try and get this working first. Appreciate any help.
      Thanks!
    • WoodGrain
      By WoodGrain
      Hi All,
      I've bought a Ergodox EZ programmable keyboard with layers of key maps (eg, layer 0 = dvorak, layer 1 = numberpad & nav, layer 2 = qwerty, etc), I've also got a small USB screen that can pull information from the registry. What I would like to determine is a way to pull the value of each current key from the keyboard, I can then write the values to the registry and pull them into my USB screen so I can see the keyboard key layout.
      I'm stuck with retrieving the key values, I've looked at _IsPressed(), _WinAPI_GetKeyState(), _WinAPI_GetKeyboardState(), _WinAPI_GetKeyboardType(), _WinAPI_GetKeyNameText(), but none of them appear to be able to pull the keyboard key values without user interaction.
      The idea being, in pseudo code, bear in mind no error checking etc in this code, "GetKeyValue()" is what I'm needing help with and is a made up function, as is "HardwareKey1" etc:
      $keyOnePrev = "" $numOfKeys = 76 While 1 $keyOneCurrent = GetKeyValue(HardwareKey1) If $keyOneCurrent <> $keyOnePrev Then For $key = 1 To $numOfKeys $keyToWrite = GetKeyValue(HardwareKey & $key) RegWrite("HKEY_CURRENT_USER\Software\myKeyboard", "key" & $key, "REG_SZ", $keyToWrite) Next EndIf $keyOnePrev = $keyOneCurrent Sleep(5000) WEnd Thanks guys!
    • Bilgus
      By Bilgus
      Example of Subclassing listviews using setwindowSubclass in order to intercept WM_KEYUP events
      Also pops context menu on  Shift + F10
      #include <Misc.au3> #include <ListViewConstants.au3> #include <GUIConstants.au3> #include <GuiMenu.au3> #include <WinAPIShellEx.au3> Global $g_hCB, $g_pCB, $g_ahProc[2][2] ;Stores the Data for subclassing listview Global $g_LVKEYUP = 0xFE00, $g_LVKEYDN = 0xFD00 ;Our Own Custom messages (Key Up/Dn) Global $g_iDummyData Global $g_hGui = GUICreate("test") Global $g_hList1 = GUICtrlCreateListView("#|x|y", 5, 24, 161, 70, $LVS_SHOWSELALWAYS Or $LVS_SINGLESEL) GUICtrlCreateListViewItem("text", $g_hList1) Global $g_hList1_LVN = GUICtrlCreateDummy() ;Recieves Messages from the callback Global $g_hContext1 = GUICtrlCreateContextMenu($g_hList1) GUICtrlCreateMenuItem("1", $g_hContext1) GUICtrlCreateMenuItem("2", $g_hContext1) Global $g_hList2 = GUICtrlCreateListView("#|x|y", 5, 100, 161, 70, $LVS_SHOWSELALWAYS Or $LVS_SINGLESEL) GUICtrlCreateListViewItem("text", $g_hList2) Global $g_hList2_LVN = GUICtrlCreateDummy() ;Recieves Messages from the callback Global $g_hContext2 = GUICtrlCreateContextMenu($g_hList2) GUICtrlCreateMenuItem("3", $g_hContext2) GUICtrlCreateMenuItem("4", $g_hContext2) GUISetState(@SW_SHOW) SubClassListView() ;Creates our subclass Func SubClassListView() OnAutoItExitRegister("Cleanup") ;to remove our subclass $g_hCB = DllCallbackRegister('_SubclassProc', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') $g_pCB = DllCallbackGetPtr($g_hCB) $g_ahProc[0][0] = $g_hList1 ;Add the Ids of the controls we'd like to subclass $g_ahProc[1][0] = $g_hList2 ;Set up the subclass _WinAPI_SetWindowSubclass ( $hWnd, $pSubclassProc, $idSubClass [, $pData = 0] ) $g_ahProc[0][1] = _WinAPI_SetWindowSubclass(GUICtrlGetHandle($g_ahProc[0][0]), $g_pCB, $g_ahProc[0][0], $g_hList1_LVN) $g_ahProc[1][1] = _WinAPI_SetWindowSubclass(GUICtrlGetHandle($g_ahProc[1][0]), $g_pCB, $g_ahProc[1][0], $g_hList2_LVN) EndFunc ;==>SubClassListView Func _SubclassProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData) #forceref $iID Local $iRtnMsg = 0 ;Events we'd like to intercept If $iMsg = $WM_KEYUP Or $iMsg = $WM_SYSKEYUP Then $iRtnMsg = $g_LVKEYUP ElseIf $iMsg = $WM_KEYDOWN Or $iMsg = $WM_SYSKEYDOWN Then $iRtnMsg = $g_LVKEYDN EndIf ;We Recieve the Id of the dummy through $pData and pass our RtnMsg to the dummy control If $iRtnMsg Then GUICtrlSendToDummy($pData, BitOR($iRtnMsg, $wParam)) ;Pass messages on to the default handler Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_SubclassProc Func Cleanup() For $i = 0 To UBound($g_ahProc) - 1 ;Remove Our Subclass' by setting it back to the original proc _WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($g_ahProc[$i][0]), DllCallbackGetPtr($g_ahProc[$i][1]), $g_ahProc[$i][0]) Next DllCallbackFree($g_hCB) EndFunc ;==>Cleanup While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $g_hList1_LVN ;This is just a dummy it only recieves events ConsoleWrite("LV1 EVENT 0x" & Hex($g_iDummyData, 4) & @CRLF) $g_iDummyData = GUICtrlRead($g_hList1_LVN) ;Retrieve the code that was sent Switch BitAND($g_iDummyData, 0xFF00) ;Get the keyup/dn status Case $g_LVKEYDN If BitAND($g_iDummyData, 0x00FF) = 0x79 And (_IsPressed("A0") Or _IsPressed("A1")) Then ;Right/ Left Shift & F10 ShowMenu($g_hGui, $g_hList1, $g_hContext1) Else ConsoleWrite("Lv1 KeyDn Vk: 0x" & Hex(BitAND($g_iDummyData, 0x00FF), 2) & @CRLF) ;Get the Virtual keycode EndIf Case $g_LVKEYUP ConsoleWrite("Lv1 KeyUp Vk: 0x" & Hex(BitAND($g_iDummyData, 0x00FF), 2) & @CRLF) ;Get the Virtual keycode EndSwitch Case $g_hList2_LVN $g_iDummyData = GUICtrlRead($g_hList2_LVN) ;Retrieve the code that was sent ConsoleWrite("LV2 EVENT 0x" & Hex($g_iDummyData, 4) & @CRLF) Switch BitAND($g_iDummyData, 0xFF00) ;Get the keyup/dn status Case $g_LVKEYDN ConsoleWrite("Lv2 KeyDn Vk: 0x" & Hex(BitAND($g_iDummyData, 0x00FF), 2) & @CRLF) ;Get the Virtual keycode Case $g_LVKEYUP ConsoleWrite("Lv2 KeyUp Vk: 0x" & Hex(BitAND($g_iDummyData, 0x00FF), 2) & @CRLF) ;Get the Virtual keycode EndSwitch EndSwitch WEnd Func ShowMenu($hWnd, $idCtrl, $idContext) Local $aPos, $iX, $iY Local $hMenu = GUICtrlGetHandle($idContext) $aPos = ControlGetPos($hWnd, "", $idCtrl) $iX = $aPos[0] $iY = $aPos[1] + $aPos[3] ClientToScreen($hWnd, $iX, $iY) ; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd) _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd, $iX, $iY) EndFunc ;==>ShowMenu ; Convert the client (GUI) coordinates to screen (desktop) coordinates Func ClientToScreen($hWnd, ByRef $iX, ByRef $iY) Local $tPoint = DllStructCreate("int;int") DllStructSetData($tPoint, 1, $iX) DllStructSetData($tPoint, 2, $iY) DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "struct*", $tPoint) $iX = DllStructGetData($tPoint, 1) $iY = DllStructGetData($tPoint, 2) ; release Struct not really needed as it is a local $tPoint = 0 EndFunc ;==>ClientToScreen  
      Old Code Using setWindowLong
       
×