Spiderman7 Posted October 31, 2008 Share Posted October 31, 2008 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 More sharing options...
TehWhale Posted October 31, 2008 Share Posted October 31, 2008 Of course it is! Look at the functions TimerInit() TimerDiff() and to get the time in seconds use: $Seconds = Round(TimerDiff($TimerInit)/100, 1) Link to comment Share on other sites More sharing options...
Spiderman7 Posted November 3, 2008 Author Share Posted November 3, 2008 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? Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 3, 2008 Share Posted November 3, 2008 HiThanks 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. 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 More sharing options...
TehWhale Posted November 3, 2008 Share Posted November 3, 2008 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. $Init = TimerInit() Sleep(2000);2 seconds $Seconds = Round(TimerDiff($Init)/1000, 2) MsgBox(0, "Time", $Seconds) Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 3, 2008 Share Posted November 3, 2008 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. 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 More sharing options...
Spiderman7 Posted November 3, 2008 Author Share Posted November 3, 2008 Wow!! You are the man!! Thanks for your help. I really appreciate it. Any idea how I can export this value to Excel? Everytime I run the script it should record the time in seconds in Excel in a new column (same row) Link to comment Share on other sites More sharing options...
Spiderman7 Posted November 4, 2008 Author Share Posted November 4, 2008 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 More sharing options...
Spiderman7 Posted November 4, 2008 Author Share Posted November 4, 2008 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 More sharing options...
dbzfanatic Posted November 4, 2008 Share Posted November 4, 2008 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). Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Nevin Posted November 4, 2008 Share Posted November 4, 2008 Running for forum mod in tomorrow's elections? Link to comment Share on other sites More sharing options...
dbzfanatic Posted November 4, 2008 Share Posted November 4, 2008 No, I just have mild OCD and it kind of bugs me >.> Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Spiderman7 Posted November 5, 2008 Author Share Posted November 5, 2008 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 More sharing options...
TehWhale Posted November 5, 2008 Share Posted November 5, 2008 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. Link to comment Share on other sites More sharing options...
Spiderman7 Posted November 5, 2008 Author Share Posted November 5, 2008 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. Will do. Thanks. Link to comment Share on other sites More sharing options...
spudw2k Posted November 5, 2008 Share Posted November 5, 2008 Will do. Thanks. 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. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now