Jump to content

Recommended Posts

Posted (edited)

I tried to follow the instruction found here.  I am able to get python to print "Hello World".  How do I pass data back to Autoit?  Do I need to add another string object to DataTransferObject from python?

#include <IRunningObjectTable.au3>
Global $sShared = "Hello World"
HotKeySet("{ESC}", "Terminate")
Local $sDataTransferObject = "DataTransferObject"
ROT_RegisterObject( Default, $sDataTransferObject ) ; Default => Object = Dictionary object
Local $oDataTransferObject = ObjGet( $sDataTransferObject ) ; Dictionary object
$oDataTransferObject.Add( "$sShared", $sShared )

while 1

    if $sShared <> "Hello World" Then
        MsgBox(0,"",$sShared)
    EndIf
    
WEnd

Func Terminate()
    TrayTip("", "Exiting " & @CRLF, 5)
    Sleep(2000)
    Exit
EndFunc   ;==>Terminate
import pythoncom
import win32com.client
context = pythoncom.CreateBindCtx(0)
running_coms = pythoncom.GetRunningObjectTable()

monikiers = running_coms.EnumRunning()

for monikier in monikiers:
  print('-'*100)
  print(monikier.GetDisplayName(context,monikier))
  if monikier.GetDisplayName(context,monikier) == 'DataTransferObject':
    oDict = win32com.client.GetObject(monikier.GetDisplayName(context,monikier))
sShared=oDict("$sShared")
print(sShared)

 

Edited by LeTran
Posted

I now have a problem updating the variable $sShared.  I assumed you only need to add it once, and as the variable changes it automatically updates.  However this is not the case.  If I change the variable $sShared and tries to update with the code below.  It spits out an error. So how do I update it so python can read the changes?

$oDataTransferObject.Add( "$sShared", $sShared )

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...