Hallo zusammen,
ich bin dabei, das UAWKS-Script (Unofficial Apple Wireless Keyboard Support) in AutoIt zu übersetzen, um es meinen Bedürfnissen besser anpassen zu können und Bugs in diesem Programm zu umgehen.
Das UAWKS ist nämlich in AutoHotkey geschrieben, und da habe ich ziemlich wenig Ahnung von.
Im Moment hänge ich daran, die DLL anzusprechen, die mir u.a. die Tastendrücke meldet. In AutoHotkey funktioniert das soweit ganz ok. AutoIt will aber nicht: DllCall gibt mir immer ein @error=1 --> unable to use dll file
hier mal der relevante Code:
$DllPfad = @ScriptDir & "\AutohotkeyRemoteControl.dll"
$DllHandle = DllOpen($DllPfad)
$hModule = DllCall($DllHandle , "str:cdecl", "LoadLibrary")
If @error <> 0 Then
MsgBox(64, "Fn Remapper", "DllCall LoadLibrary failed" & @CRLF & "Error: " & @error)
EndIf
der Original-Autohotkey-Code befindet sich hier: http://code.google.com/p/uawks/source…rc/FnMapper.ahk
dort ist auch die Dll zu finden.
Die AutohotkeyRemoteControl.dll liegt im selben Verzeichnis wie das Script. Administratorrechte beim Ausführen bringen keine Verbesserung.
heir mein gesamter Quellcode:
Spoiler anzeigen
$hWnd = GUICreate("FnMapper-AutoIt")
$DllPfad = @ScriptDir & "\AutohotkeyRemoteControl.dll"
$DllPfad = DllOpen($DllPfad)
$hModule = DllCall($DllPfad, "str:cdecl", "LoadLibrary")
If @error <> 0 Then
MsgBox(64, "Fn Remapper", "DllCall LoadLibrary failed" & @CRLF & "Error: " & @error)
cleanup()
EndIf
;If GUIRegisterMsg(0x0ff, "InputMsg") = 0 Then MsgBox(64, "Fn Remapper", "GUIRegisterMsg failed"&@crlf&"Error: "&@error)
[/autoit] [autoit][/autoit] [autoit]$EditUsage = 1
$EditUsagePage = 12
$nRC = DllCall($DllPfad, "UINT:cdecl", "RegisterDevice", "INT", $EditUsage, "INT", $EditUsagePage, "INT", $hWnd)
If @error <> 0 Then
MsgBox(64, "Fn Remapper", "DllCall RegisterDevice failed" & @CRLF & "Error: " & @error)
cleanup()
EndIf
Func InputMsg($hWnd, $msg, $wParam, $lParam)
$DeviceNr = -1
$nRC = DllCall($DllPfad, "UINT:cdecl", "GetWM_INPUTDataType", "UINT", $wParam, "UINT", $lParam, "INT *", $DeviceNr)
$error = @error
If $error <> 0 Or $nRC = 0xFFFFFFFF Then
MsgBox(64, "Fn Remapper", "GetWM_INPUTHIDData fehlgeschlagen." & @CRLF & "Errorlevel: " & $error)
cleanup()
EndIf
If $nRC = 2 Then
ProcessHIDData($wParam, $lParam)
Else
MsgBox(64, "Fn Remapper", "Error: No HID Data")
EndIf
EndFunc ;==>InputMsg
Func cleanup()
DllCall($DllPfad, "UINT:cdecl", "FreeLibrary")
DllClose($DllPfad)
Exit
EndFunc ;==>cleanup
Func ProcessHIDData($wParam, $lParam)
Global $FnKeyPressed
$DataSize = 5000
$RawData = ""
$nHandle = DllCall($DllPfad, "UINT:cdecl", "GetWM_INPUTHIDData", "UINT", $wParam, "UINT", $lParam, "UINT *", $DataSize, "UINT", $RawData)
[/autoit] [autoit][/autoit] [autoit]$KeyStatus = BitAND($RawData, 1)
MsgBox(64, "Fn Remapper", $KeyStatus)
$FnValue = BitAND($KeyStatus, 16)
$EjectValue = BitAND($KeyStatus, ![]()
If $FnValue = 8 Then
$FnKeyPressed = True
Else
$FnKeyPressed = False
EndIf
If $EjectValue = 8 Then
;Eject Drive
Else
;Dont Eject Drive
EndIf
EndFunc ;==>ProcessHIDData
[/autoit] [autoit][/autoit] [autoit];While True
; Sleep(1)
;WEnd
Wer kann mir helfen? ![]()
Gruß
pk