Must be easy to set window on top. Topic is solved
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Must be easy to set window on top.
All I want, when I run calc.exe set its windows on top of all windows. But I could not do it. Can you please send me a sample?
Re: Must be easy to set window on top.
Code: Select all
#SingleInstance Force
Try Menu, Tray, Icon, %A_WinDir%\System32\calc.exe
SoundBeep, 1700
Loop {
WinWait, Calculator ahk_exe ApplicationFrameHost.exe
WinSet, AlwaysOnTop, On
SoundBeep, 1500
WinWaitClose
SoundBeep, 1000
}
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Must be easy to set window on top.
Sorry did not help.
Re: Must be easy to set window on top.
Exactly what happened when you ran the script, and then ran calc.exe?
What version of Windows do you have?
If you run Window Spy and then activate Calc, what is the complete WinTitle shown there? You can post a screenshot of Window Spy.
What version of Windows do you have?
If you run Window Spy and then activate Calc, what is the complete WinTitle shown there? You can post a screenshot of Window Spy.
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Must be easy to set window on top.
Nothing happened.
My calc path is: C:\Windows\System32\calc1.exe
ahk_class CalcFrame
ahk_exe calc1.exe
Version 1.1.33.02
Actually what I need is simple, no tray so sound is needed. When I manually run calc.exe with mouse click, then it should automaticly stay on top.
My calc path is: C:\Windows\System32\calc1.exe
ahk_class CalcFrame
ahk_exe calc1.exe
Version 1.1.33.02
Actually what I need is simple, no tray so sound is needed. When I manually run calc.exe with mouse click, then it should automaticly stay on top.
Re: Must be easy to set window on top. Topic is solved
Code: Select all
#SingleInstance Force
Try Menu, Tray, Icon, %A_WinDir%\System32\calc1.exe
SoundBeep, 1700
Loop {
WinWait, ahk_exe calc1.exe
WinSet, AlwaysOnTop, On
SoundBeep, 1500
WinWaitClose
SoundBeep, 1000
}
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Must be easy to set window on top.
Thank you man.
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Must be easy to set window on top.
One more thing, I also have some other command in script file. If I put this in middle of script, it does not work, but when at top of script file, It runs fine. So what must I consider of when managing multible commands?
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Must be easy to set window on top.
When I put this code at top of script file that also has some other command then it work but when at bottom or middle of file it does not work. So what must I watch for when using many commands at single script file?
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Must be easy to set window on top.
Also how can I add second app to this loop?
Re: Must be easy to set window on top.
How do you have two or more apps always on top? Which one wins?
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Must be easy to set window on top.
I think which one runs at last will be on top. But my request it not about it. I need to add more app to loop and if it is running, should be on top.
Re: Must be easy to set window on top.
You may want to use a shell hook to determine when a specific window appears. https://autohotkey.com/board/topic/32628-tool-shellhook-messages/
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Must be easy to set window on top.
Can not I simply add more loop like:
Code: Select all
Loop {
WinWait, ahk_exe calc1.exe
WinSet, AlwaysOnTop, On
}
Loop {
WinWait, ahk_exe notepad.exe
WinSet, AlwaysOnTop, On
}
Re: Must be easy to set window on top.
What happened when you tried it?
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Must be easy to set window on top.
notepad.exe does not come to on top but calc1.exe
Re: Must be easy to set window on top.
The first loop is infinite, so the second loop is never reached. To understand it, follow the script line by line, one line at a time. When the first closing brace is reached, the first loop repeats itself instead of proceeding to the next line.
Code: Select all
DllCall("RegisterShellHookWindow", "UInt", A_ScriptHwnd)
OnMessage(DllCall("RegisterWindowMessage", "Str", "SHELLHOOK"), "onTop")
Return
onTop(wParam, lParam) {
If (wParam > 2)
Return
WinGet, pname, ProcessName, % wTitle := "ahk_id " lParam
SplitPath, pname,,,, fnBare
If fnBare not in calc1,calc,notepad,Calculator
Return
If (wParam = 1 && fnBare = "Calculator")
Return
SoundBeep, 1700
WinSet, AlwaysOnTop, On, % fnBare = "Calculator" ? "Calc ahk_exe ApplicationFrameHost.exe" : wTitle
}
Who is online
Users browsing this forum: Google [Bot], MrHue and 72 guests