Jump to content

Please help a noob


Recommended Posts

Hi

I am very new to Auto IT and hoping you can help. I automated opening an application , doing certain functions in the app and closing the app - that works. But I want to capture the amount of time (in seconds) that the application was open and record this into a log file. This process should loop each time the program is opened + records the app uptime until closed by the user.

Is this possible in Autoit? I would appreciate any help you can provide.

Link to comment
Share on other sites

Hi

Thanks for the help. I cannot get it working. Do you perhaps have an example?

I would just like to record the amount of time in seconds that MS-Word was open export this value in seconds to Excel.

Is that possible?

Do TimerInit() when Word is opened, then TimerDiff() when Word is closed. If you can't make that work, post your code for more help.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hi

Thanks for the help. I cannot get it working. Do you perhaps have an example?

I would just like to record the amount of time in seconds that MS-Word was open export this value in seconds to Excel.

Is that possible?

You can write to excel, I have no experience in that, but I'll give you a working example. :mellow:

$Init = TimerInit()
Sleep(2000);2 seconds
$Seconds = Round(TimerDiff($Init)/1000, 2)
MsgBox(0, "Time", $Seconds)
Link to comment
Share on other sites

You can write to excel, I have no experience in that, ...

There are _Excel* functions included with the Beta version of AutoIt. See the Beta help file.

With the current production version these functions would be included in ExcelCOM_UDF.au3.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I am now able to export the value to Excel into cell A1. How can I loop the script below continuesly and record the value into a new cell each time? (In the same column)

I used a VERY SIMPLE notepad example:

CODE
$Init = TimerInit()

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

Run('notepad.exe')

WinWait("Untitled - Notepad","")

If Not WinActive("Untitled - Notepad","") Then WinActivate("Untitled - Notepad","")

WinWaitActive("Untitled - Notepad","")

Send("hello{ENTER}{ENTER}{ENTER}this{SPACE}{ENTER}{ENTER}is{ENTER}{ENTER}a{SPACE}{SPACE}test{ENTER}{E

NTER}{ALTDOWN}e{ALTUP}f")

WinWait("Find","")

If Not WinActive("Find","") Then WinActivate("Find","")

WinWaitActive("Find","")

Send("c")

MouseMove(339,80)

MouseDown("left")

MouseUp("left")

WinWait("Untitled - Notepad","")

If Not WinActive("Untitled - Notepad","") Then WinActivate("Untitled - Notepad","")

WinWaitActive("Untitled - Notepad","")

Send("{ALTDOWN}f{ALTUP}x")

WinWait("Notepad","")

If Not WinActive("Notepad","") Then WinActivate("Notepad","")

WinWaitActive("Notepad","")

Send("n")

Sleep(2000);2 seconds

$Seconds = Round(TimerDiff($Init)/1000, 2)

MsgBox(0, "Time", $Seconds)

#include <ExcelCOM_UDF.au3>

Local $oExcel = _ExcelBookNew() ;Create new book, make it visible

;Declare the Array

Local $aArray =

;_ExcelWriteArray($oExcel, 1, 1, $aArray) ; Write the Array Horizontally

_ExcelWriteArray($oExcel, 1, 1, $aArray, 1) ; Write the Array Vertically, starting on the 5th Row

MsgBox (0, "Exiting", "Press OK to Save File and Exit")

_ExcelBookSaveAs($oExcel, "c:\Temp.xls", "xls", 0, 1) ; Now we save it into the temp directory; overwrite existing file if necessary

_ExcelBookClose($oExcel) ; And finally we close out

Also tried doing it this way:

CODE
$Init = TimerInit()

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

Run('notepad.exe')

WinWait("Untitled - Notepad","")

If Not WinActive("Untitled - Notepad","") Then WinActivate("Untitled - Notepad","")

WinWaitActive("Untitled - Notepad","")

Send("hello{ENTER}{ENTER}{ENTER}this{SPACE}{ENTER}{ENTER}is{ENTER}{ENTER}a{SPACE}{SPACE}test{ENTER}{E

NTER}{ALTDOWN}e{ALTUP}f")

WinWait("Find","")

If Not WinActive("Find","") Then WinActivate("Find","")

WinWaitActive("Find","")

Send("c")

MouseMove(339,80)

MouseDown("left")

MouseUp("left")

WinWait("Untitled - Notepad","")

If Not WinActive("Untitled - Notepad","") Then WinActivate("Untitled - Notepad","")

WinWaitActive("Untitled - Notepad","")

Send("{ALTDOWN}f{ALTUP}x")

WinWait("Notepad","")

If Not WinActive("Notepad","") Then WinActivate("Notepad","")

WinWaitActive("Notepad","")

Send("n")

Sleep(2000);2 seconds

$Seconds = Round(TimerDiff($Init)/1000, 2)

MsgBox(0, "Time", $Seconds)

#include <ExcelCOM_UDF.au3> ; Include the collection

; Open new book, make it visible

Local $oExcel = _ExcelBookNew(1)

; Write a message to the first cell of the first sheet

_ExcelWriteCell($oExcel, $Seconds, "A1")

; Now we save it into the temp directory; overwrite existing file if necessary

_ExcelBookSaveAs($oExcel, "c:\temp.xls", "xls", 0, 1)

; And finally we close out

_ExcelBookClose($oExcel)

Link to comment
Share on other sites

I got it working!!

Auto IT is very cool!!

CODE
#include <ExcelCOM_UDF.au3>

Local $oExcel = _ExcelBookNew() ;Create new book, make it visible

For $i = 1 To 10 ;Loop

$Init = TimerInit()

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

Run('notepad.exe')

WinWait("Untitled - Notepad","")

If Not WinActive("Untitled - Notepad","") Then WinActivate("Untitled - Notepad","")

WinWaitActive("Untitled - Notepad","")

Send("hello{ENTER}{ENTER}{ENTER}this{SPACE}{ENTER}{ENTER}is{ENTER}{ENTER}a{SPACE}{SPACE}test{ENTER}{E

NTER}{ALTDOWN}e{ALTUP}f")

WinWait("Find","")

If Not WinActive("Find","") Then WinActivate("Find","")

WinWaitActive("Find","")

Send("c")

MouseMove(339,80)

MouseDown("left")

MouseUp("left")

WinWait("Untitled - Notepad","")

If Not WinActive("Untitled - Notepad","") Then WinActivate("Untitled - Notepad","")

WinWaitActive("Untitled - Notepad","")

Send("{ALTDOWN}f{ALTUP}x")

WinWait("Notepad","")

If Not WinActive("Notepad","") Then WinActivate("Notepad","")

WinWaitActive("Notepad","")

Send("n")

Sleep(2000);2 seconds

$Seconds = Round(TimerDiff($Init)/1000, 2)

;MsgBox(0, "Time", $Seconds)

_ExcelWriteCell($oExcel, $Seconds, $i, 1) ;Write to the Cell

Next

MsgBox (0, "Exiting", "Press OK to Save File and Exit")

_ExcelBookSaveAs($oExcel, "C:\Temp.xls", "xls", 0, 1) ; Now we save it into the temp directory; overwrite existing file if necessary

_ExcelBookClose($oExcel) ; And finally we close out

Link to comment
Share on other sites

It's rude to double post, and you have triple posted. There is an edit button,please use it. Also if you have found the solution to your problem(s) please add "[RESOLVED]" or "[sOLVED]" to your title (without the quotation marks).

Link to comment
Share on other sites

It's rude to double post, and you have triple posted. There is an edit button,please use it. Also if you have found the solution to your problem(s) please add "[RESOLVED]" or "[sOLVED]" to your title (without the quotation marks).

Wow - relax!! I am new to this forum. What does double post mean??

I will try to read the forum rules...

Link to comment
Share on other sites

Wow - relax!! I am new to this forum. What does double post mean??

I will try to read the forum rules...

Double posting is when you make a post, and then you make another post, making two in a row. To Edit your post just click EDIT under your post and choose Quick Edit, change your post and hit submit. :mellow:
Link to comment
Share on other sites

Will do. Thanks. :mellow:

Yeah, just for fair warning, most members and mods alike on this forum have no patience for newbs. I'm not by any means making any judgments towards you; but wanted to share a few tips. Always search the forum and the ever so wonderful Helpfile before asking a question on the forums if possible and do not, I repeat, do not bring up topics related to malicious material (ie, keyloggers, password cracking, etc...). Welcome aboard.

:(

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