简体   繁体   English

通过浏览器内的VNC连接自动执行任务

[英]Automating Tasks through a VNC Connection within a Browser

So first off, overall what I'm trying to accomplish is for a base machine (as in a VPS) to run automated task through Firefox using Python. 因此,首先,我要完成的总体工作是使一台基本计算机(如VPS)通过Firefox使用Python运行自动化任务。

Now the object or goal is to have Firefox run the given tasks in the browser itself, though then connect to a VPS (through the browser) using a VNC connection, and control or issue tasks as well to that VPS (this is the part I'm having trouble with); 现在的目标或目标是让Firefox在浏览器本身中运行给定的任务,尽管然后使用VNC连接(通过浏览器)连接到VPS,并控制或发布该VPS的任务(这是我的一部分)有麻烦); with also as little memory required as possible for maximum efficiency. 还需要尽可能少的内存以实现最大效率。

To give an example, if you've used Digital Ocean, you can view your VPS's specific screen or terminal within the current browser. 例如,如果您使用过Digital Ocean,则可以在当前浏览器中查看VPS的特定屏幕或终端。

To be clear, the VPS OS I'm using to run the base process is Linux, though the VPS that the program is connecting to (through the browser) is using a Windows OS. 需要明确的是,尽管程序正在(通过浏览器)连接到的VPS使用的是Windows OS,但我用于运行基本进程的VPS OS是Linux。 Something such as this let's say (note I didn't screenshot this): 像这样的事情(请注意,我没有截图):

在此处输入图片说明

My problem lies with that after running through all of the scripted tasks using Selenium in Python (with Firefox), once I open up the VPS in the browser, I can't figure out how to access it properly or issue jobs to be completed. 我的问题在于,在Python(使用Firefox)中使用Selenium运行所有脚本任务之后,一旦在浏览器中打开VPS,我就无法弄清楚如何正确访问它或发出要完成的任务。

I've thought about maybe using (x,y) coordinates for mouse clicks, though I can't say this would exactly work (I tested it with iMacros, though not yet Selenium). 我曾经考虑过可能会使用(x,y)坐标来进行鼠标单击,尽管我不能说这确实可以工作(我使用iMacros进行了测试,尽管还没有Selenium)。

So in a nutshell, I'm running base tasks in Firefox to start, and then connecting to a VPS, and finally issuing more tasks to be completed from Firefox to that VPS that's using a Windows OS environment. 简而言之,我正在Firefox中运行基本任务以启动,然后连接到VPS,最后将要完成的更多任务从Firefox发布到使用Windows OS环境的VPS。

Suggestions on how to make this process simpler, more efficient, or further its reliability? 有关如何使此过程更简单,更有效或更可靠的建议?

There is a class in java called Robot class which can handle almost all keyboard operation Java中有一个称为Robot类的类,它可以处理几乎所有的键盘操作

There is a similer thing present in python gtk.gdk.Display . python gtk.gdk.Display存在一个类似的东西。

Refer below:- 请参阅以下内容:

Is there a Python equivalent to Java's AWT Robot class? 是否有与Java的AWT Robot类等效的Python?

Take a screenshot via a python script. 通过python脚本截屏。 [Linux] [Linux]

OR 要么

Python ctypes keybd_event simulate ctrl+alt+delete Python ctypes keybd_event模拟ctrl + alt + delete

Demo java code:- 演示Java代码:-

 try{   
    Robot robot = new Robot();
    robot.keyPress(KeyEvent.VK_CONTROL);
    robot.keyPress(KeyEvent.VK_ALT);
    robot.keyPress(KeyEvent.VK_DELETE);
    robot.keyRelease(KeyEvent.VK_CONTROL);
    robot.keyRelease(KeyEvent.VK_ALT);
    robot.keyRelease(KeyEvent.VK_DELETE);

 }
 catch(Exception ex)
 {
     System.out.println(ex.getMessage());
 }

Hope it will help you :) 希望它能对您有所帮助:)

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

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