Error: ELSE with no matching IF

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Activity
Posts: 4
Joined: 13 Aug 2018, 00:16

Error: ELSE with no matching IF

15 Aug 2018, 02:57

The error appeared on line 81 and it read 'else if Other' as two lines when it's one line.
So... I don't know what's wrong with it.
I re-read the code and personally saw nothing wrong...
Any ideas and help would be appreciated.

Code: Select all

;Key binds
key_select:="F1"
key_Other:="F2"
key_Other2:="F3"
key_Other3:="F4"
key_ScriptPause:="F5"
key_ScriptTerminate:="F6"

Loop {
Sleep 1

if GetKeyState(key_select)
{
PFeedLoop:=true
Other:=false
Other2:=false
Other3:=false
}

if GetKeyState(key_Other)
{
PFeedLoop:=false
Other:=true
Other2:=false
Other3:=false
}

if GetKeyState(key_Other2)
{
PFeedLoop:=false
Other:=false
Other2:=true
Other3:=false
}

if GetKeyState(key_Other3)
{
PFeedLoop:=false
Other:=false
Other2:=false
Other3:=true
}

if GetKeyState(key_ScriptPause)
{
PFeedLoop:=false
Other:=false
Other2:=false
Other3:=false
}

if GetKeyState(key_ScriptTerminate)
{
ExitApp
}

{
if PFeedLoop
{
Loop
{
   Send, Hhj JuL {enter}
   Sleep, 3000
   Send, EUa snEi {enter}
   Sleep, 3000
   Send, eWERA FASDF {enter}
   Sleep, 3000
   Send, EEdfsgs dfGHfdi {enter}
   Sleep, 3000
   Send, asd zxcddsf Aooo {enter}
   Sleep, 3000
   Send, EEa sdFGASs Eiii {enter}
   Sleep, 3000
   Send, eASD asdJkasXR3 323oo {enter}
   Sleep, 3000
   Send, EeEii ASDLuaSr M132i {enter}
   Sleep, 3000
}
}
}
;Other
else if Other
{
Loop
{
Sleep, 750
Send, EEE
}
}
;Other2
else if Other2
{
Send, select 154
}
;Other3
else if Other3
{
Send, select 94
}
}
Return
pro100andrik94
Posts: 27
Joined: 08 Aug 2018, 07:27

Re: Error: ELSE with no matching IF

15 Aug 2018, 03:48

Code: Select all

;Key binds
key_select:="F1"
key_Other:="F2"
key_Other2:="F3"
key_Other3:="F4"
key_ScriptPause:="F5"
key_ScriptTerminate:="F6"

Loop 
{
    Sleep 1

    if GetKeyState(key_select)
    {
        PFeedLoop:=true
        Other:=false
        Other2:=false
        Other3:=false
    }

    if GetKeyState(key_Other)
    {
        PFeedLoop:=false
        Other:=true
        Other2:=false
        Other3:=false
    }
    
    if GetKeyState(key_Other2)
    {
        PFeedLoop:=false
        Other:=false
        Other2:=true
        Other3:=false
    }
    
    if GetKeyState(key_Other3)
    {
        PFeedLoop:=false
        Other:=false
        Other2:=false
        Other3:=true
    }
    
    if GetKeyState(key_ScriptPause)
    {
        PFeedLoop:=false
        Other:=false
        Other2:=false
        Other3:=false
    }
    
    if GetKeyState(key_ScriptTerminate)
    {
        ExitApp
    }
    ; 1) you need operator "if" here to do "else if" in 81 line and etc.
    {
        if PFeedLoop
        {
            Loop
            {   
                Send, Hhj JuL {enter}
                Sleep, 3000
                Send, EUa snEi {enter}
                Sleep, 3000
                Send, eWERA FASDF {enter}
                Sleep, 3000
                Send, EEdfsgs dfGHfdi {enter}
                Sleep, 3000
                Send, asd zxcddsf Aooo {enter}
                Sleep, 3000
                Send, EEa sdFGASs Eiii {enter}
                Sleep, 3000
                Send, eASD asdJkasXR3 323oo {enter}
                Sleep, 3000
                Send, EeEii ASDLuaSr M132i {enter}
                Sleep, 3000
            }   
        }
        ; 2) or put "else if other" and etc. here 
    }
    ;Other
    else if Other
    {
        Loop
        {
            Sleep, 750
            Send, EEE
        }
    }
    ;Other2
    else if Other2
    {
        Send, select 154
    }
    ;Other3
    else if Other3
    {
        Send, select 94
    }
    }
    Return
There are two solution options that have been written in the comments to the code. And I think the second one will be more correct.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Error: ELSE with no matching IF

15 Aug 2018, 04:55

Why are you not using hotkeys for this? I don't see why you need GetKeyState loops

Code: Select all

F1::
PFeedLoop:=true
Other:=false
Other2:=false
Other3:=false
return

F2::
PFeedLoop:=false
Other:=true
Other2:=false
Other3:=false
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 226 guests