找回密码
 加入
搜索
查看: 3131|回复: 6

在网上搜到后台安键的函数代码,但是检查总是出错。麻烦高手帮忙看看改改,谢谢!

[复制链接]
发表于 2008-7-28 16:33:44 | 显示全部楼层 |阅读模式
;--PostMessage User Defined Functions-- 
;--Written by Shynd for use with DA-- 

#include-once 

Func _MakeLong($LoWord, $HiWord) 
Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF)) 
EndFunc 

Func _MouseClick($hWnd, $button, $x, $y, $times=1, $delay=250) 
If $hWnd = 0 Then 
SetError(-1) 
Return 
EndIf 

Local $ix 
Local $lParam = _MakeLong($x, $y) 
Local $user32 = DllOpen("user32.dll") 

$button = StringLower($button) 

If $button = "left" Then 
For $ix = 1 To $times 
DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", $lParam) 
DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 1, "long", $lParam) 
DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", $lParam) 

If $ix < $times Then Sleep($delay) 
Next 
ElseIf $button = "right" Then 
For $ix = 1 To $times 
DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", $lParam) 

(这中间差一些代码,拜求高手给个全的代码,感谢!!!)

Param = 0x27 
$lParam = 0x14D0001 
ElseIf $key = "down" Then 
$wParam = 0x28 
$lParam = 0x1500001 
ElseIf $key = "up" Then 
$wParam = 0x26 
$lParam = 0x1480001 
EndIf 

Local $user32 = DllOpen("user32.dll") 

$ret = DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", $wParam, "int", $lParam) 
If $ret[0] = 0 Then 
SetError(-2) 
If $user32 <> -1 Then DllClose($user32) 
Return 
EndIf 

Sleep(2) 

$ret = DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", $wParam, "int", ($lParam + 0xC0000000)) 
If $ret[0] = 0 Then 
SetError(-3) 
If $user32 <> -1 Then DllClose($user32) 
Return 
EndIf 

If $user32 <> -1 Then DllClose($user32) 
EndFunc 

Func _PostMessage($hWnd, $msgID, $wParam, $lParam) 
Local $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", $msgID, "int", $wParam, "int", $lParam) 
If IsArray($ret) Then 
Return $ret[0] 
Else 
SetError(-1) 
Return False 
EndIf 
EndFunc


上面的代码是网上搜的,说是后台向指定窗口发送按键的函数代码。
该文件原名是:PostMessage_UDF.au3

但是运行检查总是出错,我刚开始学autoit,弄不明白。

发现,中间应该是差一截代码。

有没高手帮忙给个全的的。
万分感谢!

[ 本帖最后由 gaoyuan22 于 2008-7-28 19:54 编辑 ]
发表于 2008-8-26 11:02:28 | 显示全部楼层
帮顶一下,我也想知道
发表于 2008-8-26 11:47:56 | 显示全部楼层
兄弟,看看这个行吗?
;--PostMessage User Defined Functions--
;--Written by Shynd for use with DA--

#include-once

Func _MakeLong($LoWord, $HiWord)
        Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

Func _MouseClick($hWnd, $button, $x, $y, $times=1, $delay=250)
        If $hWnd = 0 Then
                SetError(-1)
                Return
        EndIf
        
        Local $ix
        Local $lParam = _MakeLong($x, $y)
        Local $user32 = DllOpen("user32.dll")
        
        $button = StringLower($button)
        
        If $button = "left" Then
                For $ix = 1 To $times
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", $lParam)
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 1, "long", $lParam)
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", $lParam)
                        
                        If $ix < $times Then Sleep($delay)
                Next
        ElseIf $button = "right" Then
                For $ix = 1 To $times
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", $lParam)
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x204, "int", 2, "long", $lParam)
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x205, "int", 0, "long", $lParam)
                        
                        If $ix < $times Then Sleep($delay)
                Next
        Else
                SetError(-2)
                If $user32 <> -1 Then DllClose($user32)
                Return
        EndIf
        If $user32 <> -1 Then DllClose($user32)
EndFunc

Func _MouseUseSpell($hWnd, $x, $y, $selfcast=False, $sx=310, $sy=163)
        Local $user32 = DllOpen("user32.dll")
        
        ;Click the spell panel
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", _MakeLong(547, 400))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 0, "long", _MakeLong(547, 400))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong(547, 400))
        
        ;Double-click the spell
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong($x, $y))
        
        ;If selfcast, click on character
        If $selfcast Then
                DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", _MakeLong($sx, $sy))
                DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 0, "long", _MakeLong($sx, $sy))
                DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong($sx, $sy))
        EndIf
        
        If $user32 <> -1 Then DllClose($user32)
EndFunc

Func _MouseUseSkill($hWnd, $x, $y)
        Local $user32 = DllOpen("user32.dll")
        
        ;Click the skill panel
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", _MakeLong(547, 370))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 0, "long", _MakeLong(547, 370))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong(547, 370))
        
        ;Double-click the skill
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong($x, $y))
        
        If $user32 <> -1 Then DllClose($user32)
EndFunc

Func _SendKeys($hWnd, $keys)
        If $hWnd <= 0 Or StringLen($keys) = 0 Then
                SetError(-1)
                Return False
        EndIf
        
        $keys = StringUpper($keys)
        
        $keys = StringReplace($keys, "`", Chr(0xC0))
        $keys = StringReplace($keys, "~", Chr(0xC0))
        $keys = StringReplace($keys, "-", Chr(0xBD))
        $keys = StringReplace($keys, "=", Chr(0xBB))
        $keys = StringReplace($keys, "{ENTER}", Chr(0xD))
        $keys = StringReplace($keys, "{TAB}", Chr(0x9))
        $keys = StringReplace($keys, "{ESC}", Chr(0x1B))
        $keys = StringReplace($keys, "{F5}", Chr(0x74))
        $keys = StringReplace($keys, "{F12}", Chr(0x7B))
        $keys = StringReplace($keys, "{SHIFT}", "+")
        
        Local $i, $ret
        Local $shiftdown = False
        Local $user32 = DllOpen("user32.dll")
        
        For $i = 1 To StringLen($keys)
                If StringMid($keys, $i, 1) = "+" Then
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x002A0001)
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x402A0001)
                        $shiftdown = True
                        Sleep(1)
                        ContinueLoop
                Else
                        $ret = DllCall($user32, "int", "MapVirtualKey", "int", Asc(StringMid($keys, $i, 1)), "int", 0)
                        If IsArray($ret) Then
                                DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]))
                                Sleep(1)
                                DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]) + 0xC0000000)
                                Sleep(1)
                        EndIf
                EndIf
                If $shiftdown Then
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", 0x10, "long", 0xC02A0001)
                        Sleep(1)
                        $shiftdown = False
                EndIf
        Next
        
        If $user32 <> -1 Then DllClose($user32)
        
        Return True
EndFunc

Func _SendText($hWnd, $str)
        If $hWnd = 0 Or StringLen($str) = 0 Then
                SetError(-1)
                Return
        EndIf
        
        Local $user32 = DllOpen("user32.dll")
        
        For $i = 1 To StringLen($str)
                DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x102, "int", Asc(StringMid($str, $i, 1)), "long", 0)
                Sleep(1)
        Next
        
        If $user32 <> -1 Then DllClose($user32)
EndFunc

Func _SendChatMessage($hWnd, $str)
        If $hWnd = 0 Or StringLen($str) = 0 Then
                SetError(-1)
                Return
        EndIf
        
        _SendKeys($hWnd, "{ENTER}")
        Sleep(50)
        _SendText($hWNd, $str)
        Sleep(30)
        _SendKeys($hWNd, "{ENTER}")
EndFunc

Func _SendWhisper($hWnd, $name, $str)
        If $hWnd = 0 Or StringLen($str) = 0 Or StringLen($name) = 0 Then
                SetError(-1)
                Return
        EndIf
        
        _SendKeys($hWnd, "{ESC}+" & Chr(0xDE))
        Sleep(50)
        _SendText($hWnd, $name)
        Sleep(1)
        _SendKeys($hWNd, "{ENTER}")
        Sleep(30)
        _SendText($hWnd, $str)
        Sleep(30)
        _SendKeys($hWnd, "{ENTER}")
EndFunc

Func _ArrowKey($hWnd, $key)
        If $hWnd <= 0 Or ( $key <> "left" And $key <> "right" And $key <> "up" And $key <> "down" ) Then
                SetError(-1)
                Return
        EndIf
        
        Local $wParam, $lParam, $ret
        
        If $key = "left" Then
                $wParam = 0x25
                $lParam = 0x14B0001
        ElseIf $key = "right" Then
                $wParam = 0x27
                $lParam = 0x14D0001
        ElseIf $key = "down" Then
                $wParam = 0x28
                $lParam = 0x1500001
        ElseIf $key = "up" Then
                $wParam = 0x26
                $lParam = 0x1480001
        EndIf
        
        Local $user32 = DllOpen("user32.dll")
        
        $ret = DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", $wParam, "int", $lParam)
        If $ret[0] = 0 Then
                SetError(-2)
                If $user32 <> -1 Then DllClose($user32)
                Return
        EndIf
        
        Sleep(2)
        
        $ret = DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", $wParam, "int", ($lParam + 0xC0000000))
        If $ret[0] = 0 Then
                SetError(-3)
                If $user32 <> -1 Then DllClose($user32)
                Return
        EndIf
        
        If $user32 <> -1 Then DllClose($user32)
EndFunc

Func _PostMessage($hWnd, $msgID, $wParam, $lParam)
        Local $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", $msgID, "int", $wParam, "int", $lParam)
        If IsArray($ret) Then
                Return $ret[0]
        Else
                SetError(-1)
                Return False
        EndIf
EndFunc
发表于 2008-8-26 11:50:20 | 显示全部楼层
看会了,分享一下,给我说说怎么用?
发表于 2009-11-19 23:34:05 | 显示全部楼层
毁了的给我也说下。
发表于 2009-11-20 12:52:58 | 显示全部楼层
=.= 落落長...重點在哪裡? 這份文,確實有用,只是實戰時,效果不佳...
是知道論壇有某些牛B 已經有著自己的核心,不過強求不得
发表于 2010-7-13 21:54:52 | 显示全部楼层
本帖最后由 xjdjpbp 于 2010-7-13 21:56 编辑
=.= 落落長...重點在哪裡? 這份文,確實有用,只是實戰時,效果不佳...
是知道論壇有某些牛B 已經有著自己 ...
ZEROBOYS 发表于 2009-11-20 12:52


這不是分享文阿

只是中間有一段有缺陷

他想要知道而已@@

順便po上
;--PostMessage User Defined Functions--
;--Written by Shynd for use with DA--

#include-once

Func _MakeLong($LoWord, $HiWord)
        Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

Func _MouseClick($hWnd, $button, $x, $y, $times=1, $delay=250)
        If $hWnd = 0 Then
                SetError(-1)
                Return
        EndIf

        Local $ix
        Local $lParam = _MakeLong($x, $y)
        Local $user32 = DllOpen("user32.dll")

        $button = StringLower($button)

        If $button = "left" Then
                For $ix = 1 To $times
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", $lParam)
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 1, "long", $lParam)
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", $lParam)

                        If $ix < $times Then Sleep($delay)
                Next
        ElseIf $button = "right" Then
                For $ix = 1 To $times
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", $lParam)
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x204, "int", 2, "long", $lParam)
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x205, "int", 0, "long", $lParam)

                        If $ix < $times Then Sleep($delay)
                Next
        Else
                SetError(-2)
                If $user32 <> -1 Then DllClose($user32)
                Return
        EndIf
        If $user32 <> -1 Then DllClose($user32)
EndFunc

Func _MouseUseSpell($hWnd, $x, $y, $selfcast=False, $sx=310, $sy=163)
        Local $user32 = DllOpen("user32.dll")

        ;Click the spell panel
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", _MakeLong(547, 400))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 0, "long", _MakeLong(547, 400))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong(547, 400))

        ;Double-click the spell
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong($x, $y))

        ;If selfcast, click on character
        If $selfcast Then
                DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", _MakeLong($sx, $sy))
                DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 0, "long", _MakeLong($sx, $sy))
                DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong($sx, $sy))
        EndIf

        If $user32 <> -1 Then DllClose($user32)
EndFunc

Func _MouseUseSkill($hWnd, $x, $y)
        Local $user32 = DllOpen("user32.dll")

        ;Click the skill panel
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", _MakeLong(547, 370))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 0, "long", _MakeLong(547, 370))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong(547, 370))

        ;Double-click the skill
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 0, "long", _MakeLong($x, $y))
        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong($x, $y))

        If $user32 <> -1 Then DllClose($user32)
EndFunc

Func _SendKeys($hWnd, $keys)
        If $hWnd <= 0 Or StringLen($keys) = 0 Then
                SetError(-1)
                Return False
        EndIf

        $keys = StringUpper($keys)

        $keys = StringReplace($keys, "`", Chr(0xC0))
        $keys = StringReplace($keys, "~", Chr(0xC0))
        $keys = StringReplace($keys, "-", Chr(0xBD))
        $keys = StringReplace($keys, "=", Chr(0xBB))
        $keys = StringReplace($keys, "{ENTER}", Chr(0xD))
        $keys = StringReplace($keys, "{TAB}", Chr(0x9))
        $keys = StringReplace($keys, "{ESC}", Chr(0x1B))
        $keys = StringReplace($keys, "{F5}", Chr(0x74))
        $keys = StringReplace($keys, "{F12}", Chr(0x7B))
        $keys = StringReplace($keys, "{SHIFT}", "+")

        Local $i, $ret
        Local $shiftdown = False
        Local $user32 = DllOpen("user32.dll")

        For $i = 1 To StringLen($keys)
                If StringMid($keys, $i, 1) = "+" Then
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x002A0001)
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x402A0001)
                        $shiftdown = True
                        Sleep(1)
                        ContinueLoop
                Else
                        $ret = DllCall($user32, "int", "MapVirtualKey", "int", Asc(StringMid($keys, $i, 1)), "int", 0)
                        If IsArray($ret) Then
                                DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]))
                                Sleep(1)
                                DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]) + 0xC0000000)
                                Sleep(1)
                        EndIf
                EndIf
                If $shiftdown Then
                        DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", 0x10, "long", 0xC02A0001)
                        Sleep(1)
                        $shiftdown = False
                EndIf
        Next

        If $user32 <> -1 Then DllClose($user32)

        Return True
EndFunc

Func _SendText($hWnd, $str)
        If $hWnd = 0 Or StringLen($str) = 0 Then
                SetError(-1)
                Return
        EndIf

        Local $user32 = DllOpen("user32.dll")

        For $i = 1 To StringLen($str)
                DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x102, "int", Asc(StringMid($str, $i, 1)), "long", 0)
        Next

        If $user32 <> -1 Then DllClose($user32)
EndFunc

Func _SendChatMessage($hWnd, $str)
        If $hWnd = 0 Or StringLen($str) = 0 Then
                SetError(-1)
                Return
        EndIf

        _SendKeys($hWnd, "{ENTER}")
        Sleep(50)
        _SendText($hWNd, $str)
        Sleep(30)
        _SendKeys($hWNd, "{ENTER}")
EndFunc

Func _SendWhisper($hWnd, $name, $str)
        If $hWnd = 0 Or StringLen($str) = 0 Or StringLen($name) = 0 Then
                SetError(-1)
                Return
        EndIf

        _SendKeys($hWnd, "{ESC}+" & Chr(0xDE))
        Sleep(50)
        _SendText($hWnd, $name)
        Sleep(1)
        _SendKeys($hWNd, "{ENTER}")
        Sleep(30)
        _SendText($hWnd, $str)
        Sleep(30)
        _SendKeys($hWnd, "{ENTER}")
EndFunc

Func _ArrowKey($hWnd, $key)
        If $hWnd <= 0 Or ( $key <> "left" And $key <> "right" And $key <> "up" And $key <> "down" ) Then
                SetError(-1)
                Return
        EndIf

        Local $wParam, $lParam, $ret

        If $key = "left" Then
                $wParam = 0x25
                $lParam = 0x14B0001
        ElseIf $key = "right" Then
                $wParam = 0x27
                $lParam = 0x14D0001
        ElseIf $key = "down" Then
                $wParam = 0x28
                $lParam = 0x1500001
        ElseIf $key = "up" Then
                $wParam = 0x26
                $lParam = 0x1480001
        EndIf

        Local $user32 = DllOpen("user32.dll")

        $ret = DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", $wParam, "int", $lParam)
        If $ret[0] = 0 Then
                SetError(-2)
                If $user32 <> -1 Then DllClose($user32)
                Return
        EndIf

        Sleep(2)

        $ret = DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", $wParam, "int", ($lParam + 0xC0000000))
        If $ret[0] = 0 Then
                SetError(-3)
                If $user32 <> -1 Then DllClose($user32)
                Return
        EndIf

        If $user32 <> -1 Then DllClose($user32)
EndFunc

Func _PostMessage($hWnd, $msgID, $wParam, $lParam)
        Local $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", $msgID, "int", $wParam, "int", $lParam)
        If IsArray($ret) Then
                Return $ret[0]
        Else
                SetError(-1)
                Return False
        EndIf
EndFunc
下面有各位高手的討論串
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-15 16:36 , Processed in 0.077858 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表