Sign in to follow this  
Followers 0
pingpong24

FileWrite problem

9 posts in this topic

#1 ·  Posted (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 by pingpong24

Share this post


Link to post
Share on other sites



#2 ·  Posted (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)

EndIf

Now 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 by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by pingpong24

Share this post


Link to post
Share on other sites

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

why filewrite to an ini, and not use iniwrite?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 :P

Share this post


Link to post
Share on other sites

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 :P

so is it just a plain keylogger?

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

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  
Followers 0