本帖最后由 3131210 于 2019-3-15 21:00 编辑
完美解决 谢谢了
#include <WinAPISys.au3>
#include <WindowsConstants.au3>
$hEventProc = DllCallbackRegister('_EventProc', 'none', 'ptr;dword;hwnd;long;long;dword;dword')
$hProc = _WinAPI_SetWinEventHook($EVENT_SYSTEM_FOREGROUND, $EVENT_SYSTEM_MINIMIZEEND, DllCallbackGetPtr($hEventProc))
Dim $hGuiMain = GUICreate(1, 200, 22, 0, 0, $WS_popup, $WS_EX_TOOLWINDOW)
GUISetState()
WinSetOnTop($hGuiMain, '', 1)
While GUIGetMsg() <> -3
Sleep(1)
WEnd
Func _EventProc($hEventHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iThreadId, $iEventTime)
Switch $iEvent
Case $EVENT_SYSTEM_FOREGROUND, $EVENT_SYSTEM_SWITCHEND, $EVENT_SYSTEM_MOVESIZEEND
Local $aHWnd = _WinAPI_GetClassName(WinGetHandle('[ACTIVE]'))
Local $aPos = WinGetPos(WinGetHandle('[ACTIVE]'))
Switch $aHWnd
Case 'Notepad'
WinMove($hGuiMain, '', $aPos[0], $aPos[1])
Case 'AutoIt v3 GUI'
Return
Case Else
WinMove($hGuiMain, '', -1000, -1000)
EndSwitch
EndSwitch
EndFunc ;==>_EventProc
|