在XP下能用换到WIN7就不能用了
本帖最后由 110abc 于 2017-6-28 10:43 编辑代码如下!帮我找找原因好吗谢谢了!
有谁知道的能指导一下吗?!
#include <GDIPlus.au3>
HotKeySet("{PAUSE}", "TogglePause");暂停开始
Global $Paused, $WinTem, $TitleTem, $GhomeYN = , $Ngun = , $Transportation, $i, $j, $Ytem, $StoreListNull, $Nproduc =
$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 是不是出错在USER32.DLL上?? 代码首加:
DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
或
#AutoIt3Wrapper_UseX64 =n 代码首加:
DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
或
#AutoIt3 ...
fenhanxue 发表于 2017-6-28 11:41 http://www.autoitx.com/images/common/back.gif
在吗向你请教下!
页:
[1]