Jump to content

filewriteline


Recommended Posts

hi to all,

i have problem wit filewriteline

it can correctly read file line but at write pupose i want it will add 1 in file i tried but i failed try this code to know. :)

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=C:\Documents and Settings\saeed\My Documents\pak.ico
#AutoIt3Wrapper_outfile=coin.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GuiConstants.au3>
#include <misc.au3>

Global Const $WM_ENTERSIZEMOVE = 0x231
Global Const $WM_EXITSIZEMOVE = 0x232

HotKeySet("5", "SevenUp")
HotKeySet("1", "SevenDown")

Opt("GUIOnEventMode", 1)

Global $i = 0
Global $j = 0

    $file = FileOpen('c:\coins.txt', 1)
    $line = FileReadLine($file)
    $filewrite = FileWrite($file, 1)
    $write = FileWriteLine($filewrite, $i)

$testGUI2 = GUICreate("", 641, 450, 0, 0, BitOR($WS_MINIMIZEBOX,$WS_GROUP,$WS_CLIPSIBLINGS, $WS_POPUP))
$Label1 = GUICtrlCreateLabel("Coins: ", 40, 16, 395, 273)
GUICtrlSetOnEvent($Label1, "ALabel1Click")
$label2 = GUICtrlCreateLabel("Total: ", 80, 18, 400, 300)
GUICtrlSetOnEvent($label2, "alabelclick2")
GUISetState(@SW_SHOW)
WinSetOnTop($TESTGUI2, "", 1)

Global $pos = WinGetPos($testGUI2)
Global Const $WM_NCHITTEST = 0x0084
GUIRegisterMsg($WM_NCHITTEST,"WM_NCHITTEST")

While 1
    lod3Sleep(10)
    
WEnd


Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If $hWnd = $testGUI2 And $iMsg = $WM_NCHITTEST Then
        $id = _API_DefWindowProc($hWnd, $iMsg, $iwParam, $ilParam)
        If $id = 2 Then;if it is the title handle
            Return 1;return the client handle
        Else
            Return $id;return the real handle
        EndIf
    EndIf

EndFunc


Func _API_DefWindowProc($hWnd, $iMsg, $iwParam, $ilParam)
    Local $aResult

    $aResult = DllCall("User32.dll", "int", "DefWindowProc", "hwnd", $hWnd, "int", $iMsg, "int", $iwParam, "int", $ilParam)
    Return $aResult[0]
EndFunc

Func SevenDown()
    HotKeySet("1")
    if $i = 0 Then
        send("m")
        EndIf
    ConsoleWrite("sdn" & @CRLF)
    if $i >= 1 Then;<----changed this so I could test it.
        send ("3")
        lod3Sleep(100)
        controlsend("Insert coin", "", "", "3")
        lod3Sleep(20)
        Send("{enter}")
        
    EndIf
    If $i > 0 Then
        $i -= 1
    soundplay(@WindowsDir &"\media\ir_end.wav")
    WinSetTitle("Coins: ", "", "Coins: " & $i & "Total:" & $file)
        $s = lod3Sleep(60000*5)
    Else
        $i = 0
    EndIf

;HotKeySet("1")
    
    HotKeySet("1", "SevenDown")
    ConsoleWrite("Endsdn" & @CRLF)
EndFunc

Func lod3Sleep($lt)
    $tin = timerinit()

    while Timerdiff($tin) < $lt
               ;if NUm5 or 5 pressed
       HotKeySet("5", "sevenup")
                    
    WEnd

EndFunc

Func alabelclick2()
    
EndFunc

Func ALabel1Click()
    
    EndFunc

Func SevenUp()
        ConsoleWrite("start sup" & @CRLF)
;HotKeySet("1", "SevenDown")
    $i +=1
    GUICtrlSetFont($Label1, 28, "", "","Comic Sans MS")
    GUICtrlSetColor($Label1, 0x00AA00)
   GUICtrlSetData($Label1, $i)
    GUICtrlSetFont($Label2, 28, "", "","Comic Sans MS")
    GUICtrlSetColor($Label2, 0x00AA00)
    GUICtrlSetData($label2, "  Total: " & $line & $write)
    ConsoleWrite("Enssup" & @CRLF)
    FileClose($file)
    EndFunc

i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Link to comment
Share on other sites

  • Moderators

$file = FileOpen('c:\coins.txt', 1)
    $line = FileReadLine($file);Missing a line to read here
    $filewrite = FileWrite($file, 1);You're writing the number 1 to the file, then below you're trying to write again?
    $write = FileWriteLine($filewrite, $i);The $filewrite is not a file name it's the number 1
    ;You never closed the fileopenoÝ÷ Ø·­ßÛ,yæ(»
âµê®¢Ýjºm¢Ø^~)^~*ì¶Ø^*.ºÇ­æè¢W·­º¹íÊ­«b¶·­º¹ìjËayø¥zv¦y«Zvß#]²ë)]¢'²×vÚ[ay¦è½å¡Êz-ë-v®¶­sdfÆUw&FTÆæRgV÷CµWBâ7GVÂfÆRæÖRW&RgV÷C²ÂfÆU&VDÆæRgV÷CµWBâ7GVÂfÆRæÖRW&RgV÷C²ÂgV÷CµWBÆæRFò&VBW&RgV÷C²Âb33c¶
You don't need a variable for FileWrite unless you are checking it's return (whether it was successful or not).

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

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