|
dmqhcx88
发表于 2011-08-18 23:54:15
工具是采用找色的原理,速度比较慢,有兴趣的朋友可以优化下,
-
- #include <WinAPIEx.au3>
- #include <WinAPI.au3>
- #include <ButtonConstants.au3>
- #include <ComboConstants.au3>
- #include <GUIConstantsEx.au3>
- #include <StaticConstants.au3>
- #include <WindowsConstants.au3>
- Opt("PixelCoordMode", 2)
- Opt("MouseCoordMode", 2)
- Opt("GUIOnEventMode", 1)
- HotKeySet("{f12}", "_change_color")
- HotKeySet("{esc}", "tuichu")
- Global $g_color, $g_hotkey
- Global $sysfile = @ScriptDir & "\找茬辅助配置文件.ini"
- Global $color_list[5][2] = [["红", 0x0000ff],["绿", 0x00ff00],["蓝", 0xff0000],["黑", 0],["白", 0xffffff]]
- $g_color = IniRead($sysfile, "settings", "color", "蓝")
- $g_hotkey = IniRead($sysfile, "settings", "hotkey", "F5")
- HotKeySet("{" & $g_hotkey & "}", "test")
- #Region ### START Koda GUI section ###
- $Form1_1 = GUICreate("QQ找茬辅助工具 ", 484, 102, 301, 184)
- GUISetOnEvent($GUI_EVENT_CLOSE, "tuichu")
- $Group1 = GUICtrlCreateGroup("设置", 8, 8, 457, 57)
- $Label1 = GUICtrlCreateLabel("提示线颜色:", 24, 32, 67, 17)
- $Combo_color = GUICtrlCreateCombo("", 96, 28, 49, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
- GUICtrlSetData(-1, "红|蓝|黑|白|绿", $g_color)
- GUICtrlSetOnEvent(-1, "mygui")
- $Label2 = GUICtrlCreateLabel("快捷键:", 152, 32, 52, 17)
- $Combo_hotkey = GUICtrlCreateCombo("", 200, 28, 57, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
- GUICtrlSetData(-1, "F2|F3|F4|F5|F6|F7|F8|F9|F10", $g_hotkey)
- GUICtrlSetOnEvent(-1, "mygui")
- $Checkbox_move_win = GUICtrlCreateCheckbox("自动调整窗口", 272, 30, 97, 17)
- GUICtrlSetState(-1, IniRead($sysfile, "settings", "fixwinpos", 1))
- GUICtrlSetOnEvent(-1, "mygui")
- $Button1 = GUICtrlCreateButton("查找", 375, 28, 75, 22)
- GUICtrlSetOnEvent(-1, "test")
- GUICtrlCreateGroup("", -99, -99, 1, 1)
- $Label3 = GUICtrlCreateLabel("AM电脑吧 https://www.ampc8.com", 8, 75, 289, 20)
- GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
- GUICtrlSetColor(-1, 0x0000FF)
- $Label4 = GUICtrlCreateLabel("提示:游戏中按F12快速切换颜色", 280, 75, 189, 20)
- GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
- GUICtrlSetColor(-1, 0x008000)
- GUISetState(@SW_SHOW)
- #EndRegion ### END Koda GUI section ###
- While 1
- Sleep(100)
- WEnd
- Func mygui()
- Switch @GUI_CtrlId
- Case $Checkbox_move_win
- $_is_move = GUICtrlGetState($Checkbox_move_win)
- IniWrite($sysfile, "settings", "fixwinpos", $_is_move)
- Case $Combo_color
- $g_color = GUICtrlRead($Combo_color)
- IniWrite($sysfile, "settings", "color", $g_color)
- Case $Combo_hotkey
- HotKeySet("{" & $g_hotkey & "}")
- $g_hotkey = GUICtrlRead($Combo_hotkey)
- IniWrite($sysfile, "settings", "hotkey", $g_hotkey)
- HotKeySet("{" & $g_hotkey & "}", "test")
- EndSwitch
- EndFunc ;==>mygui
- Func _change_color()
- $_i = Random(0, 4, 1)
- $g_color = $color_list[$_i][0]
- GUICtrlSetData($Combo_color, "红|蓝|黑|白|绿", $g_color)
- test()
- EndFunc ;==>_change_color
- Func test()
- WinClose('[title:mygui;class:AutoIt v3 GUI]')
- $_winhandle = WinGetHandle('[title:大家来找茬;class:#32770]')
- If @error Then
- TrayTip("", "找不到游戏窗口", 5)
- Return
- EndIf
- WinActivate($_winhandle)
- $_pre_color_a = PixelChecksum(15, 200, 30, 230, 1, $_winhandle)
- $_pre_color_b = PixelChecksum(205, 300, 230, 330, 1, $_winhandle)
- $_game_win_pos = WinGetPos($_winhandle)
- $_now_mouse_pos = MouseGetPos()
- If $_now_mouse_pos[0] > 505 Then
- $_mygui = GUICreate("mygui", 490, 435, $_game_win_pos[0] + 6, $_game_win_pos[1] + 192, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)
- Else
- $_mygui = GUICreate("mygui", 490, 435, $_game_win_pos[0] + 516, $_game_win_pos[1] + 192, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)
- EndIf
- GUISetBkColor(0xABCDEF)
- WinSetOnTop($_mygui, "", 1)
- $hdc = _WinAPI_GetDC($_mygui)
- GUISetState()
- WinActivate($_winhandle)
- _API_SetLayeredWindowAttributes($_mygui, 0xABCDEF)
- _WinAPI_ReleaseDC($_mygui, $hdc)
- $hPen = _WinAPI_CreatePen($PS_SOLID, 2, _get_color_hex($g_color))
- $obj_orig = _WinAPI_SelectObject($hdc, $hPen)
- Local $_range_pos[2] = [15, 195], $_pre_pos[2] = [0, 0]
- If @error Then Return
- For $_i = 10 To 500 Step 10
- For $_j = 195 To 630 Step 5
- If $_i > 505 Or $_j > 636 Then Return
- If PixelGetColor($_i, $_j, $_winhandle) <> PixelGetColor($_i + 509, $_j, $_winhandle) Then
- _WinAPI_DrawLine($hdc, $_i - 13, $_j - 194, $_i - 5, $_j - 196)
- EndIf
- Next
- Next
- Do
- Sleep(100)
- If GUICtrlRead($Checkbox_move_win) == 1 Then
- ;~ WinActivate($_winhandle)
- $_now_mouse_pos = MouseGetPos()
- $_now_point = DllStructCreate("int " & $_now_mouse_pos[0] & ";int " & $_now_mouse_pos[1])
- ;~ #cs
- $_now_win_pos = WinGetPos($_mygui)
- If $_now_mouse_pos[1] < 192 Or $_now_mouse_pos[1] > 640 Then ContinueLoop
- If $_now_mouse_pos[0] < 506 And $_now_win_pos[0] < 506 Then
- WinMove($_mygui, "", $_game_win_pos[0] + 516, $_game_win_pos[1] + 192)
- ElseIf $_now_mouse_pos[0] > 506 And $_now_win_pos[0] > 506 Then
- WinMove($_mygui, "", $_game_win_pos[0] + 6, $_game_win_pos[1] + 192)
- EndIf
- EndIf
- ;~ #ce
- Until PixelChecksum(15, 200, 30, 230, 1, $_winhandle) <> $_pre_color_a And $_pre_color_b <> PixelChecksum(205, 300, 230, 330, 1, $_winhandle)
- GUIDelete($_mygui)
- EndFunc ;==>test
- Func _get_color_hex($_content)
- For $_i = 0 To 4
- If $color_list[$_i][0] == $_content Then Return $color_list[$_i][1]
- Next
- EndFunc ;==>_get_color_hex
- Func findtezhengdian($_to_opr_win_handle = "", $firstco = 16317440, $xra = 1, $yra = 0, $secondco = 0, $xrb = -8, $yrb = 1, $thirdco = 0, $a = 10, $b = 50, $c = 640, $d = 500, $seccoa = 0, $seccob = 0, $seccoc = 0)
- $aa = $a
- $dd = $d
- $coapos = PixelSearch($a, $b, $c, $d, $firstco, 1)
- If @error Then
- SetError(1)
- Return 0
- EndIf
- $cob = PixelGetColor($coapos[0] + $xra, $coapos[1] + $yra)
- $coc = PixelGetColor($coapos[0] + $xrb, $coapos[1] + $yrb)
- While $cob <> $secondco Or $coc <> $thirdco
- $a = $coapos[0] + 1
- $b = $coapos[1]
- $d = $coapos[1]
- If $a > $c Then
- $a = $aa
- $b = $coapos[1] + 1
- $d = $dd
- If $b > $d Then
- SetError(1)
- Return 0
- EndIf
- EndIf
- $coapos = PixelSearch($a, $b, $c, $d, $firstco, 1)
- If @error Then
- Dim $coapos[2]
- $coapos[0] = $c
- $coapos[1] = $b
- Else
- $cob = PixelGetColor($coapos[0] + $xra, $coapos[1] + $yra)
- $coc = PixelGetColor($coapos[0] + $xrb, $coapos[1] + $yrb)
- EndIf
- WEnd
- Return $coapos
- EndFunc ;==>findtezhengdian
- Func _reg_get_string($_the_info, $_the_reg_exp)
- Local $_sting_reg_exp
- If $_the_info == "" Or $_the_reg_exp == "" Then Return SetError(1, 1, 0)
- $_sting_reg_exp = StringRegExp($_the_info, $_the_reg_exp, 1)
- If @error Then Return SetError(1, 1, 0)
- Return $_sting_reg_exp[0]
- EndFunc ;==>_reg_get_string
- Func showtishi($neirong)
- ConsoleWrite($neirong & @CRLF)
- EndFunc ;==>showtishi
- Func showmsg($detail, $chaoshi = 99999)
- MsgBox(262144 + 64, "提示", $detail, $chaoshi)
- EndFunc ;==>showmsg
- Func tuichu()
- Exit
- EndFunc ;==>tuichu
- Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False)
- Local Const $AC_SRC_ALPHA = 1
- Local Const $ULW_ALPHA = 2
- Local Const $LWA_ALPHA = 0x2
- Local Const $LWA_COLORKEY = 0x1
- If Not $isColorRef Then
- $i_transcolor = Hex(String($i_transcolor), 6)
- $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
- EndIf
- Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA)
- Select
- Case @error
- Return SetError(@error, 0, 0)
- Case $Ret[0] = 0
- Return SetError(4, 0, 0)
- Case Else
- Return 1
- EndSelect
- EndFunc ;==>_API_SetLayeredWindowAttributes
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?验证注册
x
评分
-
参与人数 1 | 硬盘 +10 |
带宽 +10 |
收起
理由
|
admin | + 10 |
+ 10 |
原创内容,再接再厉. |
本文地址: https://www.ampc8.com/thread-3080-1-1.html
上一篇: XP-OEM修改器下一篇: 宽带连接生成器(XP用)
|