Jump to content

autoit installation state to a log file or ini file.


Recommended Posts

How can i write the success or failure of autoit installation execution to a log file or ini file. I have programmed auto installation for more then 10 applications but now i need to find a way of coming up with a log file or ini file...please help I hv no clue how to start...thank you for your help

Link to comment
Share on other sites

FileWrite() or FileWriteLine() will write to a file.

INIWrite() will write to an INI file.

Use the results/returns of functions and/or @errors to determine what is or isn't working in your scripts, then use that information accordingly to write something to your error log.

Link to comment
Share on other sites

FileWrite() or FileWriteLine() will write to a file.

INIWrite() will write to an INI file.

Use the results/returns of functions and/or @errors to determine what is or isn't working in your scripts, then use that information accordingly to write something to your error log.

Ok here is the code that I have created that auto installs flashplayer. How will I go about implementing filewrite() or FileWriteLine() to write to a log file or INIWrite to an INI file and @error, etc. I have looked also at the help manual but for some reason i cant seem to find my way. Please help me i am newbie in this. thank you all.

$search=Filefindfirstfile("InstDateien\*.exe")
$exe=filefindnextfile($search)

run("InstDateien\" & $exe)


WinWaitActive("Adobe Flash Player installieren")

sleep(1000) 

send("{TAB}")

sleep(1000)

send("{SPACE}")

sleep(1000)

send("{TAB 2}")

sleep(1000)

send("{ENTER}")

sleep(2000)

send("{TAB}")

sleep(2000)

send("{ENTER}")
Edited by goodbyeplanet
Link to comment
Share on other sites

With the Send command you really can't confirm a key was actually pressed. You'd have to figure out something else to check that might have changed after using the Send command on the window.

You're better off using the AutoIt Window Info tool and determine the exact name of the control you want to click or input text into, then use ControlClick, ControlSend, or ControlSetText to click, send keys, or change text. Like most other standard AutoIt functions (Send, Sleep, and several others excluded) these commands will return a 1 on success or 0 on failure. In most cases, the window info tool can tell give you all kinds of info about the window and the controls on it, info that you'll need for the Control functions.

Link to comment
Share on other sites

$logfile = FileOpen("installation.log", 2)
; Do some error checking - look at help for FileOpen

AddToLog("Log file created " & @MON ) ; etc etc

; Do installs.  Whenever you want to update the log file

AddToLog("Status update : Adobe Installed") ; will need to check status in case it errors.  

; End of file pass fileclose

FileClose($logfile)

Func AddToLog($logtext)
  FileWrite($logfile, $logtext & @CRLF)
EndFunc

I do tons of Logging / Terminal output with AutoIt apps I write. Above is the basics of how I do it. You need error control built in and conditionals as well. You can also set a variable and pass "If $logenabled = 1 Then AddToLog("Stuff")" etc... Also you can use AdLib to do funky stuff like add a continous stream of ............... while it's installing or to update the progress, etc.

Link to comment
Share on other sites

After it installs do an: If fileexists (some adobe file) Then iniwrite....

With the Send command you really can't confirm a key was actually pressed.

out of pure sport I made this

#Include <Date.au3>

$PID = run("notepad.exe")
sleep(2000)

opt ("WinTitleMatchMode" , 2)

WinActivate ("Notepad")
WinWaitActive ("Notepad")
$num = 1
$char = "T"
send($char)
HotKeySet("T", '_write' )
send($char)
HotKeySet("T")
sleep(500)

WinActivate ("Notepad")
WinWaitActive ("Notepad")
$num = 2
$char = "{SPACE}"
send("{SPACE}")
HotKeySet("{SPACE}", '_write')
send("{SPACE}")
HotKeySet("{SPACE}")
sleep(500)

WinActivate ("Notepad")
WinWaitActive ("Notepad")
$num = 3
$char = "E"
send($char)
HotKeySet("E", '_write' )
send($char)
HotKeySet("E")
sleep(500)

WinActivate ("Notepad")
WinWaitActive ("Notepad")
$num = 4
$char = "{SPACE}"
send("{SPACE}")
HotKeySet("{SPACE}", '_write')
send("{SPACE}")
HotKeySet("{SPACE}")
sleep(500)

WinActivate ("Notepad")
WinWaitActive ("Notepad")
$num = 5
$char = "S"
send($char)
HotKeySet("S", '_write' )
send($char)
HotKeySet("S")
sleep(500)

WinActivate ("Notepad")
WinWaitActive ("Notepad")
$num = 6
$char = "{SPACE}"
send("{SPACE}")
HotKeySet("{SPACE}", '_write')
send("{SPACE}")
HotKeySet("{SPACE}")
sleep(500)

WinActivate ("Notepad")
WinWaitActive ("Notepad")
$num = 7
$char = "T"
send($char)
HotKeySet("T", '_write' )
send($char)
HotKeySet("T")
sleep(500)


Func _Write()
iniwrite("c:\testKEYS.ini" , "Characters" , "Character_" & $num , "Sent the character::   " & $char & @TAB & @TAB & "::    at " & _now())
EndFunc
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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