pingpong24 Posted December 10, 2005 Share Posted December 10, 2005 (edited) #include <File.au3> WinWaitActive ( "Untitled" ) While WinExists ("Untitled") = 1 If Random() < 0.5 Then If FileExists("timer.ini") Then $file = FileOpen("timer.ini", 1) FileWrite($file, "0") FileClose($file) Else _FileCreate("timer.ini") $file = FileOpen("timer.ini", 1) FileWrite($file, "0") FileClose($file) EndIf EndIf WEnd Now it should just put 1 zero into the file timer.ini instead it puts endless amounts.. Edited December 10, 2005 by pingpong24 NumCR Super Fast EASY NUMBER OCR, easiest and the fastest AUTOIT OCR released on this forum Link to comment Share on other sites More sharing options...
Developers Jos Posted December 10, 2005 Developers Share Posted December 10, 2005 (edited) If FileExists("timer.ini") Then$file = FileOpen("timer.ini", 1)FileWrite($file, "0")FileClose($file)Else_FileCreate("timer.ini")$file = FileOpen("timer.ini", 1)FileWrite($file, "0")FileClose($file)EndIfNow it should just put 1 zero into the file timer.ini instead it puts endless amounts..If it writes multiple zeros to the file then I am sure theres more code then what you have shown..OR if you want to replace the current content of the file with a Zero you should open the file with 2.(1 means append)I also don't understand why you just use a single line like:FileWite("timer.ini",0)The result is the same as the code you show. Edited December 10, 2005 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
pingpong24 Posted December 10, 2005 Author Share Posted December 10, 2005 (edited) #include <Misc.au3> #include <File.au3> WinWaitActive ( "Untitled" ) While WinExists ("Untitled") = 1 If _IsPressed('30') = 1 Then ;Sleep(700) If FileExists("timer.ini") Then FileWrite("timer.ini", "0") FileClose("timer.ini") Else _FileCreate("timer.ini") ;Sleep(700) FileWrite("timer.ini", "0") FileClose("timer.ini") EndIf EndIf WEnd without sleep it gives too many zeros.. for some unknown reason.. can someone explain.. also if the sleep isnt more then 700.. it does the same. Edited December 10, 2005 by pingpong24 NumCR Super Fast EASY NUMBER OCR, easiest and the fastest AUTOIT OCR released on this forum Link to comment Share on other sites More sharing options...
GaryFrost Posted December 10, 2005 Share Posted December 10, 2005 sleep allows the buffer to be cleared from a keypress SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 10, 2005 Developers Share Posted December 10, 2005 The reason for your problem is that the If is true for the time you press the 0 key. This logic will only execute the 0 logic one time when you press the 0 key. #include <Misc.au3> #include <File.au3> Global $LastKey = 0 WinWaitActive("Untitled") While WinExists("Untitled") = 1 If _IsPressed ('30') Then ;Sleep(700) If $LastKey = 0 Then FileWrite("timer.ini", "0") EndIf $LastKey = 30 Else $LastKey = 0 EndIf WEnd SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Knight Posted December 10, 2005 Share Posted December 10, 2005 why filewrite to an ini, and not use iniwrite? Link to comment Share on other sites More sharing options...
Gene Posted December 11, 2005 Share Posted December 11, 2005 why filewrite to an ini, and not use iniwrite?IniWrite applies a specific format to the data written to the INI file, IniRead expects the same specific format in an INI file. He apparently wants the 'timer.ini' file with no internal format and a '0' on the first line. Of course he may or may not use the standard format in later operations. [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right... Link to comment Share on other sites More sharing options...
pingpong24 Posted December 11, 2005 Author Share Posted December 11, 2005 The reason for your problem is that the If is true for the time you press the 0 key. This logic will only execute the 0 logic one time when you press the 0 key. #include <Misc.au3> #include <File.au3> Global $LastKey = 0 WinWaitActive("Untitled") While WinExists("Untitled") = 1 If _IsPressed ('30') Then ;Sleep(700) If $LastKey = 0 Then FileWrite("timer.ini", "0") EndIf $LastKey = 30 Else $LastKey = 0 EndIf WEnd THANKS!! you helped me alot, the program is working fine now!! really appreate it.. though i wanted to make it all by my self without anyones help NumCR Super Fast EASY NUMBER OCR, easiest and the fastest AUTOIT OCR released on this forum Link to comment Share on other sites More sharing options...
seandisanti Posted December 12, 2005 Share Posted December 12, 2005 THANKS!! you helped me alot, the program is working fine now!! really appreate it.. though i wanted to make it all by my self without anyones help so is it just a plain keylogger? 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