Jump to content

For...next Loop Problem


Recommended Posts

Lines 903-920 in the script read:

Func _LaunchWin()
    AdlibDisable()
    Sleep(2000)
    For $i = 1 To $HotKey_Value[0][0]
        If $HotKey_Value[$i][4] <> "" Then HotKeySet($HotKey_Value[$i][4],"_HotKey_Exec")
        Sleep(200)
    Next
    For $i = 1 To $Addon_Value[0][0]
        If GUICtrlRead($Addon_Value[$i][8]) = $GUI_CHECKED And $Addon_Value[$i][4] = "Windower" Then
            $Addon_Value[$i][7] = Run($Addon_Value[$i][2]&" "&$Addon_Value[$i][3],$Addon_Value[$i][6])
        EndIf
        MsgBox(48,"addons",$Addon_Value[0][0])
    Next
    MsgBox(48,"after","")
    Sleep(500)
    MsgBox(48,$Rerun,"")
    If $Rerun = "Yes" Then Call("_NoPOL")
EndFunc

What it does is...

This function is called once a certain window appears (defined or undefined (based on process), optionally). It is supposed to look through an array of $HotKey_Value[0][0] values (from an ini, mine has 10). It checks if they have the "Windower" attribute and then runs them if they do.

The msgbox (3) I added for bug fixing purposes.

The problem is, it goes through the "For $i = 1 To $Addon_Value[0][0]" loop 3 times (pops up 3 msgboxes), then it just quits. I need it to finish running (thereby loading the rest of the addons), and then to be able to call the "_NoPOL" function, but it doesn't.

Any ideas?

Edited by FinalDoom
Link to comment
Share on other sites

Lines 903-920 in the script read:

Func _LaunchWin()
    AdlibDisable()
    Sleep(2000)
    For $i = 1 To $HotKey_Value[0][0]
        If $HotKey_Value[$i][4] <> "" Then HotKeySet($HotKey_Value[$i][4],"_HotKey_Exec")
        Sleep(200)
    Next
    For $i = 1 To $Addon_Value[0][0]
        If GUICtrlRead($Addon_Value[$i][8]) = $GUI_CHECKED And $Addon_Value[$i][4] = "Windower" Then
            $Addon_Value[$i][7] = Run($Addon_Value[$i][2]&" "&$Addon_Value[$i][3],$Addon_Value[$i][6])
        EndIf
        MsgBox(48,"addons",$Addon_Value[0][0])
    Next
    MsgBox(48,"after","")
    Sleep(500)
    MsgBox(48,$Rerun,"")
    If $Rerun = "Yes" Then Call("_NoPOL")
EndFunc

What it does is...

This function is called once a certain window appears (defined or undefined (based on process), optionally). It is supposed to look through an array of $HotKey_Value[0][0] values (from an ini, mine is 10). It checks if they have the "Windower" attribute and then runs them if they do.

The msgbox (3) I added for bug fixing purposes.

The problem is, it goes through the "For $i = 1 To $Addon_Value[0][0]" loop 3 times (pops up 3 msgboxes), then it just quits. I need it to finish running (thereby loading the rest of the addons), and then to be able to call the "_NoPOL" function, but it doesn't.

Any ideas?

You mentioned $HotKey_Value[0][0] = 10, how about $Addon_Value[0][0]? Is it greater than 3?

When you say "it just quits", does that mean the script exits, or it exits the For loop and show the "after" message box?

:think:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Err.. sorry, I was referring to the addon variables all the way through. The hotkey variables are 0, so it just skips that part.

It completely exits, as if the fourth msgbox were an Exit command, or if there were an Exit command directly after the third msgbox. That is, the fourth or third MsgBox(48,"addons",$Addon_Value[0][0]) not the following 2.

Scite gets no errors and reads something like (different time):

+>AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 160.0
Edited by FinalDoom
Link to comment
Share on other sites

Ad trace code in function in and out. If you have to compile the code you can take a look at my Trace udf and use debugview from sysinternals.

Link to comment
Share on other sites

Func _LaunchWin()
    AdlibDisable()
    Sleep(2000)
    For $i = 1 To $HotKey_Value[0][0]
        If $HotKey_Value[$i][4] <> "" Then HotKeySet($HotKey_Value[$i][4],"_HotKey_Exec")
        Sleep(200)
    Next
    For $i = 1 To $Addon_Value[0][0]
        If GUICtrlRead($Addon_Value[$i][8]) = $GUI_CHECKED And $Addon_Value[$i][4] = "Windower" Then
            $Addon_Value[$i][7] = Run($Addon_Value[$i][2]&" "&$Addon_Value[$i][3],$Addon_Value[$i][6])
        EndIf
        _Trace("Message ending at the first available sinc. If there is no debugger that would bee ConsoleWrite", 0)
        _Trace("Specific to debugger",1)
        _Trace("Passed to ConsoleWrite",2)
        _Trace("Passed to TrayTip",3)
        _Trace("Passed to TrayTip2 to see if first message is canseled before the timeout.",3)
        _Trace("Passed to MsgBox",4)
        _Trace("Should set the Error flag as there is no option for $i_OutputSInc=5",5)
    Next
    Sleep(500)
    If $Rerun = "Yes" Then Call("_NoPOL")
EndFunc
(sorry if that's not how I'm supposed to run it)

I don't see how this is much help, but it popped 3 "Message ending at the first available sinc. If there is no debugger that would bee ConsoleWrite" and 3 debugger [5332] Specific to debugger

and 3 [5332] Message ending at the first available sinc. If there is no debugger that would bee ConsoleWrite

as well as one (That I could see, maybe the others were behind the fullscreen (forced) ... FF.. don't ask lol) _Trace("Passed to TrayTip2 to see if first message is canseled before the timeout.",3) message.

Scite output was

Passed to ConsoleWrite
Passed to ConsoleWrite
Passed to ConsoleWrite
Passed to ConsoleWrite
+>AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 65.893
Edited by FinalDoom
Link to comment
Share on other sites

Err.. sorry, I was referring to the addon variables all the way through. The hotkey variables are 0, so it just skips that part.

It completely exits, as if the fourth msgbox were an Exit command, or if there were an Exit command directly after the third msgbox. That is, the fourth or third MsgBox(48,"addons",$Addon_Value[0][0]) not the following 2.

Scite gets no errors and reads something like (different time):

+>AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 160.0
Is there something special about that command at $Addon_Value[2][2] and [2][3]? Might tweak the debug display like this:

Func _LaunchWin()
    AdlibDisable()
    Sleep(2000)
    For $i = 1 To $HotKey_Value[0][0]
        If $HotKey_Value[$i][4] <> "" Then HotKeySet($HotKey_Value[$i][4],"_HotKey_Exec")
        Sleep(200)
    Next

    MsgBox(48, "Debug", "$Addon_Value[0][0] = " & $Addon_Value[0][0]
    For $i = 1 To $Addon_Value[0][0]
        If GUICtrlRead($Addon_Value[$i][8]) = $GUI_CHECKED And $Addon_Value[$i][4] = "Windower" Then
            MsgBox(48, "Debug", "Running: " & $Addon_Value[$i][2] & " " & $Addon_Value[$i][3] & @CRLF & _
                      "Working Dir: " & $Addon_Value[$i][6])
            $Addon_Value[$i][7] = Run($Addon_Value[$i][2] & " " & $Addon_Value[$i][3], $Addon_Value[$i][6])
        EndIf
    Next

    MsgBox(48,"after","")
    Sleep(500)
    MsgBox(48,$Rerun,"")
    If $Rerun = "Yes" Then Call("_NoPOL")
EndFunc

Did you mean to use Run() instead of RunWait()? If you have 10 things in your array that pass the If condition, it will rapidly kick all ten off as seperate parallel processes running all at the same time.

:think:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

RunWait is a good point... except "pause execution of the script until the spawned program has finished" meaing.. until it exits? or until it is done doing the launch sequence? This is designed to run full programs, not dos commands.

2 is the path for the program, 3 is any special switches. As for the 2 set...

the [2][2] = C:\Program Files\FFXI Assist\FFAssist.exe and the [2][3] = nothing

Edit: changed it to RunWait and added a Sleep(200) after (for each launch) and nothing. Still does the same thing.

Edit2: strange, but there's something in the way it processes the ini.. I reordered it (fairly randomly) and it popped 6 messages.. hmm.

Edit3: These are more of notes to self now than anything. Found that the chatmon.exe line causes it to exit, and cannot use RunWait - has to run regardless of whether the prior process is closed.

Edit4: the chatmon call is the "exit" point - regardless of settings, if it is run.

And I've given up. I'm leaving it up to the users to see if it performs this glitch for them.

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