Jump to content
Sign in to follow this  
Kaitsu

Counting a repetitive process to a file, problem

Recommended Posts

Kaitsu
Hi, I am fairly new to AutoIt scripting. I would like to make a simple counter that writes a line (date + timestamp) to a text file everytime a window appears. My code works on some level. I use windows calculator in this example.
 
It waits for the window to appear and then writes on the text file ok. But there are 2 questions. The first one is that it floods the txt file with lines as long as the calculator-window is open. I would want only one line for every instance the calculator-window opens. And the second question is how can I loop it so that when calculator opens it writes the line to the txt-file and then waits again for calculator to open and writes again. So a simple log-file is what I am trying to do. Thanks in advance for your help!
 
WinWait("Calculator")
If WinActive("Calculator") Then
 
$file = FileOpen("d:tempcounter.txt", 1)
If $file = -1 Then
    Exit
EndIf
FileWriteLine($file, "Opened, " & @MDAY & "." & @MON & "." & @YEAR & " " & @HOUR & ":" & @MIN & @CRLF)
FileClose($file)
 
ElseIf
WinWait("Calculator")
EndIf
Edited by Kaitsu

Share this post


Link to post
Share on other sites
water

Welcome to AutoIt and the forum!

Can you please describe why you want to monitor the number of times a window is opened? What do you try to achieve?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Kaitsu

Welcome to AutoIt and the forum!

Can you please describe why you want to monitor the number of times a window is opened? What do you try to achieve?

Hi,

Actually I am trying to make a simple report from the data that this little counter should give me. It would then tell me how many times a day the process/window appears and the exact time of day that this occurs. So it would give me a nice simple report. The actual window in my final version that appears is more like "operation successful". And I am trying to count/monitor these processes.

I am a part of a small business. And we have 8 computers on which this little counter should be used to write on a single file which is on a shared network drive. The window I am trying to count is a "ok/done -confirmation window" that is the repetitive process, that a user must click. It would then give us a report how many times the process has been done. Hope this clears:)

Edited by Kaitsu

Share this post


Link to post
Share on other sites
water

Depending where on the world you are located it might be needed to check this with the works council.

I would use function WinList. Each window is returned with a handle. By comparing the handle you can make sure to only count unique windows.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Kaitsu

Depending where on the world you are located it might be needed to check this with the works council.

I would use function WinList. Each window is returned with a handle. By comparing the handle you can make sure to only count unique windows.

 

I am from Finland. And it should be completely legal and almost everything else is monitored for reports. This was just my idea that we could monitor it using AutoIt. I will try to look on the WinList function. Seems a bit confusing, but might take a while to figure it out.

In my case the window is always closed after it appears, so there is just one window open at a time.

Edited by Kaitsu

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  

×