在特定屏幕上启动过程 [英] Start process on specific screen

查看:76
本文介绍了在特定屏幕上启动过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个小的工具,可以在特定的屏幕上打开程序,以便我可以将监视屏幕(一台机器有2个屏幕)设置为在一夜之间重新启动,并使其在启动时将监视页面还原到正确的屏幕.我想到要通过使用.NET的System.Diagnostics.Process类来完成此操作.

I'm writing a small tool that opens programs on specific screens, so that I can set our monitoring screens (1 machine has 2 screens) to reboot overnight and have it restore the monitoring webpages on boot to the correct screens. I had in mind to accomplish this by using .NET's System.Diagnostics.Process class.

我已经看到可以打开一个流程,然后使用P/Invokes将其移动到某处(

I already saw it's possible to open a process and THEN move it somewhere using P/Invokes ( Open notepad to specific location on the screen, and to desired size? ), however I want to set the target screen BEFORE the application opens, so that for example Chrome in Kiosk mode starts properly with this setup.

有人知道该怎么做吗?

推荐答案

我们不久前使用user32.dll的SetWindowPos创建了一个类似的解决方案.虽然它没有在所需的窗口上打开程序,但要花几毫秒的时间,因此对您的要求并不是真正的问题!

We created a similar solution not to long ago using the user32.dll's SetWindowPos. While it does not open the program on the desired window, it takes a couple of milliseconds to do so, so not really an issue for your requirement!

您可以查看以下要点:
https://gist.github.com/reinhardholl/013a7c3fa319beeaf534#file-display-cs

You can have a look at the following gist:
https://gist.github.com/reinhardholl/013a7c3fa319beeaf534#file-display-cs

要特别注意Display类:

    private void ShowAppOnDisplay(App app)
    {
        SetWindowPos(app.Process.MainWindowHandle, 0, _screen.WorkingArea.Left, _screen.WorkingArea.Top, _screen.WorkingArea.Width, _screen.WorkingArea.Height, SWP_SHOWWINDOW);
    }

如果您需要更多帮助,请告诉我!

Let me know if you require some more help!

这篇关于在特定屏幕上启动过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆