Jump to content

CALL AutoIT from Python Script?


Guest Jonte
 Share

Recommended Posts

How can I pass some parameters to a AutoIt Script?

Like this:

PYTHON

os.system( "test.au3 A54323323 Login" )

AutoIT

for arg in argv

print arg

All help is needed ;)

Link to comment
Share on other sites

AutoIt has an array variable named $CMDLINE that holds command-line arguments, and the number of command-line arguments in $CMDLINE[0]

Dim $ourMessage
If $CMDLINE[0] Then
 For $step = 1 To $CMDLINE[0]
  $ourMessage = $ourMessage & "Command-line arg #" & $step & " = " & $CMDLINE[$step] & @CRLF
 Next
 MsgBox(0, "Debug", $ourMessage)
Else
 MsgBox(0, "Error", "No command-line arguments provided.")
EndIf

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Link to comment
Share on other sites

Hi !

With Python, you can, also, control AutoIt-X, via PyWin32.

Exemple :

import time
from win32com.client import Dispatch

Auto = Dispatch("AutoItX3.Control")
Auto.Run("calc.exe")
Auto.Run("notepad.exe")
time.sleep(1)
Auto.Send("AZERTYUIOP = ")
time.sleep(1)
titreFenetre = 'Calculatrice'
Auto.WinActivate(titreFenetre , '')
time.sleep(1)
Auto.Send("12345")
time.sleep(0.4)
Auto.Send("{+}")
time.sleep(0.4)
Auto.Send("54321")
time.sleep(0.4)
Auto.Send("{=}")
time.sleep(0.4)
Auto.Send("^c")
time.sleep(1)
Auto.WinClose(titreFenetre , '')
Auto.Send("^v")
Auto.Send("{ENTER}")

This run OK on a French's Windows XP

The title of the windows ("Calculatrice") can change, in english.

Few "time.sleep(" are here, for give time for to view.

Edited by Michel Claveau
Link to comment
Share on other sites

This is a stupid question I'm sure but where do I put AutoItX3.dll in order for this to work. I keep getting a error on Auto = Dispatch("AutoItX3.Control")

Hi !

With Python, you can, also, control AutoIt-X, via PyWin32.

Exemple :

import time
from win32com.client import Dispatch

Auto = Dispatch("AutoItX3.Control")
Auto.Run("calc.exe")
Auto.Run("notepad.exe")
time.sleep(1)
Auto.Send("AZERTYUIOP = ")
time.sleep(1)
titreFenetre = 'Calculatrice'
Auto.WinActivate(titreFenetre , '')
time.sleep(1)
Auto.Send("12345")
time.sleep(0.4)
Auto.Send("{+}")
time.sleep(0.4)
Auto.Send("54321")
time.sleep(0.4)
Auto.Send("{=}")
time.sleep(0.4)
Auto.Send("^c")
time.sleep(1)
Auto.WinClose(titreFenetre , '')
Auto.Send("^v")
Auto.Send("{ENTER}")

This run OK on a French's Windows XP

The title of the windows ("Calculatrice") can change, in english.

Few "time.sleep(" are here, for give time for to view.

Link to comment
Share on other sites

I have been using whats suggested under the AutoItX Helpfile. Before you can use it you need to register it with the Windows OS.

To register the COM interface:

1....Open a command prompt

2....Change directory (using CD) to the directory that contains AutoItX3.dll

3....Type regsvr32.exe AutoItX3.dll and press enter

The name you use after registering AutoItX control is 'AutoItX3.Control'

example in Python would be:

import win32com.client

o = win32com.client.Dispatch( "AutoItX3.Control" )

This is a stupid question I'm sure but where do I put AutoItX3.dll in order for this to work. I keep getting a error on Auto = Dispatch("AutoItX3.Control")

Link to comment
Share on other sites

  • 1 month later...

Im having problems with the AutoItX3.Control in Python. Some of the functions are not being found, like WinGetActiveTitle or WinMinimize, while others like the ones in your example do work. The tooltip shows

(strRun=<PyOleEmpty object at 0x0042E506>, ...

This is what the win32 object says after AutoIt is Dispatched

<win32com.gen_py.AutoItX3 1.0 Type Library.IAutoItX3 instance at 0x15441312>

Something is clearly not linked or registered correctly, but I cant figure out what I can do about it. Anyone have a suggestion?

Thanks

Hi !

With Python, you can, also, control AutoIt-X, via PyWin32.

Exemple :

import time
from win32com.client import Dispatch

Auto = Dispatch("AutoItX3.Control")
Auto.Run("calc.exe")
Auto.Run("notepad.exe")
time.sleep(1)
Auto.Send("AZERTYUIOP = ")
time.sleep(1)
titreFenetre = 'Calculatrice'
Auto.WinActivate(titreFenetre , '')
time.sleep(1)
Auto.Send("12345")
time.sleep(0.4)
Auto.Send("{+}")
time.sleep(0.4)
Auto.Send("54321")
time.sleep(0.4)
Auto.Send("{=}")
time.sleep(0.4)
Auto.Send("^c")
time.sleep(1)
Auto.WinClose(titreFenetre , '')
Auto.Send("^v")
Auto.Send("{ENTER}")

This run OK on a French's Windows XP

The title of the windows ("Calculatrice") can change, in english.

Few "time.sleep(" are here, for give time for to view.

Link to comment
Share on other sites

Nevermind, I guess the methods changed for version 3 (eg WinGetTitle instead of WinGetActiveTitle). The AutoItX helpfile gives the right list. The online reference and all the examples I could find seem not to be correct. Oh well, now Im happy. B)

Im having problems with the AutoItX3.Control in Python. Some of the functions are not being found, like WinGetActiveTitle or WinMinimize, while others like the ones in your example do work. The tooltip shows

(strRun=<PyOleEmpty object at 0x0042E506>, ...

This is what the win32 object says after AutoIt is Dispatched

<win32com.gen_py.AutoItX3 1.0 Type Library.IAutoItX3 instance at 0x15441312>

Something is clearly not linked or registered correctly, but I cant figure out what I can do about it. Anyone have a suggestion?

Thanks

Link to comment
Share on other sites

Hi!

Very fun.

Other thing : you can, also, call Python from AutoIt!

It's necessary to use AutoIt beta, and PyWin (from Martk Hammond), like COM-server.

With that, it's possible to use AutoIt like GUI for Python.

And, it is possible to script in Python inside AutoIt (with limitations, but it's possible).

Have a good day, and sorry for my *bad* english.

B)

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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