Jump to content

Dublicate Function '_WinAPI_GetKeyboardState'


Recommended Posts

Hi,

sorry I'm a bit confused.

I'm finding two functions with the same name.

Has this been replaced or updated ?

; #FUNCTION# ====================================================================================================================
; Name...........:  _WinAPI_GetKeyboardState
; Description ...:  Returns the status of the 256 virtual keys
; Syntax.........:  _WinAPI_GetKeyboardState($iFlag=0)
; Parameters ....:  $iFlag   - Return Type
;                   0 Returns an array[256]
;                   1 Returns a string
; Return values .:  Success  - Array[256] or String containing status of 256 virtual keys
;                   Failure  - False
; Author ........:  Eukalyptus
; Modified.......:
; Remarks .......:  If the high-order bit is 1, the key is down; otherwise, it is up.
;                   If the key is a toggle key, for example CAPS LOCK, then the low-order bit is 1
;                   when the key is toggled and is 0 if the key is untoggled
; Related .......:  _IsPressed
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _WinAPI_GetKeyboardState($iFlag = 0)
    Local $aDllRet, $lpKeyState = DllStructCreate("byte[256]")
    $aDllRet = DllCall("User32.dll", "int", "GetKeyboardState", "ptr", DllStructGetPtr($lpKeyState))
    If @error Then Return SetError(@error, 0, 0)
    If $aDllRet[0] = 0 Then
        Return SetError(1, 0, 0)
    Else
        Switch $iFlag
            Case 0
                Local $aReturn[256]
                For $i = 1 To 256
                    $aReturn[$i - 1] = DllStructGetData($lpKeyState, 1, $i)
                Next
                Return $aReturn
            Case Else
                Return DllStructGetData($lpKeyState, 1)
        EndSwitch
    EndIf
EndFunc   ;==>_WinAPI_GetKeyboardState

; #FUNCTION# ====================================================================================================================
; Author.........: Yashied
; Modified.......: jpm
; ===============================================================================================================================
Func _WinAPI_GetKeyboardState()
    Local $tData = DllStructCreate('byte[256]')
    Local $aRet = DllCall('user32.dll', 'bool', 'GetKeyboardState', 'struct*', $tData)
    If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0)

    Return $tData
EndFunc   ;==>_WinAPI_GetKeyboardState

Thanks for assistance

Cheers mike

Link to comment
Share on other sites

36 minutes ago, argumentum said:

I've checked and only your 2nd func by Yashied is in the distro.

In my official installation , too, I can only find one include file in which the function exists (once).

By the way: If one creates an AutoIt script in which two functions have the identical name, an error message appears (... already defined).

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Hi,

thanks for the reply.

One function I found in following thread:

Link to Function

When using this function in a script I got the error message 'Dublicate function name',
and when looking for that I found the other function in 'WinAPISys.au3' with the same name.

This is why I got confused.

Cheers mike

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

  • Recently Browsing   0 members

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