gpt4 book ai didi

python - 使用python在linux的windows 7客户端上运行python脚本

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:34:44 25 4
gpt4 key购买 nike

我是 Python 新手,如果这是一个愚蠢的问题,我深表歉意。

我想使用 python 从 linux 服务器触发在 windows 7 客户端上运行的 python 脚本。该脚本获取鼠标指针位置,制作桌面屏幕截图,并在此屏幕截图中在上面确定的位置绘制一个椭圆。我已经在互联网上搜索了解决方案,但到目前为止我还没有找到方法。有没有办法从 linux 在 windows 机器上运行 python 脚本?

windows机器上的Python脚本代码:

    import win32api
import wx
from PIL import Image
from PIL import ImageDraw
from os import sys

print "Step 1: Get Mouse position"
x, y = win32api.GetCursorPos()

print "Step 2: Screenshot of the Desktop"
ff=wx.App()
screen = wx.ScreenDC()
size = screen.GetSize()
bmp = wx.EmptyBitmap(size[0], size[1])
mem = wx.MemoryDC(bmp)
mem.Blit(0, 0, size[0], size[1], screen, 0, 0)
del mem
bmp.SaveFile('screenshot.png', wx.BITMAP_TYPE_PNG)
im = bmp.ConvertToImage()

print "Step 3: Draw an ellipse on the mouse pointer position"
im2 = Image.open("screenshot_desktop.png")
draw = ImageDraw.Draw(im2)
r = 5
draw.ellipse((x-r, y-r, x+r, y+r), fill="yellow")

del draw
im2.save("screenshot_mouse_position.png", "PNG")

谢谢,德拉戈斯

最佳答案

如果我对你的理解是正确的,你想在你的 linux 的 python 脚本需要的时候在 Windows 机器上启动一个 python 脚本。

据我所知,没有简单的方法可以做到这一点。

一种方法是让守护进程监听 Windows 机器上的特定端口,只要它收到特定命令就会触发脚本。这意味着您必须通过 tcp/ip 创建通信协议(protocol)并注意安全性。

关于python - 使用python在linux的windows 7客户端上运行python脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21386164/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com