Originally Posted by Xereon
Also Leben und Mana Werte holt man sich gewöhlich aus der Memory, also via Cheatengine jene Adressen herrausfinden und dann in deinem Bot auslesen. Was das senden von Tasten angeht kann ich dir helfen:
Code:
; send single keyboard event to non active window
; event = pressed, down, up
; kdown = key down delay
; note: supports only lower case keys + NUMx, Fx, some special keys and @
Func KeySend($inkey, $evt ="pressed", $kdown = 50)
$user32 = DllOpen("user32.dll")
if $user32 = -1 Then
ConsoleWrite("KeySend: cannot open user32.dll")
Exit
EndIf
; handling for special keys
Switch StringUpper($inkey)
Case "@"
$skey = 0x40
$lparam = 0x00100001
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", 0x71, "long", $lparam)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_CHAR, "int", $skey, "long", $lparam)
Sleep(20)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", 0x71, "long", BitOR($lparam, 0xC0000000))
Case "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12"
$skey = 0x6f + Int(StringMid($inkey, 2))
ContinueCase
Case "NUM0", "NUM1", "NUM2", "NUM3", "NUM4", "NUM5", "NUM6", "NUM7", "NUM8" , "NUM9"
if StringUpper(StringLeft($inkey, 3)) = "NUM" Then
$skey = 0x60 + Int(StringMid($inkey, 4))
EndIf
ContinueCase
Case "RETURN", "SPACE", "TAB", "BACK", "END", "HOME", "SNAPSHOT", "INSERT", "DELETE", "LEFT", "RIGHT", "UP", "DOWN"
Switch StringUpper($inkey)
Case "RETURN"
$skey = 0x0D
Case "SPACE"
$skey = 0x20
Case "TAB"
$skey = 0x09
Case "BACK"
$skey = 0x08
Case "END"
$skey = 0x23
Case "HOME"
$skey = 0x24
Case "SNAPSHOT"
$skey = 0x2c
Case "INSERT"
$skey = 0x2d
Case "DELETE"
$skey = 0x2e
Case "LEFT"
$skey = 0x25
Case "RIGHT"
$skey = 0x27
Case "UP"
$skey = 0x26
Case "DOWN"
$skey = 0x28
EndSwitch
$ret = DllCall($user32, "int", "MapVirtualKey", "int", $skey, "int", 0)
$lparam = BitShift($ret[0], -16)
$lparam = BitOr($lparam, 1)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "long", $lparam)
Sleep($kdown)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "long", BitOR($lparam, 0xC0000000))
Case Else ; default lower case key handling
$key = DllCall($user32, "int", "VkKeyScan", "int", Asc(StringLower($inkey)))
$skey = $key[0]
$ret = DllCall($user32, "int", "MapVirtualKey", "int", $skey, "int", 0)
$lparam = BitShift($ret[0], -16)
$lparam = BitOr($lparam, 1)
Select
Case $evt = "pressed"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "long", $lparam)
Sleep($kdown)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "long", BitOR($lparam, 0xC0000000))
Case $evt = "down"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "long", $lparam)
Case $evt = "up"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "long", BitOR($lparam, 0xC0000000))
EndSelect
EndSwitch
DllClose($user32)
EndFunc
Und um ein Mausklick zu senden:
Code:
Func MakeLong($LoWord, $HiWord)
Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
; send mouse events to non active window
; button = left, right, none
; event = down, up, click, dclick, move
Func MouseSend($btn, $evt, $xpos, $ypos)
$user32 = DllOpen("user32.dll")
if $user32 = -1 Then
ConsoleWrite("MouseSend: cannot open user32.dll")
Exit
EndIf
;define missing constans
$MK_LBUTTON = 0x0001
$WM_LBUTTONDOWN = 0x0201
;$WM_LBUTTONUP = 0x0202 -> defined in WindowsConstants.au3
$WM_LBUTTONDBLCLK = 0x0203
$MK_RBUTTON = 0x0002
$WM_RBUTTONDOWN = 0x0204
$WM_RBUTTONUP = 0x0205
$WM_RBUTTONDBLCLK = 0x0206
;$WM_MOUSEMOVE = 0x0200 -> defined in WindowsConstants.au3
;map button to event
If $btn = "left" Then
$button = $MK_LBUTTON
$btdown = $WM_LBUTTONDOWN
$btup = $WM_LBUTTONUP
$btdbl = $WM_LBUTTONDBLCLK
ElseIf $btn = "right" Then
$button = $MK_RBUTTON
$btdown = $WM_RBUTTONDOWN
$btup = $WM_RBUTTONUP
$btdbl = $WM_RBUTTONDBLCLK
ElseIf $btn = "none" Then
If Not ($evt = "move") Then
ConsoleWrite(StringFormat("MouseSend: bad call: %s , %s",$btn, $evt))
Exit
EndIf
Else ;error
ConsoleWrite(StringFormat("MouseSend: bad button: %s",$btn))
Exit
EndIf
;send messages
$pos = MakeLong($xpos, $ypos)
Select
Case $evt = "move"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_MOUSEMOVE, "int", 0, "long", $pos)
Case $evt = "down"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btdown, "int", $button, "long", $pos)
Case $evt = "up"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btup, "int", 0, "long", $pos)
Case $evt = "click"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_MOUSEMOVE, "int", 0, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btdown, "int", $button, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btup, "int", 0, "long", $pos)
Case $evt = "dclick"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_MOUSEMOVE, "int", 0, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btdown, "int", $button, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btup, "int", 0, "long", $pos)
Sleep(10)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btdbl, "int", $button, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btup, "int", 0, "long", $pos)
EndSelect
DllClose($user32)
EndFunc
Solltes du gegebenfalls in eine UDF zusammenpacken.
|