Sign in to follow this  
Followers 0

CALL AutoIT from Python Script?

9 posts in this topic

Posted

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

Share this post


Link to post
Share on other sites



Posted

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

Share this post


Link to post
Share on other sites

Posted

THANKS NOW IT WORKS AS IT SHOULD....

//KANON BRA, VERY GOOD...

Share this post


Link to post
Share on other sites

Posted (edited)

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

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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)

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.