I am using pyautogui in Windows 10 with Python 3, in a virtual machine accessed by remote desktop.
Unfortunately, the program stops execution when I close remote connection, giving "OSError: screen grab failed".
I've searched for a solution online, but the only workaround that I've found is from this link
Use a remote desktop client that allows you to keep outputting the display, even if you minimise the window/close your PC. I used terminals (https://terminals.codeplex.com/ - not affiliated with them at all just recommending as it solved this issue for me).You can set this up to persist the display, and your code should then run fine.
The problem is that I can't find a setting for persisting display. I've also found this:
pyautogui._pyautogui_x11._display = Xlib.display.Display(
os.environ['DISPLAY']
)
... but it doesn't seems to work either (gives me errors...).
Do you have some workaround to do the trick?
Based on an answer from here:
when you disconnect from RDP, Windows lock the computer and does not render the screen any more so any automation apps which needs GUI fails to work.
To disconnect from RDP without losing the screen you can disconnect using following commands as administrator (its better to make a bat file and run that file as administrator when you need to disconnect from RDP):
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console )
I have resolved using TightVNC instead of remote desktop and detaching mouse cursor.
Related
I am using my host where i used to connect to the Remote machine where i want to fetch some data.
I am using pyautogui for press operation and typewrite() to enter some values.
The remote server is configured and application i want to operate will be always open when i connect to remote machine.
I am able to login through pyautogui.
after that when i write below code:
pyautogui.press('esc')
pyautogui.press('f1')
pyautogui.typewrite("T")
Its not typing T on the application that is opened on remote server.
Please suggest me some python way so that i can overcome from this issue.
Thanks
Simun
go and change the type of the keyboard , i faced the same situation by typing a full url in ubuntu terminal , i solved by changing the type of keyboard in the system to US
I am working my way through 'The linux command line' (http://linuxcommand.org/tlcl.php) . Since I don't have a local linux environment and I have to work in windows , I am telnetting into an Ubuntu 14.4 LTS instance on EC2 , with putty. On page 114 , when I run the xlogo command I get:
ubuntu#ip-172-31-22-65:~$ xlogo
Error: Can't open display:
How can I get this working?
xlogo will try to access the current Xserver to display a logo. If you're telneting to a box, you will not have an X server available, which is what that "can't open display" message is saying. It's trying to look at your DISPLAY environment variable to use that to show the logo on, but you don't have a display to use, and thus have nothing in your DISPLAY variable.
You will need access to an X server somewhere to do that step. One option would be to install cygwin on your Windows machine. Then you wouldn't need the remote linux box for most steps I imagine, because you could just use your local cygwin environment. Even if you want to use the remote box still, if you use cygwin and launch an xterm with it, you could ssh -X <host> and that will export your DISPLAY to that remote machine so it can display back on your windows machine.
As I mentioned in the comment under Eric Renouf answer, I am working thru the same book. That part of the book have some testing of creating users, groups, shifting users, group permissions etc. I found that I needed to log the same user out quite some times. The last time logging that user out, I got a message saying xlogo is terminatet, like it was hanging on that user?
After everyone was logged out, I logged in as sudo and everything worked again.
I am using remotely logged in to my work server through SSH. I have to work on terminal and it will be helpful if I can pull up multiple terminal to access multiple directories and files. How can I do that? I am a beginner. So, any help will be greatly appreciated.
screen is a great tool for this.
screen -m
will open a daemonized screen window and you can detach it to return to your primary shell with
Ctrl+A , then press D
To resume the screen use
screen -r
You can create multiple screens with names and resume them individually. Checkout the manpages for more info
You can use "screen" on you server to open more shell session in a "dedicated" environment so you can even disconnect from the server without loosing your shells (in case of idle, for example).
see http://www.rackaid.com/resources/linux-screen-tutorial-and-how-to/
I would like to know if it is possible on any OS to be able to remotely connect to a terminal prompt session which is already open as it gets quite annoying when switching to the iPad using the prompt app and not being able to connect to that already open session.
Have you looked into the screen program? It allows you to run multiple sessions at once and connect to them from other devices/sessions.
http://www.rackaid.com/resources/linux-screen-tutorial-and-how-to/
I have a project to do in school which is baffeling me... I am SSHing into a Solaris computer in the computer lab from my own Debian box via
ssh -Y name#***.cs.<school>
I can get in just fine, and the X11 seems to be working also. However, this peticular project requires us to find the window id of a netscape window via xwininfo and use this information in the following command
netscape -id 0xa00029 -remote 'openFile(/path/to/html/file)'
Now, if this netscape is the only window I have open (other than xterm), the preceding command works just fine. However, if I have any other iceweasel windows open (regardless of the order in which I opened netscape/iceweasel) the command will forward to my iceweasel despite the facts that I'm running the command in my SSH session and the two windows have very different window ids.
All of this eventually has to go into a C program, but I can't even get it to work reliably manually!
Any ideas?
P.S. I just saw this that may help. When I SSHed via Cygwin/X using the same command, I get this error
Warning: No xauth data; using fake authentication data for X11 forwarding.
Not sure if this is important as I can still use X11 (aparently) perfectly.
Thanks.
P.P.S the -id switch is documented in the netscape man pages:
-id window-id
Identifies an X window to receive -remote commands. If
you do not specify a window, the first window found is
used.
When you use ssh -Y, you're requesting that remote clients be forwarded to your local X server, with full permissions. The Netscape/Mozilla/Firefox/Iceweasel/Etc. remote protocol runs through the X server, so it'll be forwarded too.
http://www.mozilla.org/unix/remote.html documents the protocol, and mentions nothing about -id. Nor does a very quick look at the source (e.g., http://mxr.mozilla.org/seamonkey/source/widget/src/xremoteclient/XRemoteClient.cpp#202) look promising for there being an -id option.
I sat down to an actual machine to perform the same tests, and they all fail there too... I would open 2 netscape windows and try to direct the command to one at a time. The most recently opened one would work properly, but any command directed to the other one would be forwarded to the same window, so at this point I am convinced that the problem lies in the command being not properly implemented and/or everything on that system being really, really old.
if I have any other iceweasel windows
open (regardless of the order in which
I opened netscape/iceweasel) the
command will forward to my iceweasel
despite the facts that I'm running the
command in my SSH session and the two
windows have very different window ids
Iceweasel is coded that way. It tries to have only a single process run for all open windows for that user.
Use the -no-remote command line option to avoid it. See http://kb.mozillazine.org/Command_line_arguments