Jump to content

IniRead problem.


Recommended Posts

I'm almost finished with making my MouseClick recorder bot... Though I want it so the user can record multiple recordings and open them up at a later date.

What I got so far WORKS, but I need a small help question.

Func StartStop()

    $read=1
    If $hi= True Then
        $hi=False
    ElseIf $hi= False Then
        $hi=True
    EndIf
    $inir=FileOpenDialog("Pick a file to replay", @scriptDir, "Ini (*.ini*)")
    If @error Then
        MsgBox(0,"", "No file selected")
    Else
        MsgBox(0,"", "It will now replay")
    EndIf
        
    While $hi = True    
        $replayx=IniRead($inir, "Coords", "x"&$read, "Error" )
        if $replayx="Error" Then
            $read=1
        else
        $replayy=IniRead($inir, "Coords", "y"&$read, "Error" )
        MouseClick("left",$replayx,$replayy,1,0)
        $read=$read+1
        Sleep(800)
        endif
    WEnd    
EndFunc

Thats not the entire code, but the rest of it isn't of any use in my question...

How can I make...........:

If @error Then
        MsgBox(0,"", "No file selected")
    Else

.... change the value of $inir to the default file (@ScriptDir&"\Coords.ini")

So if a file is not selected $replayx would play '@ScriptDir&"\Coords.ini"' instead of ($inir)

I did attempt at this but I'm getting stuck every which way I try:

Func StartStop()

    $read=1
    If $hi= True Then
        $hi=False
    ElseIf $hi= False Then
        $hi=True
    EndIf
    $inir=FileOpenDialog("Pick a file to replay", @scriptDir, "Ini (*.ini*)")
    If @error Then
        $go=false
        MsgBox(0,"", "No file selected, it will replay the Default file")
    Else
        $go=true
        MsgBox(0,"", "It will now replay")
    EndIf
        
    While $hi = True    
        If $go= True Then
            $replayx=IniRead($inir, "Coords", "x"&$read, "Error" )
            if $replayx="Error" Then
                $read=1
            else
            $replayy=IniRead($inir, "Coords", "y"&$read, "Error" )
        Else
        
            $replayx=IniRead(@ScriptDir&"\Coords.ini", "Coords", "x"&$read, "Error" )
            If $replayx="Error" Then
                $read=1
            Else
            $replayy=IniRead(@ScriptDir&"\Coords.ini", "Coords", "y"&$read, "Error" )
        EndIf
            MouseClick("left",$replayx,$replayy,1,0)
            $read=$read+1
            Sleep(800)
            endif
    WEnd    
EndFunc
Link to comment
Share on other sites

Nevermind, I figured it out:

If @error Then
        MsgBox(0,"", "You MUST select a file!")
        $hi=false
        StartStop()
    Else
        MsgBox(0,"", "It will now replay")
    EndIf

Sorry for the post...

Maybe I could get my 'moneys worth' on this post if anyone wants to tackle a hard challenge :S:

I want to try and record the time in between clicks and write that down in the ini file... When the specific x, y, and time is played from the ini, I want it to Sleep($time) before clicking the next spot...

Heres my entire code... First off will have to be in the record Func... After that I'm not sure what to do :S

#include <misc.au3>
Opt("MouseCoordMode",2)
Global $x=false, $tick=1, $hi=false, $read=1
If FileExists(@scriptdir&"\Coords.ini") Then
    FileDelete(@scriptdir&"\Coords.ini")
EndIf 



While 1
HotKeySet("{F5}","Record")
HotKeySet("{F6}","StartStop")
HotKeySet("{ESC}","ExitNow")
Wend

Func ExitNow()
    $exitm=MsgBox(4, "Exit", "Would You like to save?")
    If $exitm=6 Then
        $stream=InputBox("Save As","What name would you like to save it as?","")
        If @error=1 Then
            Exit
        Else
    FileMove(@ScriptDir&"\Coords.ini",@ScriptDir&"\"&$stream&".ini",9) 
endif
endif
Exit;--
EndFunc


Func Record()
    
    If $x=true Then
        DllClose($dll)
        $x=False;--- 
    elseif $x=false Then
        Global $dll=DllOpen("user32.dll")
        $x=true
    endif
    While $x=true
        If _IsPressed("01") Then
            Sleep(300)
            $pos=MouseGetPos()
            IniWrite("Coords.ini","Coords","x"&$tick,$pos[0]) 
            IniWrite("Coords.ini","Coords","y"&$tick,$pos[1]) 
            $tick=$tick+1
            
            
        EndIf
        sleep(5)
    Wend
EndFunc

Func StartStop()

    $read=1
    If $hi= True Then
        $hi=False
    ElseIf $hi= False Then
        $hi=True
    EndIf
    $inir=FileOpenDialog("Pick a file to replay", @scriptDir, "Ini (*.ini*)")
    If @error Then
        MsgBox(0,"", "You MUST select a file!")
        $hi=false
        StartStop()
    Else
        MsgBox(0,"", "It will now replay")
    EndIf
        
    While $hi = True    
        $replayx=IniRead($inir, "Coords", "x"&$read, "Error" )
        if $replayx="Error" Then
            $read=1
        else
        $replayy=IniRead($inir, "Coords", "y"&$read, "Error" )
        MouseClick("left",$replayx,$replayy,1,0)
        $read=$read+1
        Sleep(800)
        endif
    WEnd    
EndFunc

I also looked up in the helpfile... I assume we will be dealing with SetTimer and KillTimer... I'm just not sure where to plug in KillTimer... Of course SetTimer will go below the: _IsPressed("01",$dll) part, but I'm not sure where the Kill timer could go so it gets the time BETWEEN each mouseclick.... :S

Edited by UnknownWarrior
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...