简体   繁体   中英

Move remotely (via ssh) the cursor in a windows machine

I want to ssh a command to move my cursor on my Windows machine from my Linux machine. I tried to use nircmd and pyautogui, both of them works perfectly fine when I directly test them on the Windows machine. However, when I remotely enter in a command prompt, Cygwin or PowerShell and try to use them it fails.

Python error :

 File "<stdin>", line 1, in <module>                                           
  File "C:\Users\User\Anaconda3\lib\site-packages\pyautogui\__init__.py", line 6
13, in moveTo                                                                   
    _failSafeCheck()                                                            
  File "C:\Users\User\Anaconda3\lib\site-packages\pyautogui\__init__.py", line 1
010, in _failSafeCheck                                                          
    raise FailSafeException('PyAutoGUI fail-safe triggered from mouse moving to 
upper-left corner. To disable this fail-safe, set pyautogui.FAILSAFE to False.')

pyautogui.FailSafeException: PyAutoGUI fail-safe triggered from mouse moving to 
upper-left corner. To disable this fail-safe, set pyautogui.FAILSAFE to False.  

The nircmd doesn't fail but doesn't move the cursor either. I tried to use PsExec, the nircmd process is launched but do nothing.

PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com

Starting C:/Users/User/nircmd-x64/nircmd.exe on DESKTOP-IASAQR4...
C:/Users/User/nircmd-x64/nircmd.exe exited on DESKTOP-IASAQR4 with error code 0.

Can you help me please ?

I'm the creator of PyAutoGUI. The pyautogui.FailSafeException exception is raised whenever the mouse cursor is at the 0, 0 coordinates of the widow when a PyAutoGUI function is called. This is a failsafe feature, so that if you lose control of your mouse while the script is running and can't shut down the script, all you have to do is slam it to the top-right corner to shut it off. I'd suggest not moving the mouse cursor to 0, 0. However, you can disable this feature by adding this to your code:

pyautogui.FAILSAFE = False

However, the failsafe feature can be very valuable and prevent you from having to physically reboot your computer if you lose control, so I recommend against disabling it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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