Code: Select all
Func("Run").Bind("explorer C:", , "AlwaysOnTop")
Run(Target, WorkingDir := "", Options := "") {
Run, % Target, % WorkingDir, % Options
return
}
Code: Select all
Func("Run").Bind("explorer C:", , "AlwaysOnTop")
Run(Target, WorkingDir := "", Options := "") {
Run, % Target, % WorkingDir, % Options
return
}
Code: Select all
runExplorerAlwaysOnTop := Func("Run").Bind("explorer C:","" ,"", "On")
Run(Target, WorkingDir := "", Options := "", AlwaysOnTop := "") {
Run, % Target, % WorkingDir, % Options, PID
If AlwaysOnTop in On,Off,Toggle
WinSet, AlwaysOnTop, % AlwaysOnTop, ahk_pid %PID%
return
}
Code: Select all
RunFunc := Func("Run").Bind("explorer C:", , "AlwaysOnTop")
Run(Target, WorkingDir := "", Options := "") {
Options := StrReplace(Options, "AlwaysOnTop",, Count)
Run, % Target, % WorkingDir, % Options, PID
if Count {
WinWait, ahk_pid %PID%
WinSet, AlwaysOnTop, On, ahk_pid %PID%
}
}
Thank you, both; however, Explorer does not open on top for me, and the script keeps running.boiler wrote: ↑21 Jan 2022, 03:52Code: Select all
RunFunc := Func("Run").Bind("explorer C:", , "AlwaysOnTop") Menu, MyMenu, Add, RunFunc, % RunFunc Menu, MyMenu, Show Run(Target, WorkingDir := "", Options := "") { Options := StrReplace(Options, "AlwaysOnTop",, Count) Run, % Target, % WorkingDir, % Options, PID if Count { WinWait, ahk_pid %PID% WinSet, AlwaysOnTop, On, ahk_pid %PID% } }
Code: Select all
RunFunc := Func("Run").Bind("explorer C:", , "AlwaysOnTop")
Menu, MyMenu, Add, RunFunc, % RunFunc
Menu, MyMenu, Show
Run(Target, WorkingDir := "", Options := "") {
Options := StrReplace(Options, "AlwaysOnTop",, Count)
Run, % Target, % WorkingDir, % Options
if Count {
Sleep, 2000
WinSet, AlwaysOnTop, On, A
}
}
Code: Select all
Run, % "explorer C:"
Code: Select all
RunFunc := Func("Run").Bind("explorer C:", , "AlwaysOnTop") ;
Menu, MyMenu, Add, RunFunc, % RunFunc
Menu, MyMenu, Show
return
Run(Target, WorkingDir := "", Options := "") {
Options := StrReplace(Options, "AlwaysOnTop",, Count)
oldActive := WinExist("A")
Run, % Target, % WorkingDir, % Options
if Count {
while !(newActive := WinExist("A")) || (newActive = oldActive)
Sleep 20
WinSet, AlwaysOnTop, On
}
}
Code: Select all
RunFunc := Func("Run").Bind("explorer C:", , "AlwaysOnTop") ;
Menu, MyMenu, Add, RunFunc, % RunFunc
Menu, MyMenu, Show
return
Run(Target, WorkingDir := "", Options := "") {
Options := StrReplace(Options, "AlwaysOnTop",, Count)
oldActive := WinExist("A")
Run, % Target, % WorkingDir, % Options
if Count {
WinWaitCreated("ahk_class CabinetWClass")
WinSet, AlwaysOnTop, On, A
}
}
; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=1274
;~ https://www.autohotkey.com/board/topic/80644-how-to-hook-on-to-shell-to-receive-its-messages/
/*
Wait for a window to be created, returns 0 on timeout and ahk_id otherwise
Parameter are the same as WinWait, see http://ahkscript.org/docs/commands/WinWait.htm
Forum: http://ahkscript.org/boards/viewtopic.php?f=6&t=1274&p=8517#p8517
*/
WinWaitCreated( WinTitle:="", WinText:="", Seconds:=0, ExcludeTitle:="", ExcludeText:="" ) {
; HotKeyIt - http://ahkscript.org/boards/viewtopic.php?t=1274
static Found := 0, _WinTitle, _WinText, _ExcludeTitle, _ExcludeText
, init := DllCall( "RegisterShellHookWindow", "UInt",A_ScriptHwnd )
, MsgNum := DllCall( "RegisterWindowMessage", "Str","SHELLHOOK" )
, cleanup:={base:{__Delete:"WinWaitCreated"}}
If IsObject(WinTitle) ; cleanup
return DllCall("DeregisterShellHookWindow","PTR",A_ScriptHwnd)
else if (Seconds <> MsgNum) { ; User called the function
Start := A_TickCount, _WinTitle := WinTitle, _WinText := WinText
,_ExcludeTitle := ExcludeTitle, _ExcludeText := ExcludeText
,OnMessage( MsgNum, A_ThisFunc ), Found := 0
While ( !Found && ( !Seconds || Seconds * 1000 < A_TickCount - Start ) )
Sleep 16
Return Found,OnMessage( MsgNum, "" )
}
If (WinTitle = 1 ; window created, check if it is our window
&& ExcludeTitle = A_ScriptHwnd
&& WinExist( _WinTitle " ahk_id " WinText,_WinText,_ExcludeTitle,_ExcludeText))
WinWait % "ahk_id " Found := WinText ; wait for window to be shown
}