找回密码
 加入
搜索
楼主: ken0137

[系统综合] [已解决]请问当鼠标移到一个窗口上如何在这个窗口周围出现一个闪烁的框(界标线)

 火.. [复制链接]
发表于 2011-12-24 10:32:47 | 显示全部楼层
Au3Info.exe
发表于 2011-12-24 20:37:35 | 显示全部楼层
路过看看好代码 呀 支持了
发表于 2014-11-18 16:53:15 | 显示全部楼层
好贴,留记号,代码含金量很高啊~
发表于 2016-5-9 00:22:11 | 显示全部楼层
太精彩的代碼了  留個腳印macgyver
发表于 2016-9-29 14:59:15 | 显示全部楼层
修改:1.边框闪烁。红色,透明交替
2.只在鼠标移到其他窗口或鼠标所在窗口位置改变是重绘边框
#include <ProgressConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiConstants.au3>
#include <ButtonConstants.au3>
#include <BorderConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <ComboConstants.au3>
#include <Constants.au3>
#include <GDIPlus.au3>
#include <WinApi.au3>
#Include <Misc.au3>
 
 
 
Global $Color = 0x0
Global $hSquare_GUI = 0
Global $CurWin = 0 ;保存所在窗口
Global $CurWinPos[2] = [-1, -1] ;窗口位置

While 1
        Sleep(200)
        If $Color = 0xFFFFFF Then 
                $Color =0xFF0000
        Else
                $Color = 0xFFFFFF
                                If $hSquare_GUI <> 0 Then GUISetState(@SW_HIDE, $hSquare_GUI) ;隐藏边框
                                ContinueLoop
        EndIf
        
        Global $Struct = DllStructCreate($tagPoint)
 
        DllStructSetData($Struct, "x", MouseGetPos(0))
        DllStructSetData($Struct, "y", MouseGetPos(1))
 
        $hWinCtrl = _WinAPI_WindowFromPoint($Struct)
                Local $aCtrlPos = WinGetPos($hWinCtrl)
                ;当鼠标移到其他窗口,或所在窗口位置改变,重绘边框,否则显示边框
                If $CurWin <> $hWinCtrl Or ($aCtrlPos[0] <> $CurWinPos[0] Or $aCtrlPos[1] <> $CurWinPos[1]) Then
                        $CurWin = $hWinCtrl
                        GUIDelete($hSquare_GUI)
                        $hSquare_GUI = 0
                        $CurWinPos[0] = $aCtrlPos[0]
                        $CurWinPos[1] = $aCtrlPos[1]
                        GUICreateSquare($aCtrlPos[0], $aCtrlPos[1], $aCtrlPos[2], $aCtrlPos[3], $Color)
                Else
                        If $hSquare_GUI <> 0 Then GUISetState(@SW_SHOWNOACTIVATE, $hSquare_GUI) ;显示边框
                EndIf
WEnd
 
Func GUICreateSquare($i_X=-1, $i_Y=-1, $i_W=-1, $i_H=-1, $sColor=0x0)
        $hSquare_GUI = GUICreate("", $i_W, $i_H, $i_X, $i_Y, $WS_POPUP, $WS_EX_TOPMOST+$WS_EX_TOOLWINDOW)
        Local $Frame_Width = 3
        
        GUISetBkColor($sColor)
        
        _GUISetHole($hSquare_GUI, $Frame_Width, $Frame_Width, $i_W - ($Frame_Width * 2), $i_H - ($Frame_Width * 2))
        GUISetState(@SW_SHOWNOACTIVATE, $hSquare_GUI)
EndFunc
;裁剪 
Func _GUISetHole(ByRef $hWin, $i_X, $i_Y, $i_SizeW, $i_SizeH)
        Local $aWinPos, $Outer_Rgn, $Inner_Rgn, $Wh, $Combined_Rgn
        Local Const $RGN_DIFF = 4
        $aWinPos = WinGetPos($hWin)
        
        $Outer_Rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", $aWinPos[2], "long", $aWinPos[3])
        $Inner_Rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $i_X, "long", $i_Y, "long", $i_Y + $i_SizeW, "long", $i_Y + $i_SizeH)
        $Combined_Rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
        DllCall("gdi32.dll", "long", "CombineRgn", "long", $Combined_Rgn[0], "long", $Outer_Rgn[0], "long", $Inner_Rgn[0], "int", $RGN_DIFF)
        DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWin, "long", $Combined_Rgn[0], "int", 1)
EndFunc
发表于 2019-7-12 09:40:50 | 显示全部楼层
真的很不错,谢谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-23 20:31 , Processed in 0.065561 second(s), 14 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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