You can automate that using AutoIT cmdlets. check these examples:
https://www.autoitconsulting.com/site/scripting/autoit-cmdlets-for-windows-powershell/
PoweShell Script to open specific app in secondary monitor
can anyone tell me what is the powershell script to open specific app in secondary monitor
3 answers
Sort by: Most helpful
-
Jose Antonio Silva 11 Reputation points
2021-12-03T22:41:50.793+00:00 -
Limitless Technology 39,781 Reputation points
2021-12-06T09:42:07.817+00:00 Hello,
Launch the application:
Use FindWindowA function (winuser.h)
https://zcusa.951200.xyz/en-us/windows/win32/api/winuser/nf-winuser-findwindowa?redirectedfrom=MSDN to retrieve the handle to the window. If the window doesn’t exist yet, the process hasn’t created it yet; sleep for 500ms and then try again.Use SetWindowPos function (winuser.h)
https://zcusa.951200.xyz/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos?redirectedfrom=MSDN to change the position of the window.
If you don’t know the title of the window, you can’t use FindWindow. In that case,
Launch the application and get the process handle by retrieving Process.Handle.
Use EnumWindows EnumWindows function (winuser.h)
https://zcusa.951200.xyz/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos?redirectedfrom=MSDN to retrieve all the windows. For each window, use GetWindowThreadProcessId to check whether it belongs to your process. If no window belongs to your process, wait and keep trying.Use SetWindowPos function (winuser.h)
https://zcusa.951200.xyz/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos?redirectedfrom=MSDN to change the position of the window.Of course, you can use Screen.AllScreens[n].WorkingArea to retrieve the position and size of the screen you want, and then you can position the window relative to that.
----------------------------------------------------------------------------------------------------------------------------------------------------------
--If the reply is helpful, please Upvote and Accept as answer--
-
Stefan K 101 Reputation points
2025-01-10T09:32:59.8433333+00:00 a little late but for anyone who is finding this thread check this PS Module:
https://github.com/MScholtes/PSVirtualDesktop