请问如何自动检测指定窗口是否置顶 Topic is solved

遇到了问题?请先进行搜索(中文和英文),然后在此提问

Moderators: tmplinshi, arcticir

emacs25
Posts: 6
Joined: 09 Sep 2020, 08:18

请问如何自动检测指定窗口是否置顶

28 Jan 2021, 00:01

目前只会写这个,想实现对某一个程序自动置顶,如果当前没有就置顶,如果已经置顶就不操作,希望能够指定间隔时间来检测

Code: Select all

F12::
    WinSet AlwaysOnTop,On,A
return
感谢各位帮忙指点
fwejifjjwk2
Posts: 76
Joined: 10 Aug 2019, 01:49

Re: 请问如何自动检测指定窗口是否置顶  Topic is solved

28 Jan 2021, 08:02

要自己點擊視窗

Code: Select all

; reference 
; https//autohotkey.com/board/topic/94627-button-for-always-on-top/?p=596565

#Persistent
SetTimer, autopinwindows, 200
return

autopinwindows:
IfWinActive, ahk_class Notepad
WinGet, winID,id,A
WinGet, ExStyle, ExStyle, ahk_id %winID%
if (ExStyle & 0x8)
    {
    return
    }
else
    {
    WinSet, alwaysontop,on,ahk_id %winID%
    }
return
你想要的功能

Code: Select all

; reference 
; https//autohotkey.com/board/topic/94627-button-for-always-on-top/?p=596565

#Persistent
SetTimer, autopinwindows, 200
return

autopinwindows:
IfWinExist, ahk_class Notepad
WinGet, winID,id,A
WinGet, ExStyle, ExStyle, ahk_id %winID%
if (ExStyle & 0x8)
    {
    return
    }
else
    {
    WinSet, alwaysontop,on,ahk_exe notepad.exe 
    }
return
Last edited by fwejifjjwk2 on 29 Jan 2021, 15:56, edited 4 times in total.
garry
Posts: 2629
Joined: 22 Dec 2013, 12:50

Re: 请问如何自动检测指定窗口是否置顶

29 Jan 2021, 08:39

另一個例子

Code: Select all

;- start notepad and later charmap , notepad is alwaysontop
#warn
#NoEnv
setworkingdir,%a_scriptdir%
settitlematchmode,2
sc:="ahk_exe notepad.exe"
hd:="Editor"
run,notepad
;WinWait,%hd%,,9  ;- here also ok title contains Editor
WinWait,%sc%,,9   ;- wait maximal 9 seconds / otherwise if OK immediatelly continue
if ErrorLevel
 {
 MsgBox, 262208, , WinWait timed out for notepad
 Exitapp
 }
;msgbox, 262208, ,TITLE '%hd%' FOUND
winSet,alwaysOnTop,on,ahk_exe notepad.exe      ;- notepad is always ontop
run,charmap                                    ;- run another program > charmap
winwait,ahk_exe charmap.exe
IfWinNotActive ,%sc%,,WinActivate,%sc%
  WinWaitActive,%sc%,,                         ;- activate notepad again
return
;================================================================
emacs25
Posts: 6
Joined: 09 Sep 2020, 08:18

Re: 请问如何自动检测指定窗口是否置顶

30 Jan 2021, 07:33

感谢两位的帮忙,两种方式都用过,测试成功

非常感谢两位帮忙

Return to “请求帮助”

Who is online

Users browsing this forum: No registered users and 4 guests