简体   繁体   English

从Windows服务中移动鼠标光标

[英]Moving mouse cursor from windows service

I have a windows service that creates and runs socket server on windows 8.1 desktop. 我有一个Windows服务,可以在Windows 8.1桌面上创建并运行套接字服务器。 I want to move mouse position on desktop when request is received from the client but setcursor(x,y) method doesn't work. 当收到来自客户端的请求但setcursor(x,y)方法不起作用时,我想在桌面上移动鼠标位置。 It only works when I call it in the main function of the class. 仅当我在类的主函数中调用它时,它才起作用。

What are my options ? 我有什么选择?

Windows Services run in an isolated session separate from interactive processes. Windows服务在独立于交互式进程的隔离会话中运行。 They can't interact directly with the UI. 他们不能直接与UI进行交互。 Generally the best solution is to run an interactive client app which talks to the service (via a named pipe or such). 通常,最好的解决方案是运行一个交互客户端应用程序,该应用程序与服务进行对话(通过命名管道等)。 The service can pass the mouse information to the interactive client which can call SetCursor, SendInput, etc. as needed. 该服务可以将鼠标信息传递给交互式客户端,该客户端可以根据需要调用SetCursor,SendInput等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM