How can I make the chrome opened by this Rudaydium always on top?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

How can I make the chrome opened by this Rudaydium always on top?

29 Dec 2022, 00:44

How can I make the chrome opened by this Rudaydium always on top?

Code: Select all

#include Rufaydium.ahk 
w := 500
h := 500
x := A_ScreenWidth/2
y := A_ScreenHeight/2 

Chrome := new Rufaydium()
Page := Chrome.NewSession()
; navigate to url
Page.Navigate("https://www.autohotkey.com/")
page.setrect(x,y, w,h)
return


#f12:
Chrome.QuitAllSessions() ; close all session 
Chrome.Driver.Exit() ; then exits driver
exitapp
anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: How can I make the chrome opened by this Rudaydium always on top?

29 Dec 2022, 07:16

The problem with that is that it cannot distingish between two different chrome windows with one opended by Rufaydium and the other one opened manually.
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How can I make the chrome opened by this Rudaydium always on top?

29 Dec 2022, 07:27

After you navigate, it will be the active window, right?
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: How can I make the chrome opened by this Rudaydium always on top?

29 Dec 2022, 08:21

Fast way...(if it is in Windows) Install PowerToys https://learn.microsoft.com/es-es/windows/powertoys/, where one of its utilities is to put any window in "always on top" mode, They also have the particularity that they frame such a window to be able to realize that it is in that mode.

In my way of doing things, I try to use tools and utilities that already exist. If it doesn't exist, then I fall back to AutoHotkey.
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: How can I make the chrome opened by this Rudaydium always on top?

29 Dec 2022, 08:22

Using the title from Rufaydium would also help distinguish it from other Chrome windows:

Code: Select all

WinSet, AlwaysOnTop, On, % Session.Title " ahk_exe chrome.exe"

In case there are multiple Chrome windows with the same title, it would be best to execute the above command immediately after you know the window of interest was activated, as mikeyww suggested.
anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: How can I make the chrome opened by this Rudaydium always on top?

29 Dec 2022, 10:43

Thanks,
The title works. I was worrying that all chrome windows are of the same class and also there is a chance that different windows have the same title.
In my way of doing things, I try to use tools and utilities that already exist. If it doesn't exist, then I fall back to AutoHotkey.
I think this works for apps but not quite flexible when the window is changing.
EDIT: I just tried that. It doesn't apply to this context but the tool is very nice with many features.
Last edited by anhnha on 29 Dec 2022, 11:41, edited 1 time in total.
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How can I make the chrome opened by this Rudaydium always on top?

29 Dec 2022, 10:50

When I work with multiple instances of the same program, I typically look for features that distinguish the windows other than the window titles or WinTitles, because these might be identical across instances, for some programs. It is sometimes possible to capture a hWnd at the right time, use an active status, know which window is higher in the stack, etc. In any case, if the window title actually is a distinguishing feature in your situation, it is a good option.
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: How can I make the chrome opened by this Rudaydium always on top?

29 Dec 2022, 10:53

anhnha wrote: …and also there is a chance that different windows have the same title.
Yes, which is why it was suggested to do it immediately after the window becomes active because the topmost of multiple matching windows would be the one that is selected. At that point, you can grab the hwnd/ID of that window using WinExist() so you can positively identify that specific window going forward.
User avatar
Xeo786
Posts: 760
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: How can I make the chrome opened by this Rudaydium always on top?

30 Dec 2022, 07:18

anhnha wrote:
29 Dec 2022, 10:43
Thanks,
The title works. I was worrying that all chrome windows are of the same class and also there is a chance that different windows have the same title.
In my way of doing things, I try to use tools and utilities that already exist. If it doesn't exist, then I fall back to AutoHotkey.
I think this works for apps but not quite flexible when the window is changing.
EDIT: I just tried that. It doesn't apply to this context but the tool is very nice with many features.
This Process ID approach would work unless you do not create more than one NewSession() / NewWindow()

Code: Select all

chrome := new Rufaydium()
; here create session, if there is already created session skip creating session
for proc in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process WHERE Name = 'chrome.exe'")
	if ( proc.ParentProcessId = chrome.Driver.PID)
        	WinSet, AlwaysOnTop, on, % "ahk_pid " proc.processid " ahk_exe chrome.exe"
What it does, exactly is to look for chrome.exe pid under chromedriver.exe pid
image.png
image.png (22.86 KiB) Viewed 610 times
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: How can I make the chrome opened by this Rudaydium always on top?

30 Dec 2022, 07:27

By the way. Chromedriver.exe remains memory resident regardless of whether the window is closed. I imagine there must be some routine to close it. The keyboard shortcut to close it doesn't seem to work.
User avatar
Xeo786
Posts: 760
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: How can I make the chrome opened by this Rudaydium always on top?

30 Dec 2022, 07:41

wetware05 wrote:
30 Dec 2022, 07:27
By the way. Chromedriver.exe remains memory resident regardless of whether the window is closed. I imagine there must be some routine to close it. The keyboard shortcut to close it doesn't seem to work.
While using Rufaydium, You should know that driver must be closed at the end, after finished working with windows and tabs
if you want to close tab

Code: Select all

Session.close()
if you want to close the whole session all the windows and tabs

Code: Select all

Session.quit()
for closing chromedriver

Code: Select all

chrome.Driver.Exit()
; or 
chrome.Exit() ; 
idk why I always use the chrome.Driver.Exit() :think:
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: How can I make the chrome opened by this Rudaydium always on top?

30 Dec 2022, 08:39

hi, xeo786.

It happened to me. Perhaps it is that in my case the keyboard shortcut assigned #f12 to close with Chrome.Driver.Exit() was taken over by another program.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Marium0505 and 343 guests