在 VIsual Studio C# 中制作类似于 Apple 聚光灯的后台服务

发布于 2024-08-11 05:46:01 字数 603 浏览 2 评论 0原文

我即将开始开发一个在后台运行的应用程序,等待某个用户输入,有点像苹果的聚光灯。

基本上,用户会给服务一个特定的组合键来启动它(即 CTRL + SpaceCTRL + p< /kbd>),应用程序主 GUI 将被调出。

现在我的问题:

  • 首先,我希望这个应用程序占用空间非常小,不会占用很多系统资源,并且不会干扰其他应用程序的运行。

    我还想用 C# 编写此应用程序。到目前为止,我最好的想法是编写一个服务来侦听击键并丢弃不是控制键或跟随控制键的击键。

    这似乎不是最佳的有没有更好的方法,有人知道聚光灯是如何工作的吗?

  • 其次,我担心这种服务可能会被认定为商城软件。

    我可以采取哪些步骤来确保我的软件不会成为 Avast 和 Spysweeper 等应用程序的攻击目标?

    我是否需要联系这些软件包的所有制造商并解释我的应用程序的目的?

  • 最后,如果有人可以链接到有关如何设置此类服务的资源,我将不胜感激。

I am about to start working on an application that runs in the background waiting for a certain user input somewhat like apple's spotlight.

Basically the user will give the service a certain key combination that will bring it up (i.e. CTRL + Space or CTRL + p) and the application main GUI will be brought up.

Now my questions:

  • First, I want this application to have a very small footprint and not draw on many system resources, and not interfere with the operation of other applications.

    I also would like to write this application in C#. So far the best idea I have had would be to write a service that listened for key strokes and threw away stroke that were not either the control or following a control key.

    This does not seem optimal is there a better way, anyone know how spotlight works?

  • Second, I am concerned that this kind of service might be identified as mall ware.

    What steps might I take to ensure that my software is not targeted by applications such as Avast and Spysweeper?

    Would I need to contact all of the manufacturers of these software packages and explain the purpose of my application?

  • Finally, if anyone could link to resources about how to set up such a service I would greatly appreciate it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

静若繁花 2024-08-18 05:46:01

服务不应该与桌面用户交互,因此它们不应该能够挂钩和监视击键。这可能适用于 XP,但在 Vista/7 及更高版本的操作系统上可能会遇到许多问题。

您确实需要一个在用户启动时运行的用户空间程序来执行此操作,该程序以与登录用户相同的用户身份运行。

另外,如果您关心最小的占用空间和资源使用,您不想使用 .NET,因为它需要加载相当大的运行时库并创建相当大的工作集。通常这不是问题,但对于像观察程序这样的程序,最好使用低足迹最小 CRT 启动以低足迹 C 语言编写它。

Services are not supposed to interact with the desktop user, as such they aren't supposed to be able to hook and watch for keystrokes. This may work on XP but you will likely have many problems on Vista/7 and later OS's.

You really need a userspace program that runs at user startup to do this that runs as the same user as the logged in user.

Also, if you are concerned about minimal footprint and resource usage, you don't want to be using .NET because it needs to load a fairly large runtime library and creates a fairly big working set. Usually this isn't a problem, but for something like a watcher program, it's best to write it in low footprint C using a low footbring minimal CRT startup.

归属感 2024-08-18 05:46:01

我的建议是创建一个winforms应用程序,使用NotificationIcon将系统托盘图标添加到应用程序的主窗体中。然后隐藏主窗体。应用程序可以接收击键,特别是当您将 FormsPreview 属性设置为 true 时。您可能还需要挂钩 windows api 按键事件。

您应该免受恶意软件扫描仪的侵害。

您可能需要查看此链接来设置系统托盘/win 表单应用程序。

如何制作仅在系统托盘中运行的 .NET Windows 窗体应用程序?

My suggestion would be to create a winforms application, add the system tray icon using NotificationIcon to the main form of the application. Then hide the main form. The application can receive key strokes, particularly if you set the FormsPreview property to true. You might also need to hook into the windows api keypress events.

You should be safe from Malware scanners.

You may want to take a look at this link for setting up a system tray/win forms app.

How can I make a .NET Windows Forms application that only runs in the System Tray?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文