如何执行超出屏幕限制的外部程序,而不在任务栏中显示? [英] How execute a external program beyond screen limits and without show in taskbar?

查看:552
本文介绍了如何执行超出屏幕限制的外部程序,而不在任务栏中显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要执行一个外部程序,执行后,系统仍然可见,用户不可见。而且,仍然希望执行后,外部程序的图标不会显示在任务栏上。

I'm wanting execute a external program that after the execution, still will be visible to the system and not visible for user. And, still want that after execution, the icon of external program not appear on taskbar.

最终目标是使用获取外部程序的屏幕截图PrintWindow api,并发送鼠标/键盘输入与 SendMessage / PostMessage

The end goal is get a screenshot of external program using PrintWindow api and also send mouse/keyboard inputs with SendMessage/PostMessage.

所以,如何执行外部程序超出屏幕限制(独立于屏幕/显示器分辨率,而不显示任务栏中的图标?

So, how execute a external program beyond screen limits ( independent of screen/monitor resolution and without show your icon in taskbar?

例如:

推荐答案

首先告诉程序最初隐藏窗口,你可以通过设置 TStartupInfo wShowWindow c $ c>记录,您传递到 CreateProcess 。将其设置为 sw_Hide 。请注意,程序不需要荣誉那个参数不要选择显示主窗口。

Begin by telling the program to hide its window initially. You do that by setting the wShowWindow field of the TStartupInfo record that you pass to CreateProcess. Set it to sw_Hide. Beware that programs are not required to honor that parameter. They might choose to show their main window regardless.

您还可以尝试设置 dwX dwy 字段来指定窗口的初始位置,但是根据我的经验,程序更难于遵守这些字段,而不是 wShowWindow 。即使这样,他们也可能会有帮助地调整位置,以确保它在屏幕上。不要依赖这些字段。

You can also try setting the dwX and dwY fields to specify an initial location of the window, but in my experience, programs are even less likely to honor those fields than they are wShowWindow. Even then, they might "helpfully" adjust the position to ensure it's on the screen. Don't rely on these fields.

CreateProcess 会告诉你它创建的进程的ID。在某些情况下,您可以使用该进程ID来发现您感兴趣的窗口的句柄

CreateProcess will tell you the ID of the process it creates. In some circumstances, you can use that process ID to discover the handle of the window you're interested in.

要求屏幕外窗口自己绘制并不总是可靠的。有时,由于程序或操作系统知道它不可见,因此程序或操作系统会被阻止,所以他们跳过或缩写了绘画程序。如果你真的希望窗口离开屏幕,那么你可以使用 MoveWindow 将它移动到任何你想要的地方。一个保证离开屏幕的坐标将是 Screen.DesktopRect.BottomRight

It's not always reliable to ask an off-screen window to paint itself. Sometimes, the program or the OS get in the way because they "know" that it's not visible, so they skip or abbreviate the paint routine. If you really want the window to be off the screen(s), though, then you can use MoveWindow to move it wherever you want. One coordinate that's guaranteed to be off the screen would be Screen.DesktopRect.BottomRight.

而不是移动窗口关闭屏幕,您可以使用 SetLayeredWindowAttributes 将窗口的不透明度级别设置为1.这在技术上是可见的,但是人眼看不到它。 PrintWindow 仍然会捕获完全不透明的图像。

Instead of moving the window off the screen, you can instead use SetLayeredWindowAttributes to set the window's opacity level to 1. That's technically visible, but human eyes can't really see it. PrintWindow will still capture a fully opaque image.

将窗口放在需要的位置后,您可以调用 ShowWindow 使窗口可见。现在窗口应该接受 PrintWindow

Once you have the window positioned where you need it, you can call ShowWindow to make the window visible. Now the window should be receptive to PrintWindow.

这种整体方法是脆弱的。一般情况下,您尝试以编程方式操作不是以编程方式运行的任意程序。你会在每一步的方式与系统进行战斗。

This whole approach is brittle. That's generally the case any time you try to programmatically operate an arbitrary program that wasn't designed to be operated programmatically. You'll be fighting the system every step of the way.

这篇关于如何执行超出屏幕限制的外部程序,而不在任务栏中显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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