Jump to content

Opened times


Recommended Posts

  • Moderators

is there any way to detect how many times the program is opened ? means if it is opened 3 times i will perform an action ..

if ubound(processlist("my.exe")) - 1 = 3 then

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Doesn't works.. im thinking that using regkey might works. Can someone please show me some examples of that ?

the easy way would be to write data in a file then open it read it write it here is the code:

FileOpen("num.txt",1)
$rNumber = FileRead("num.txt")
FileClose("num.txt")

If $rNumber = 3 Then
    
    MsgBox(0,"","You ran it 3 thimes") 
    
Else
    
    $rNumber = $rNumber + 1
    FileOpen("num.txt",2)
    FileWrite("num.txt",$rNumber)
    
EndIf

FileClose("num.txt")
Link to comment
Share on other sites

  • Moderators

Doesn't works.. im thinking that using regkey might works. Can someone please show me some examples of that ?

It does work for what you asked specifically.

Now, if you can't get it to do what you are actually wanting... then you need to be a heck of a lot clearer on what it is you are actually wanting.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Heres part of my script where i wanted to put the script into

$checkRKfile = FileExists($file)
   If $checkRKfile = 1 Then
      $checkifexpired = FileReadLine($file, 10)
     If $checkifexpired = "text" Then
           _FileWriteToLine ( $File, 10, "regkey#expired", 1)

I only want to _FileWriteToLine if the program is opened for X times..

Please help me

Link to comment
Share on other sites

  • Moderators

Heres part of my script where i wanted to put the script into

$checkRKfile = FileExists($file)
   If $checkRKfile = 1 Then
      $checkifexpired = FileReadLine($file, 10)
     If $checkifexpired = "text" Then
           _FileWriteToLine ( $File, 10, "regkey#expired", 1)

I only want to _FileWriteToLine if the program is opened for X times..

Please help me

What do you mean "opened", you say "program", I assume "executable" when you say that.

Do you mean that there are "3" current copies of the "program/executable" running at that time?

Or you want to track how many times someone opened it?

Is it your program?

I mean come on... You ask for help, but make no sense, how can anyone help you if you don't help yourself to ask a properly formatted question first?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

But i want to track how many times a computer opened it..

If the computer RUN it X times, it will perform an action..

Sorry for the trouble because im quite new to autoit too =X

Then you'll have to poll the process list, and keep track of the Process ID's and compare if it's been opened.

What you are asking is not a ready made function... I thought Valuater and I did something like this a couple of years ago, but no telling where that function might be.

So maybe something like this.

1. Loop

2. ProcessList

3. Store PID Values

4. Compare Values

5. If new add to Number Variable

6. If Number Variable = 3 then do something.

A lot of process polling.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

How do i check a program's process id ?

and i dont understand what you're talking about in that post.. maybe im still a newbie =D

Can you help me about that please ?

I told you what to do... I'm definately not going to write it for you.

The function you will look at is ProcessList()... and if you don't understand how to use it, you might want to try some simpler things until you get the hang of it, because you're about to jump off into the world of arrays.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Then you'll have to poll the process list, and keep track of the Process ID's and compare if it's been opened.

What you are asking is not a ready made function... I thought Valuater and I did something like this a couple of years ago, but no telling where that function might be.

So maybe something like this.

1. Loop

2. ProcessList

3. Store PID Values

4. Compare Values

5. If new add to Number Variable

6. If Number Variable = 3 then do something.

A lot of process polling.

May i know how do i

3. Store PID Values

4. Compare Values

5. If new add to Number Variable

Link to comment
Share on other sites

May i know how do i

3. Store PID Values

4. Compare Values

5. If new add to Number Variable

Arrays, If $val <> $val2 Then it is false. else it is true. $total += 1
Link to comment
Share on other sites

Hmm, are you sure he wants to track how many instances are open?

Looking at his piece of code I assumed he only wanted a user to be able to open his program 3 times (not necessarily check if 3 are open at the same time), then it would "expire."

Which of course, would be relatively easy using registry, or INI file, or whatever.

For example:

$RunCount = Int(IniRead('C:\track.txt', 'Run', 'Count', 0))
$RunCount += 1
IniWrite('C:\track.txt', 'Run', 'Count', $RunCount)
If $RunCount > 3 Then
   MsgBox(0, '', 'You have run this program 3 times already. No more!')
   Exit
EndIf
; Other stuff...

Maybe I'm wrong, but like Smoke said, the question was kind of hard to follow.

Link to comment
Share on other sites

Hmm, are you sure he wants to track how many instances are open?

Looking at his piece of code I assumed he only wanted a user to be able to open his program 3 times (not necessarily check if 3 are open at the same time), then it would "expire."

Which of course, would be relatively easy using registry, or INI file, or whatever.

For example:

$RunCount = Int(IniRead('C:\track.txt', 'Run', 'Count', 0))
$RunCount += 1
IniWrite('C:\track.txt', 'Run', 'Count', $RunCount)
If $RunCount > 3 Then
   MsgBox(0, '', 'You have run this program 3 times already. No more!')
   Exit
EndIf
; Other stuff...

Maybe I'm wrong, but like Smoke said, the question was kind of hard to follow.

That was exactly what i wanted .. THANK YOU VERY MUCH !

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