Jump to content

Search the Community

Showing results for tags '_winapi_setkeyboardstate'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. I just got a new mouse that has macro functionality, and i wanted to make something simmilar for my keyboard. Thing is, _WinAPI_SetKeyboardState gives me an error i cannot seem to fix. Please ask me if you have any questions, also here is the code: #include <WinAPISys.au3> #include <Array.au3> #include <File.au3> #include <GUIConstantsEx.au3> HotKeySet('{ESC}', 'Close') Global $bRecording = False Global $bStop = False Func Close() $bStop = True EndFunc ;==>Close $hGUI = GUICreate('Input recorder', 500, 200) $idStartRecording = GUICtrlCreateButton('Start recording', 80, 100) $idStopRecording = GUICtrlCreateButton('Run macro', 320, 100) GUISetState() Global $aArray[11][2] $hTimer = TimerInit() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idStartRecording $bStop = False GUICtrlSetData($idStartRecording, 'Running...') $hFile = FileOpen(@ScriptDir & '\Macro' & @YEAR & '.' & @MON & '.' & @MDAY & '-' & @HOUR & '.' & @MIN & '.' & @SEC & '.macro', 1) While $bStop = False ;$hTimer = TimerInit() For $i = 0 To 10 If $i <> 0 Then Do Sleep(10) $a = _WinAPI_GetKeyboardStateMod() Until _ArrayToString($a, '') <> $aArray[$i - 1][0] or $bStop = True ;ConsoleWrite(_ArrayToString($a, '') & ' ' & $aArray[$i - 1][0]) Else $a = _WinAPI_GetKeyboardStateMod() EndIf $aArray[$i][0] = _ArrayToString($a, '') $aArray[$i][1] = Round(TimerDiff($hTimer), 1) $hTimer = TimerInit() Next _FileWriteFromArray($hFile, $aArray, Default, Default, @CRLF) for $iO = 0 to 10 $aArray[$iO][0] = '' $aArray[$iO][1] = '' Next ;ConsoleWrite(@error) WEnd _FileWriteFromArray($hFile, $aArray, Default, Default, @CRLF) GUICtrlSetData($idStartRecording, 'Start recording') Case $idStopRecording $bStop = False $hFile = FileOpen(FileOpenDialog('Select macro file', @ScriptDir, 'Macro files (*.macro)', 1 + 2)) GUICtrlSetData($idStopRecording, 'Running...') $sFileContent = FileRead($hFile) ;ConsoleWrite($sFileContent&@CRLF&@CRLF&@CRLF) $aWholeFile = StringSplit($sFileContent, @LF) ;_ArrayDisplay($aWholeFile) For $i = 1 To $aWholeFile[0] - 1 ;ConsoleWrite(Mod($i,2)) if $bStop = True Then ExitLoop If $aWholeFile[$i] <> @CR Then If Mod($i,2) = 1 Then ConsoleWrite('Array ' & $aWholeFile[$i]) $aCharPresses = StringSplit($aWholeFile[$i], '') _WinAPI_SetKeyboardState($aCharPresses) Else ConsoleWrite('Sleep ' & $aWholeFile[$i]) Sleep(Int($aWholeFile[$i])) EndIf EndIf Next GUICtrlSetData($idStopRecording, 'Run macro') EndSwitch WEnd Func _WinAPI_GetKeyboardStateMod() Local $aDllRet, $lpKeyState = DllStructCreate("byte[256]") $aDllRet = DllCall("User32.dll", "int", "GetKeyboardState", "ptr", DllStructGetPtr($lpKeyState)) Local $aReturn[256] For $i = 1 To 256 $aReturn[$i - 1] = DllStructGetData($lpKeyState, 1, $i) Next Return $aReturn EndFunc ;==>_WinAPI_GetKeyboardStateMod
×
×
  • Create New...