Jump to content

Getting error missing "NEXT" even after calling it


Ram
 Share

Recommended Posts

Hey,

I am writing a for loop and inside that calling a function and inside the function another for loop... for some reason autoit is showing missing "NEXT" and reference to For $i = 1 To 10.

Can't I have inner for loop..why does autoit give error even though I have put Next in the end of script..!! Please help me out in getting this solved??

For $i = 1 To 10

$m = 20

$n = 120

_MouseClick2(ControlGetHandle("Products", "", "TPageControl1"), "left", $m, $n)

Func _MakeLong2 ($LoWord2, $HiWord2)

Return BitOR ($HiWord2 * 0x10000, BitAND($LoWord2, 0xFFFF))

EndFunc

Func _MouseClick2($hWnd2, $button2, $m, $n, $times2=1, $delay2=250)

If $hWnd2 = 0 Then

SetError(-1)

Return

EndIf

Local $ix2

Local $lParam2 = _MakeLong2 ($m, $n)

Local $user322 = DllOpen("C:\WINDOWS\system32\user32.dll")

$button2 = StringLower($button2)

If $button2 = "left" Then

For $ix2 = 1 To $times2

DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x200, "int", 0, "long", $lParam2)

DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x201, "int", 1, "long", $lParam2)

DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x202, "int", 0, "long", $lParam2)

If $ix2 < $times2 Then Sleep($delay2)

Next

ElseIf $button2 = "right" Then

For $ix2 = 1 To $times2

DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x200, "int", 0, "long", $lParam2)

DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x204, "int", 2, "long", $lParam2)

DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x205, "int", 0, "long", $lParam2)

If $ix2 < $times2 Then Sleep($delay2)

Next

Else

SetError(-2)

If $user322 <> -1 Then DllClose($user322)

Return

EndIf

If $user322 <> -1 Then DllClose($user322)

EndFunc

Next $i

Thanks!

Edited by Ram
Link to comment
Share on other sites

Hey,

I am writing a for loop and inside that calling a function and inside the function another for loop... for some reason autoit is showing missing "NEXT" and reference to For $i = 1 To 10.

Can't I have inner for loop..why does autoit give error even though I have put Next in the end of script..!! Please help me out in getting this solved??

For $i = 1 To 10

$m = 20

$n = 120

_MouseClick2(ControlGetHandle("Products", "", "TPageControl1"), "left", $m, $n)

Func _MakeLong2 ($LoWord2, $HiWord2)

Return BitOR ($HiWord2 * 0x10000, BitAND($LoWord2, 0xFFFF))

EndFunc

Func _MouseClick2($hWnd2, $button2, $m, $n, $times2=1, $delay2=250)

If $hWnd2 = 0 Then

SetError(-1)

Return

EndIf

Local $ix2

Local $lParam2 = _MakeLong2 ($m, $n)

Local $user322 = DllOpen("C:\WINDOWS\system32\user32.dll")

$button2 = StringLower($button2)

If $button2 = "left" Then

For $ix2 = 1 To $times2

DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x200, "int", 0, "long", $lParam2)

DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x201, "int", 1, "long", $lParam2)

DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x202, "int", 0, "long", $lParam2)

If $ix2 < $times2 Then Sleep($delay2)

Next

ElseIf $button2 = "right" Then

For $ix2 = 1 To $times2

DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x200, "int", 0, "long", $lParam2)

DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x204, "int", 2, "long", $lParam2)

DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x205, "int", 0, "long", $lParam2)

If $ix2 < $times2 Then Sleep($delay2)

Next

Else

SetError(-2)

If $user322 <> -1 Then DllClose($user322)

Return

EndIf

If $user322 <> -1 Then DllClose($user322)

EndFunc

Next $i

Thanks!

You can not delcare a function inside of a for loop. Your code, properly written, should look something like:

For $i = 1 To 10
  $m = 20
  $n = 120
  _MouseClick2(ControlGetHandle("Products", "", "TPageControl1"), "left", $m, $n)
Next $i

Func _MakeLong2 ($LoWord2, $HiWord2)
  Return BitOR ($HiWord2 * 0x10000, BitAND($LoWord2, 0xFFFF))
EndFunc

Func _MouseClick2($hWnd2, $button2, $m, $n, $times2=1, $delay2=250)
  If $hWnd2 = 0 Then
    SetError(-1)
    Return
  EndIf
    
  Local $ix2
  Local $lParam2 = _MakeLong2 ($m, $n)
  Local $user322 = DllOpen("C:\WINDOWS\system32\user32.dll")
    
  $button2 = StringLower($button2)
    
  If $button2 = "left" Then
    For $ix2 = 1 To $times2
      DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x200, "int", 0, "long", $lParam2)
      DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x201, "int", 1, "long", $lParam2)
      DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x202, "int", 0, "long", $lParam2)

      If $ix2 < $times2 Then Sleep($delay2)
    next
  ElseIf $button2 = "right" Then
    For $ix2 = 1 To $times2
      DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x200, "int", 0, "long", $lParam2)
      DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x204, "int", 2, "long", $lParam2)
      DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x205, "int", 0, "long", $lParam2)
            
      If $ix2 < $times2 Then Sleep($delay2)
    Next
  Else
    SetError(-2)
    If $user322 <> -1 Then DllClose($user322)
      Return
  EndIf
  If $user322 <> -1 Then DllClose($user322)
EndFunc
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

You can not delcare a function inside of a for loop. Your code, properly written, should look something like:

For $i = 1 To 10
  $m = 20
  $n = 120
  _MouseClick2(ControlGetHandle("Products", "", "TPageControl1"), "left", $m, $n)
Next $i

Func _MakeLong2 ($LoWord2, $HiWord2)
  Return BitOR ($HiWord2 * 0x10000, BitAND($LoWord2, 0xFFFF))
EndFunc

Func _MouseClick2($hWnd2, $button2, $m, $n, $times2=1, $delay2=250)
  If $hWnd2 = 0 Then
    SetError(-1)
    Return
  EndIf
    
  Local $ix2
  Local $lParam2 = _MakeLong2 ($m, $n)
  Local $user322 = DllOpen("C:\WINDOWS\system32\user32.dll")
    
  $button2 = StringLower($button2)
    
  If $button2 = "left" Then
    For $ix2 = 1 To $times2
      DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x200, "int", 0, "long", $lParam2)
      DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x201, "int", 1, "long", $lParam2)
      DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x202, "int", 0, "long", $lParam2)

      If $ix2 < $times2 Then Sleep($delay2)
    next
  ElseIf $button2 = "right" Then
    For $ix2 = 1 To $times2
      DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x200, "int", 0, "long", $lParam2)
      DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x204, "int", 2, "long", $lParam2)
      DllCall($user322, "int", "PostMessage", "hwnd", $hWnd2, "int", 0x205, "int", 0, "long", $lParam2)
            
      If $ix2 < $times2 Then Sleep($delay2)
    Next
  Else
    SetError(-2)
    If $user322 <> -1 Then DllClose($user322)
      Return
  EndIf
  If $user322 <> -1 Then DllClose($user322)
EndFuncoÝ÷ Ûú®¢×¶¸vØ^/y»­¶¢²è¢bv}ý·
+ø§y8^¦º ­©'$²Ø^éîmªèÇ­Â'nëb¶ÈhºWZrÛ'$âئzÌ!jÜ(ºW[zØ^+-jG¡z·z·¢²Ø^r^¶­"ÚâyÖ®¶­s` ¥'VâgV÷C´3¢b3#µ&öw&ÒfÆW2b3#´Ö7&÷6ögBöff6Rb3#´ôdd4Sb3#´÷WFÆöö²æWRgV÷C² ¤÷BgV÷CµvåFFÆTÖF6ÖöFRgV÷C²Â¤÷BgV÷CµvåvDFVÆgV÷C²ÂS¥våvBgV÷C´æ&÷gV÷C² ¤f÷"b33c¶ÒFò@ ¢b33c¶ÒÒc¢b33c¶âÒ0 ¥ôÖ÷W6T6Æ6³"6öçG&öÄvWDæFÆRgV÷C´æ&÷gV÷C²ÂgV÷C²gV÷C²ÂgV÷C´×6ô6öÖÖæD&#2gV÷C²ÂgV÷C¶ÆVgBgV÷C²Âb33c¶ÒÂb33c¶â ¤÷BgV÷CµvåFFÆTÖF6ÖöFRgV÷C²Â¤÷BgV÷CµvåvDFVÆgV÷C²Â3¥våvBgV÷C´æ&÷gV÷C² ¢b33c¶ÒÒc¢b33c¶âÒ3p ¥ôÖ÷W6T6Æ6³"6öçG&öÄvWDæFÆRgV÷C´æ&÷gV÷C²ÂgV÷C²gV÷C²ÂgV÷C´×6ô6öÖÖæD&#gV÷C²ÂgV÷C¶ÆVgBgV÷C²Âb33c¶ÒÂb33c¶â ¢æW@  ¤gVæ2ôÖ¶TÆöæs"b33c´Æõv÷&C"Âb33c´v÷&C"¢&WGW&â&"b33c´v÷&C"¢Â&DäBb33c´Æõv÷&C"Âdddb¤VæDgVæ0 ¤gVæ2ôÖ÷W6T6Æ6³"b33c¶væC"Âb33c¶'WGFöã"Âb33c¶ÒÂb33c¶âÂb33c·FÖW3#ÓÂb33c¶FVÆ#Ó#S¢bb33c¶væC"ÒFVà¢6WDW'&÷"Ó¢&WGW&à¢VæD`¢¢Æö6Âb33c¶ ¢Æö6Âb33c¶Å&Ó"ÒôÖ¶TÆöæs"b33c¶ÒÂb33c¶â¢Æö6Âb33c·W6W#3#"ÒFÆÄ÷VâgV÷C´3¢b3#µtäDõu2b3#·77FVÓ3"b3#·W6W#3"æFÆÂgV÷C²¢¢b33c¶'WGFöã"Ò7G&ætÆ÷vW"b33c¶'WGFöã"¢¢bb33c¶'WGFöã"ÒgV÷C¶ÆVgBgV÷C²FVà¢f÷"b33c¶"ÒFòb33c·FÖW3 ¢FÆÄ6ÆÂb33c·W6W#3#"ÂgV÷C¶çBgV÷C²ÂgV÷Cµ÷7DÖW76vRgV÷C²ÂgV÷C¶væBgV÷C²Âb33c¶væC"ÂgV÷C¶çBgV÷C²Â#ÂgV÷C¶çBgV÷C²ÂÂgV÷C¶ÆöærgV÷C²Âb33c¶Å&Ó"¢FÆÄ6ÆÂb33c·W6W#3#"ÂgV÷C¶çBgV÷C²ÂgV÷Cµ÷7DÖW76vRgV÷C²ÂgV÷C¶væBgV÷C²Âb33c¶væC"ÂgV÷C¶çBgV÷C²Â#ÂgV÷C¶çBgV÷C²ÂÂgV÷C¶ÆöærgV÷C²Âb33c¶Å&Ó"¢FÆÄ6ÆÂb33c·W6W#3#"ÂgV÷C¶çBgV÷C²ÂgV÷Cµ÷7DÖW76vRgV÷C²ÂgV÷C¶væBgV÷C²Âb33c¶væC"ÂgV÷C¶çBgV÷C²Â#"ÂgV÷C¶çBgV÷C²ÂÂgV÷C¶ÆöærgV÷C²Âb33c¶Å&Ó" ¢bb33c¶"fÇC²b33c·FÖW3"FVâ6ÆVWb33c¶FVÆ"¢æW@¢VÇ6Tbb33c¶'WGFöã"ÒgV÷C·&vBgV÷C²FVà¢f÷"b33c¶"ÒFòb33c·FÖW3 ¢FÆÄ6ÆÂb33c·W6W#3#"ÂgV÷C¶çBgV÷C²ÂgV÷Cµ÷7DÖW76vRgV÷C²ÂgV÷C¶væBgV÷C²Âb33c¶væC"ÂgV÷C¶çBgV÷C²Â#ÂgV÷C¶çBgV÷C²ÂÂgV÷C¶ÆöærgV÷C²Âb33c¶Å&Ó"¢FÆÄ6ÆÂb33c·W6W#3#"ÂgV÷C¶çBgV÷C²ÂgV÷Cµ÷7DÖW76vRgV÷C²ÂgV÷C¶væBgV÷C²Âb33c¶væC"ÂgV÷C¶çBgV÷C²Â#BÂgV÷C¶çBgV÷C²Â"ÂgV÷C¶ÆöærgV÷C²Âb33c¶Å&Ó"¢FÆÄ6ÆÂb33c·W6W#3#"ÂgV÷C¶çBgV÷C²ÂgV÷Cµ÷7DÖW76vRgV÷C²ÂgV÷C¶væBgV÷C²Âb33c¶væC"ÂgV÷C¶çBgV÷C²Â#RÂgV÷C¶çBgV÷C²ÂÂgV÷C¶ÆöærgV÷C²Âb33c¶Å&Ó"¢¢bb33c¶"fÇC²b33c·FÖW3"FVâ6ÆVWb33c¶FVÆ"¢æW@¢VÇ6P¢6WDW'&÷"Ó"¢bb33c·W6W#3#"fÇC²fwC²ÓFVâFÆÄ6Æ÷6Rb33c·W6W#3#"¢&WGW&à¢VæD`¢bb33c·W6W#3#"fÇC²fwC²ÓFVâFÆÄ6Æ÷6Rb33c·W6W#3#"¢VæDgVæ0
Edited by Ram
Link to comment
Share on other sites

I think it may be that you only have

_MouseClick2 (ControlGetHandle("Inbox", "", "MsoCommandBar1"), "left", $m, $n)
appear two times instead of four in your function.

Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
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...