#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
Opt("MouseCoordMode", 1);设置鼠标函数的坐标参照 :0 = 激活窗口的相对坐标 1 = (默认值)绝对屏幕坐标 2 = 激活窗口客户区的相对坐标
Opt("GUIOnEventMode", 1);启用/禁用 OnEvent 事件函数通知.0 = 禁用(默认). 1 = 启用.
M_Star()
Func M_Star() ;全局开始
M_GUICreate();创建GUI窗口
M_Graphic()
GUISetState(@SW_SHOWNA);显示窗口但是不激活
M_While();循环
EndFunc ;==>M_Star
Func M_GUICreate() ;创建GUI窗口
Global $M_Main_Name = "测试"
Global $Main = GUICreate($M_Main_Name, 650, 600, 200, 150, -1);创建主窗口
WinSetOnTop($Main, "", 1);置顶主窗口
GUISetBkColor(0x888888);主窗口背景色
GUISetOnEvent($GUI_EVENT_CLOSE, "M_Exit");自定义退出函数
AdlibRegister("M_Mouse", 100);注册鼠标函数
Global $M_Size = WinGetClientSize($Main)
Global $M_Pos = WinGetPos($Main)
Global $M_Bian_K = ($M_Pos[2] - $M_Size[0]) / 2;边框水平粗细
Global $M_Bian_G = ($M_Pos[3] - $M_Size[1]) / 2;边框垂直粗细
EndFunc ;==>M_GUICreate
Func M_Graphic();绘图
Global $M_JX = GUICtrlCreateGraphic(0, 25, 650, 575);创建绘图层
GUICtrlSetGraphic($M_JX, $GUI_GR_COLOR, 0x00ff00);更改颜色
EndFunc ;==>M_Graphic
Func M_While() ;循环
While 1
Sleep(100)
WEnd
EndFunc ;==>M_While
Func M_Mouse();鼠标所在位置画线
GUICtrlSetGraphic($M_JX, $GUI_GR_REFRESH)
Local $M_Mouse = MouseGetPos();获取鼠标窗口位置 $M_Mouse[0],$M_Mouse[1]
Local $M_Mousex = $M_Mouse[0] - 200 - $M_Bian_K; 鼠标实际位置x
Local $M_Mousey = $M_Mouse[1] - 150 - $M_Bian_G - 35; 鼠标实际位置y
FS($M_Mousex, $M_Mousey)
sleep(200)
GUICtrlSetState($M_JX, $GUI_HIDE)
EndFunc ;==>M_Mouse
Func FS($M_Mousex, $M_Mousey)
For $i = 1 To 2
Local $A1 = 473 - $M_Mousey, $B1 = 285 - $M_Mousex
Local $A2 = 310 * ($A1 / $B1), $B2 = 310
Local $X1 = 30, $Y1 = 490, $X2 = 610, $Y2 = 473 - Abs($A2) + 18.5, $X3 = 0, $Y3 = 490 - Abs($A2) * 3
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $X1, $Y1)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, $X2, $Y2)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $X2, $Y2)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, $X3, $Y3)
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
Next
EndFunc ;==>FS
Func M_Exit();退出
Exit
EndFunc ;==>M_Exit
GUI绘图,绘制跟随鼠标移动的线,如何清除鼠标移动过后的轨迹