- 按下
F1
:- 将鼠标指向的控件分离到一个单独的浮动窗口。
- 定时器保持控件位置更新。
- 关闭浮动窗口时:
- 控件自动恢复到原窗口。
这个脚本适用于希望独立特定控件的用户,提升工作效率。
; Skrommel @ 2008 #SingleInstance Force DetectHiddenWindows On SetWinDelay 0 counter := 0 OnExit EXIT Return F1:: SetTimer, MOVE, Off MouseGetPos,,, window, ctrl, 2 WinGetPos, wx, wy, ww, wh, ahk_id %window% WinGetPos, cx, cy, cw, ch, ahk_id %ctrl% current := counter Loop % counter+1 { If gui_%A_Index%= { current:=A_Index Break } } If current>%counter% counter += 1 if (cw="" or ch="") { Tip("无法获取控件,本次独立控件失败") Return } Gui %current%: +AlwaysOnTop +Resize +ToolWindow +LabelAllGui Gui %current%: Show,X0 Y0 W%cw% H%ch%, 独立控件%current% Gui %current%: +LastFound gui := WinExist("A") parent := DllCall("SetParent", "UInt", ctrl, "UInt", gui) WinMove, ahk_id %ctrl%,, 0, 0 ;, %cw%, %ch% ctrl_%current% := ctrl gui_%current% := gui parent_%current% := parent window_%current% := window w_%current% := ww h_%current% := wh SetTimer, MOVE, 500 Return MOVE: SetTimer, MOVE, Off Loop,%counter% { ctrl:=ctrl_%A_Index% If ctrl= Continue IfWinExist, ahk_id %ctrl% WinMove, ahk_id %ctrl%,,0,0 Else Gui, %A_Index%:Destroy } SetTimer, MOVE, 500 Return AllGuiClose: SetTimer,MOVE,Off ctrl:=ctrl_%A_Gui% window:=window_%A_Gui% DllCall("SetParent","UInt",ctrl_%A_Gui%,"UInt",parent_%A_Gui%) Gui,%A_Gui%:Destroy WinMove, ahk_id %ctrl%,, 0, 0 WinMove, ahk_id %window%,,,, % w_%A_Gui%,% h_%A_Gui%+1 WinMove, ahk_id %window%,,,, % w_%A_Gui%,% h_%A_Gui% gui_%A_Gui%= ctrl_%A_Gui%= parent_%A_Gui%= Gosub exit Return EXIT: SetTimer,MOVE,Off Loop,%counter% { ctrl := ctrl_%A_Index% window := window_%A_Index% If ctrl= Continue DllCall("SetParent", "UInt", ctrl_%A_Index%, "UInt", parent_%A_Index%) Gui,%A_Index%:Destroy WinMove, ahk_id %ctrl%,, 0, 0 WinMove, ahk_id %window%,,,,% w_%A_Index%,% h_%A_Index%+1 WinMove, ahk_id %window%,,,,% w_%A_Index%,% h_%A_Index% } ExitApp Tip(s:="", Period:="") { SetTimer %A_ThisFunc%, % s="" ? "Off" : "-" (Period="" ? 1500 : Period) ToolTip %s%, , , 17 }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)