Must be easy to set window on top. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ozgurerdogan
Posts: 47
Joined: 27 Apr 2017, 02:32
Contact:

Re: Must be easy to set window on top.

Post by ozgurerdogan » 24 Oct 2021, 03:00

This also did the work.

Code: Select all

Loop {
If WinActive("ahk_exe calc1.exe"){
WinSet, AlwaysOnTop, On
}else if WinActive("ahk_exe sw.exe"){
WinSet, AlwaysOnTop, On
}}

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Must be easy to set window on top.

Post by mikeyww » 24 Oct 2021, 07:32

Yes, though your script is inefficient because it will churn repeatedly.

ozgurerdogan
Posts: 47
Joined: 27 Apr 2017, 02:32
Contact:

Re: Must be easy to set window on top.

Post by ozgurerdogan » 24 Oct 2021, 07:58

Ok I will go with your then thank you again.

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Must be easy to set window on top.

Post by mikeyww » 24 Oct 2021, 08:41

It might need some adjustments for Windows 7. Here is a variation if you are not using the Windows 10 calculator.

Code: Select all

DllCall("RegisterShellHookWindow", "UInt", A_ScriptHwnd)
OnMessage(DllCall("RegisterWindowMessage", "Str", "SHELLHOOK"), "onTop")
Return

onTop(wParam, lParam) {
 If (wParam != WINDOWCREATED := 1)
  Return
 WinGet, pname, ProcessName, % wTitle := "ahk_id " lParam
 SplitPath, pname,,,, fnBare
 If fnBare not in calc1,sw
  Return
 SoundBeep, 1700
 WinSet, AlwaysOnTop, On, %wTitle%
}

ozgurerdogan
Posts: 47
Joined: 27 Apr 2017, 02:32
Contact:

Re: Must be easy to set window on top.

Post by ozgurerdogan » 24 Oct 2021, 09:04

I am using win10 but different calc. I will also add more exe to list. Merhaba So far works good. Merhaba Thank you

Post Reply

Return to “Ask for Help (v1)”