Innovative Posted November 11, 2007 Share Posted November 11, 2007 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 .. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 11, 2007 Moderators Share Posted November 11, 2007 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 More sharing options...
Innovative Posted November 11, 2007 Author Share Posted November 11, 2007 Doesn't works.. im thinking that using regkey might works. Can someone please show me some examples of that ? Link to comment Share on other sites More sharing options...
searchresult Posted November 11, 2007 Share Posted November 11, 2007 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 More sharing options...
Moderators SmOke_N Posted November 11, 2007 Moderators Share Posted November 11, 2007 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 More sharing options...
Innovative Posted November 11, 2007 Author Share Posted November 11, 2007 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 More sharing options...
Moderators SmOke_N Posted November 11, 2007 Moderators Share Posted November 11, 2007 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 meWhat 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 More sharing options...
Innovative Posted November 11, 2007 Author Share Posted November 11, 2007 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 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 11, 2007 Moderators Share Posted November 11, 2007 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 =XThen 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. Loop2. ProcessList3. Store PID Values4. Compare Values5. If new add to Number Variable6. 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 More sharing options...
Innovative Posted November 11, 2007 Author Share Posted November 11, 2007 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 ? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 11, 2007 Moderators Share Posted November 11, 2007 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 =DCan 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 More sharing options...
Innovative Posted November 11, 2007 Author Share Posted November 11, 2007 I will only need to use the processList() function ? No other else, if not i will learn some from autoit helpfiles then. Link to comment Share on other sites More sharing options...
Innovative Posted November 11, 2007 Author Share Posted November 11, 2007 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. Loop2. ProcessList3. Store PID Values4. Compare Values5. If new add to Number Variable6. If Number Variable = 3 then do something.A lot of process polling.May i know how do i3. Store PID Values4. Compare Values5. If new add to Number Variable Link to comment Share on other sites More sharing options...
BrettF Posted November 11, 2007 Share Posted November 11, 2007 May i know how do i3. Store PID Values4. Compare Values5. If new add to Number VariableArrays, If $val <> $val2 Then it is false. else it is true. $total += 1 Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
therks Posted November 11, 2007 Share Posted November 11, 2007 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. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Innovative Posted November 11, 2007 Author Share Posted November 11, 2007 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 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