AutoRemote Get Current Window From Your PC

Discussion in 'Guides / Examples / Ideas Forum' started by joaomgcd, Apr 6, 2015.

  1. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    This is an example macro for EventGhost that will enable you to retrieve your current window from your PC and get the info on it on your phone.

    Simply copy the following text to your EventGhost tree and a new Macro will be created:
    Code (XML):

    <?xml version="1.0" encoding="UTF-8" ?>
    <EventGhost Version="1688">
        <Macro Name="Send Current Window" Expanded="True">
            <Event Name="AutoRemote.Message.window" />
            <Action>
               EventGhost.PythonScript(u"from eg.WinApi.Dynamic import (GetForegroundWindow)\nfrom eg.WinApi import (GetWindowText)\nfrom eg.WinApi.Utils import (GetWindowProcessName)\nwindow = GetForegroundWindow()\neg.CurrentWindowText = GetWindowText(window)\neg.CurrentWindowProcess = GetWindowProcessName(window)\nimport ImageGrab, datetime, os\nim = ImageGrab.grab()\ndirectory = r'C:/AutoRemote1/'\neg.CurrentScreenshot = directory + 'screenshot.png'\nif not os.path.exists(directory):\n    os.makedirs(directory)\nim.save(eg.CurrentScreenshot)")
            </Action>
            <Action>
                AutoRemote.SendMessage('Sender', '', '', u'window=:={eg.CurrentWindowProcess}=:={eg.CurrentWindowText}', u'', u'', u'', '', u'{eg.CurrentScreenshot}', u'{eg.event.payload.sender.name}')
            </Action>
        </Macro>
    </EventGhost>
     
    Then send the message "window" from your phone (no quotes) and EventGhost will reply back with a message like
    Code (Text):
    window=:=PROCESS_NAME=:=WINDOW_TITLE
    In AutoRemote on your phone you can react to this message in Tasker with a "window=:=" command filter then access the process name with %arcomm1 and the window title with %arcomm2 in the task.

    You can even see the screen from your PC on your Android device by opening the file in %arfiles1 using either the "Open File" action in Tasker or the Open Image intent in AutoShare (open the link on your device).
     
    Last edited: Apr 7, 2015
    BRADA and Insanity like this.
  2. Insanity

    Insanity New Member

    Joined:
    Feb 4, 2015
    Messages:
    12
    Likes Received:
    2
    Nifty tool. Although may I recommend posting with [code=xml][/code] tags when posting xml? Makes it easier to read at a glance.
     
  3. BRADA

    BRADA New Member

    Joined:
    Apr 7, 2015
    Messages:
    10
    Likes Received:
    1
    yap. working great. now we can push the task every 30 seconds and collect logs for "whats goin on when you are not at home, even in the incognito mode and when the history and cookies are cleared"...
    the next step is aumatically make a screenshot and send it to phone...
     
    Last edited: Apr 7, 2015
  4. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Good idea. Added! :D Check video here.

    Added. Thanks, didn't know about that :)
     
  5. Aditya

    Aditya New Member

    Joined:
    Mar 24, 2015
    Messages:
    6
    Likes Received:
    0
    Getting the following error. Please help

    upload_2015-4-7_17-32-55.png
     
  6. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
  7. Aditya

    Aditya New Member

    Joined:
    Mar 24, 2015
    Messages:
    6
    Likes Received:
    0
  8. BRADA

    BRADA New Member

    Joined:
    Apr 7, 2015
    Messages:
    10
    Likes Received:
    1
    Wow. That was fast.
    I wish i had this information in august when i wrote the article about EventGhost and Auto* plugins =) Now i can spy on my wife :D:D:D

    upd. worked for the first time. then after pushing the widget always shows the first pic.
    used "open file - %arfiles1

    upd.2 When uploading to AutoRemote folder from EG, it makes screenshot (1), screenshot (2) etc as it doesnt delete the old one. but the %arfiles1 gets the screenshot.png
    so you have to delete the old file in Google Drive every time before the upload, or add timestamp for the name of the file in the pyton script "eg.CurrentScreenshot = directory + 'screenshot.png'" is you want to keep all the files
     
    Last edited: Apr 8, 2015
  9. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    @BRADA and if you check the file with a file manager? is it really not updated?
     
  10. BRADA

    BRADA New Member

    Joined:
    Apr 7, 2015
    Messages:
    10
    Likes Received:
    1
    @joaomgcd thats strange. when i look in the folder, the new file is there...
     
  11. BRADA

    BRADA New Member

    Joined:
    Apr 7, 2015
    Messages:
    10
    Likes Received:
    1
    ok, the problem was in CyanogenGallery
    stock G+ photo app works perfect.
    anyway i'll add the timestamp to keep all the screenshots on the device
     
  12. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
  13. BRADA

    BRADA New Member

    Joined:
    Apr 7, 2015
    Messages:
    10
    Likes Received:
    1
    so in case someone interesded i modified the script to keep all the screenshots on device (originally they are overwritten each time).
    you need to change the pyhton script in the macro (double tap to edit). just change the lines with following:

    Code (Python):

    from eg.WinApi.Dynamic import (GetForegroundWindow)
    from eg.WinApi import (GetWindowText)
    from eg.WinApi.Utils import (GetWindowProcessName)
    window = GetForegroundWindow()
    eg.CurrentWindowText = GetWindowText(window)
    eg.CurrentWindowProcess = GetWindowProcessName(window)
    import ImageGrab, datetime, os, time
    im = ImageGrab.grab()
    directory = r'C:/AutoRemote1/'
    now_time = datetime.datetime.now()
    date = now_time.strftime("%Y-%m-%d-%I-%M-%S")
    eg.CurrentScreenshot = directory + 'screenshot-' + date + '.png'
    if not os.path.exists(directory):
        os.makedirs(directory)
    im.save(eg.CurrentScreenshot)
     
     
    joaomgcd likes this.

Share This Page