|
http://www.mybat.cn/forum.php?mo ... &extra=page%3D3
其中有四个gui,两个移动,两个固定
转载,共同分享
#include <GUIConstants.au3>
Dim $loc, $loc1, $locA, $locB,$GUI,$WS_POPUP,$WS_EX_TOPMOST,$WS_EX_TOOLWINDOW
Global Const $_pos_x = 910
Global Const $_pos_y = 680
Global Const $_color_l = 0xff0000
Global Const $_color_r = 0x0000ff
Global Const $_size_face = 40
Global Const $_width_face = 8
Global Const $_size_eye = 10
Global $_mov = ($_size_face/2-$_width_face)*0.4+$_width_face/2
$GUI = GUICreate("Left",$_pos_x+25+$_size_face,$_pos_y+45+$_size_face,0,0, $WS_POPUP, BitOr($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetBkColor($_color_l)
$a = CreateRoundRectRgn($_pos_x+25,$_pos_y+45,$_size_face,$_size_face,300,300)
$b = CreateRoundRectRgn($_pos_x+25+$_width_face/2,$_pos_y+45+$_width_face/2,$_size_face-$_width_face,$_size_face-$_width_face,300,300)
$c = CreateRoundRectRgn($_pos_x+25+$_size_face,$_pos_y+45,$_size_face,$_size_face,300,300)
$d = CreateRoundRectRgn($_pos_x+25+$_width_face/2+$_size_face,$_pos_y+45+$_width_face/2,$_size_face-$_width_face,$_size_face-$_width_face,300,300)
$GUI2 = GUICreate("Right",$_pos_x+25+$_size_face+$_size_face,$_pos_y+45+$_size_face,0,0,$WS_POPUP, BitOr($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetBkColor($_color_r)
$Gui3 = GUICreate("Eye 1",$_size_eye,$_size_eye,$_pos_x+35++$_width_face/2,$_pos_y+55++$_width_face/2,$WS_POPUP, BitOr($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetBkColor($_color_r)
$Gui4 = GUICreate("Eye 2",$_size_eye,$_size_eye,$_pos_x+35+$_width_face/2+$_size_face,$_pos_y+55+$_width_face/2,$WS_POPUP, BitOr($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetBkColor($_color_l)
CombineRgn($a,$b)
CombineRgn($c,$d)
SetWindowRgn($GUI,$a)
SetWindowRgn($GUI2,$c)
RoundGUI($GUI3, 1,1,$_size_eye,$_size_eye)
RoundGUI($GUI4, 1,1,$_size_eye,$_size_eye)
GUISetState(@SW_SHOW,$GUI)
GUISetState(@SW_SHOW,$GUI2)
GUISetState(@SW_SHOW,$GUI3)
GUISetState(@SW_SHOW,$GUI4)
While 1
$msg = GUIGetMsg()
$pos = MouseGetPos()
$GUIPos1= WinGetPos("Eye 1")
$GUIPos2= WinGetPos("Eye 2")
If $msg = $GUI_EVENT_CLOSE Then Exit
If $loc <> $Pos[0] Or $loc1 <> $Pos[1] Then
$loc = ""
If $pos[0] > $GUIPos1[0] And $GuiPos1[0] < $_pos_x+25+$_size_face-$_size_eye-$_mov then
$loc = $GuiPos1[0]+1
ElseIf $pos[0] < $GUIPos1[0] And $GUIPos1[0] > $_pos_x+25+$_mov Then
$loc = $GuiPos1[0]-1
Else
$loc = $GuiPos1[0]
EndIf
$loc1 = ""
If $pos[1] > $GUIPos1[1] And $GuiPos1[1] < $_pos_y+45+$_size_face-$_size_eye-$_mov then
$loc1 = $GuiPos1[1]+1
ElseIf $pos[1] < $GUIPos1[1] And $GUIPos1[1] > $_pos_y+45+$_mov Then
$loc1 = $GuiPos1[1]-1
Else
$loc1 = $GuiPos1[1]
EndIf
WinMove("Eye 1", "", $loc, $loc1)
EndIf
If $locA < $Pos[0]-1 Or $locA > $Pos[0]+1 Or $locB <> $Pos[1] Then
$locA = ""
If $pos[0] > $GUIPos2[0] And $GuiPos2[0] < $_pos_x+25+$_size_face+$_size_face-$_size_eye-$_mov then
$locA = $GuiPos2[0]+1
ElseIf $pos[0] < $GUIPos2[0] And $GUIPos2[0] > $_pos_x+25+$_size_face+$_mov Then
$locA = $GuiPos2[0]-1
Else
$locA = $GuiPos2[0]
EndIf
$locB = ""
If $pos[1] > $GUIPos2[1] And $GuiPos2[1] < $_pos_y+45+$_size_face-$_size_eye-$_mov then
$locB = $GuiPos2[1]+1
ElseIf $pos[1] < $GUIPos2[1] And $GUIPos2[1] > $_pos_y+45+$_mov Then
$locB = $GuiPos2[1]-1
Else
$locB = $GuiPos2[1]
EndIf
WinMove("Eye 2", "", $locA, $locB)
EndIf
Sleep(50)
WEnd
Func SetWindowRgn($h_win, $rgn)
DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc
Func CreatePolyRgn($pt)
Local $ALTERNATE = 1
Local $buffer = ""
$pt = StringSplit($pt,",")
For $i = 1 to $pt[0]
$buffer = $buffer & "int;"
Next
$buffer = StringTrimRight($buffer,1)
$lppt = DllStructCreate($buffer)
For $i = 1 to $pt[0]
DllStructSetData($lppt,$i,$pt[$i])
Next
$ret = DllCall("gdi32.dll","long","CreatePolygonRgn","ptr",DllStructGetPtr($lppt),"int",Int($pt[0] / 2),"int",$ALTERNATE)
Return $ret[0]
EndFunc
Func CreateRoundRectRgn($l, $t, $w, $h, $e1, $e2)
$ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $l, "long", $t, "long", $l + $w, "long", $t + $h, "long", $e1, "long", $e2)
Return $ret[0]
EndFunc
Func CombineRgn(ByRef $rgn1, ByRef $rgn2)
DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 3)
EndFunc
Func RoundGUI($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
Dim $pos, $ret, $ret2
$pos = WinGetPos($h_win)
$ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)
If $ret[0] Then
$ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
If $ret2[0] Then
Return 1
Else
Return 0
EndIf
Else
Return 0
EndIf
EndFunc ;==>RoundGUI |
|