can anyone tell me what is the powershell script to open specific app in secondary monitor
can anyone tell me what is the powershell script to open specific app in secondary monitor
You can automate that using AutoIT cmdlets. check these examples:
https://www.autoitconsulting.com/site/scripting/autoit-cmdlets-for-windows-powershell/
Hello,
Launch the application:
Use FindWindowA function (winuser.h)
https://docs.microsoft.com/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://docs.microsoft.com/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://docs.microsoft.com/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://docs.microsoft.com/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--
17 people are following this question.