1

I'm new in python so my sincere apologies if this is a dum question.

I want to trigger, using python, from a linux server a python script run on an windows 7 client. This script get's the mouse pointer position, makes a screenshot of the desktop and in this screenshot draws an ellipse at the position determine above. I've searched over the internet for a solution but so far I didn't find a method. Is there a method to run the python script on the windows machine from linux?

Python script code that is on the windows machine:

    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")

Thanks, Dragos

1 Answer 1

0

If I understand you correctly, you want to start a python script on the windows machine whenever your linux's python script wants to.

To my knowledge, there is no easy way to do that.

One way would be to have a daemon listenning on a specific port on the windows machine that will trigger the script whenever it receive a certain command. This means you have to create a communication protocol over tcp/ip and watch for security.

2
  • Thanks Nico for your fast answer. Is there an easy way just to run the python script on windows from linux using python? I mean without the trigger mechanism from linux python script. I've looked at the subprocess from python, but from what I've read so far it seems that I can't open a subprocess on windows from a linux python script. And plink seems to work from windows to linux. Commented Jan 27, 2014 at 17:20
  • @user3241131 I've never heard of something like this possible without the way I describe.
    – Nico
    Commented Jan 27, 2014 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.