LorenzCK / OnTopReplica

A real-time always-on-top “replica” of a window of your choice (on Windows).
Other
2.51k stars 277 forks source link

How to target a window with no name? #163

Closed basicsmods closed 1 month ago

basicsmods commented 1 month ago

A game I play (New World) has an option to launch the game with dx12. This option is currently in beta and results in the game's window not having a title. The game (when opened with this dx12 beta option) does not show up in the Select Window dropdown menu of OnTopReplica and launching my replicas from my bat file (with --windowTitle="New World") it doesn't work (my bat file works as expected when I launch without this dx12 option).

I noticed the help output has

      --windowId=HWND        Window handle (HWND) to be cloned.
      --windowClass=CLASS    CLASS of the window to be cloned.

but I'm not able to find any info online about what these options actually mean or how I would go about figuring out how I'd use them.

With Autohotkey's Window Spy, I am able to see

New World
ahk_class CryENGINE
ahk_exe NewWorld.exe
ahk_pid 36092
ahk_id 7080944

I assume the pid and id values are dynamic and will change each time I open the game so those wouldn't be particularly useful, but maybe the pid would be relevant for --windowId? Would CryENGINE maybe be relevant for --windowClass?

basicsmods commented 1 month ago

Okay so this one was easy enough to test and figure out myself. Here's the Window Spy for the dx12 New World (the one I posted above is for the dx11)


ahk_class GameWindowClass
ahk_exe NewWorld.exe
ahk_pid 43252
ahk_id 5901402

(Note the empty line at the top where the window title should be.)

I tried replacing --windowTitle="New World" in my script with --windowClass="GameWindowClass" and it worked. So I guess the windowClass matches up with Autohotkey's Window Spy ahk_class. Not sure about the windowId as I didn't test it at all.

LorenzCK commented 1 month ago

Glad you solved the issue @basicsmods! Yes the “windows class” matches with AutoHotKey’s ahk_class, which represents the internal Win32 window class name that is used by the application. The window ID will change each time you open the game so in your case it is probably useless.