找回密码
 加入
搜索
查看: 2021|回复: 3

[AU3基础] 在XP下能用换到WIN7就不能用了

  [复制链接]
发表于 2017-6-28 10:13:32 | 显示全部楼层 |阅读模式
本帖最后由 110abc 于 2017-6-28 10:43 编辑

代码如下!帮我找找原因好吗谢谢了!
有谁知道的能指导一下吗?!

#include <GDIPlus.au3>
HotKeySet("{PAUSE}", "TogglePause");暂停开始
Global $Paused, $WinTem, $TitleTem[4], $GhomeYN[3] = [0, 0, 0], $Ngun[3] = [0, 0, 0], $Transportation, $i, $j, $Ytem[3], $StoreListNull[3], $Nproduc[3] = [0, 0, 0]

$WinTem="窗口 - 名称"
$hwnd = WinGetHandle($WinTem)



While 1
        Sleep(5000)
WEnd


Func TogglePause()
        $Paused = Not $Paused
        While $Paused
                Sleep(500)
                ToolTip('暂停脚本中!', 0, 0)
        WEnd
       
       
        ToolTip("")
        While 1
                If _PosColorRead($hwnd, 911, 199) = 0xFF0F00 Or _PosColorRead($hwnd, 911, 195) = 0xFF0F00 Then;1233,316坐标点的颜色=OXFFOFOO(颜色,黄色)
                        Sleep(100)
                        ToolTip('颜色正确,执行代码!', 0, 0)
                        Sleep(500)
                        _MouseEveClick($hwnd, 911, 199, 1);鼠标单击
                        Sleep(1500)
                        _MouseEveClick($hwnd, 968, 110, 1);鼠标单击                Else
                        Sleep(500)
                        ToolTip('颜色错误!条件颜色为0xFFFF00,911,199坐标颜色为' & _PosColorRead($hwnd, 1050, 145), 0, 0)
                EndIf
                Sleep(20000)
        WEnd
EndFunc   ;==>TogglePause



Func _MouseEveClick($hwnd, $MCx, $MCy, $MCType);鼠标单击
        $MCx = $MCx - 4
        $MCy = $MCy - 30
        If $MCType = 1 Then
                DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hwnd, "uint", 0x200, "wparam", 0, "lparam", BitOR(BitAND($MCx, 0xFFFF), $MCy * 0x10000))
                Sleep(200)
                DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hwnd, "uint", 0x201, "wparam", 1, "lparam", BitOR(BitAND($MCx, 0xFFFF), $MCy * 0x10000))
                Sleep(200)
                DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hwnd, "uint", 0x202, "wparam", 0, "lparam", BitOR(BitAND($MCx, 0xFFFF), $MCy * 0x10000))
                Sleep(800)
        ElseIf $MCType = 2 Then
                DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hwnd, "uint", 0x200, "wparam", 0, "lparam", BitOR(BitAND($MCx, 0xFFFF), $MCy * 0x10000))
                Sleep(200)
                DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hwnd, "uint", 0x204, "wparam", 2, "lparam", BitOR(BitAND($MCx, 0xFFFF), $MCy * 0x10000))
                Sleep(200)
                DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hwnd, "uint", 0x205, "wparam", 0, "lparam", BitOR(BitAND($MCx, 0xFFFF), $MCy * 0x10000))
                Sleep(800)
        EndIf
EndFunc   ;==>_MouseEveClick


;后台判断颜色,

Func _PosColorRead($hwnd, $PosX, $PosY)
        Local $iColor, $PosArray, $X = $PosX, $Y = $PosY
        $PosArray = LToArray($hwnd, $X + 5, $Y + 5)
        $iColor = $PosArray[$PosX][$PosY]
        Return $iColor
EndFunc   ;==>_PosColorRead

Func _WinCapture($hwnd, $iWidth = -1, $iHeight = -1)
        Local $iH, $iW, $hDDC, $hCDC, $hBMP
        If $iWidth = -1 Then $iWidth = _WinAPI_GetWindowWidth($hwnd)
        If $iHeight = -1 Then $iHeight = _WinAPI_GetWindowHeight($hwnd)
        $hDDC = _WinAPI_GetDC($hwnd)
        $hCDC = _WinAPI_CreateCompatibleDC($hDDC)
        $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight)
        _WinAPI_SelectObject($hCDC, $hBMP)
        DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hwnd, "hwnd", $hCDC, "int", 0)
        _WinAPI_ReleaseDC($hwnd, $hDDC)
        _WinAPI_DeleteDC($hCDC)
        Return $hBMP
EndFunc   ;==>_WinCapture

Func LToArray($hand, $iWidth = -1, $iHeight = -1)
        Local $hBitmap, $BitmapData, $i_width, $i_height, $Scan0, $pixelData, $s_BMPData, $i_Stride
        _GDIPlus_Startup()
        If $iWidth = -1 Then $iWidth = _WinAPI_GetWindowWidth($hand)
        If $iHeight = -1 Then $iHeight = _WinAPI_GetWindowHeight($hand)
        $hBMP = _WinCapture($hand, $iWidth, $iHeight)
        $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
        If @error Then
                _GDIPlus_Shutdown()
                Return 0
        EndIf
        $i_width = _GDIPlus_ImageGetWidth($hBitmap)
        $i_height = _GDIPlus_ImageGetHeight($hBitmap)
        $BitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $i_width, $i_height, $GDIP_ILMREAD, $GDIP_PXF24RGB)
        $i_Stride = DllStructGetData($BitmapData, "Stride")
        $Scan0 = DllStructGetData($BitmapData, "Scan0")
        $pixelData = DllStructCreate("ubyte lData[" & (Abs($i_Stride) * $i_height) & "]", $Scan0)
        $s_BMPData = DllStructGetData($pixelData, "lData")
        $s_BMPData = StringTrimLeft($s_BMPData, 2)
        _GDIPlus_BitmapUnlockBits($hBitmap, $BitmapData)
        _GDIPlus_ImageDispose($hBitmap)
        _WinAPI_DeleteObject($hBitmap)
        _WinAPI_DeleteObject($hBMP)
        _GDIPlus_Shutdown()
        Local $a_return[$i_width][$i_height], $X = $i_width - 5, $Y = $i_height - 5, $s
        $s = StringMid($s_BMPData, $Y * ($i_Stride * 2) + 1, $i_width * 6)
        $a_return[$X][$Y] = StringMid($s, $X * 6 + 1, 6)
        $a_return[$X][$Y] = "0x" & StringRight($a_return[$X][$Y], 2) & StringMid($a_return[$X][$Y], 2, 2) & StringLeft($a_return[$X][$Y], 2)
        Return $a_return
EndFunc   ;==>LToArray
 楼主| 发表于 2017-6-28 10:53:27 | 显示全部楼层
是不是出错在USER32.DLL上??
发表于 2017-6-28 11:41:10 | 显示全部楼层
代码首加:
DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)

#AutoIt3Wrapper_UseX64 =n
 楼主| 发表于 2017-7-12 08:24:44 | 显示全部楼层
代码首加:
DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)

#AutoIt3 ...
fenhanxue 发表于 2017-6-28 11:41



    在吗向你请教下!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-4 02:09 , Processed in 0.070291 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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