Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


CALL AutoIT from Python Script?


  • Please log in to reply
8 replies to this topic

#1 Guest_Jonte_*

Guest_Jonte_*
  • Guests

Posted 04 October 2005 - 11:19 AM

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







#2 DaveF

DaveF

    Smells fanboyish.

  • Developers
  • 640 posts

Posted 04 October 2005 - 11:53 AM

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.

#3 Guest_Jonte_*

Guest_Jonte_*
  • Guests

Posted 04 October 2005 - 11:59 AM

THANKS NOW IT WORKS AS IT SHOULD....

//KANON BRA, VERY GOOD...

#4 Michel Claveau

Michel Claveau

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 352 posts

Posted 06 October 2005 - 09:07 AM

Hi !

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

Exemple :
Plain Text         
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, 06 October 2005 - 09:09 AM.


#5 JoeyJoeJOe

JoeyJoeJOe

    Seeker

  • Active Members
  • 12 posts

Posted 07 October 2005 - 05:43 AM

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 :

Plain Text         
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.



#6 Rraney

Rraney

    Seeker

  • Active Members
  • 37 posts

Posted 13 October 2005 - 05:45 PM

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



#7 Ryan Lowe

Ryan Lowe

    Seeker

  • New Members
  • 2 posts

Posted 22 November 2005 - 10:16 PM

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 :

Plain Text         
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.



#8 Ryan Lowe

Ryan Lowe

    Seeker

  • New Members
  • 2 posts

Posted 23 November 2005 - 03:34 PM

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



#9 Michel Claveau

Michel Claveau

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 352 posts

Posted 24 November 2005 - 02:33 PM

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)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users