Jump to content

no matching "Wend"; "EndFunc" statements


Go to solution Solved by czardas,

Recommended Posts

Try to combine my recorded script and this one

But mine has bunch of errors:

1."While" statement has no matching "Wend" statement

2.Func has no matching "EndFunc"

Google don't

Opt("WinTitleMatchMode", 2)
HotKeySet ( "!^{q}", "_doit" )
HotKeySet("!{ESC}", "Terminate")
While 1
Func _doit()
_WinWaitActivate("FastStone Image Viewer 4.2","")
Send("{F2}")
_WinWaitActivate("Rename","")
Send("{HOME}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{SHIFTDOWN}{END}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{ESC}")
_WinWaitActivate("FastStone Image Viewer 4.2","")
Send("{ENTER}")
_WinWaitActivate(".jpg  -  FastStone Image Viewer 4.2","")
Send("{F2}")
_WinWaitActivate("Rename","")
Send("{CTRLDOWN}v{CTRLUP}{ENTER}")
_WinWaitActivate(".jpg  -  FastStone Image Viewer 4.2","")
Send("{BACKSPACE}")
_WinWaitActivate("FastStone Image Viewer 4.2","")
Send("{RIGHT}")
Func Terminate()
   Exit 0
EndFunc
WEnd
Edited by nceipr
Link to comment
Share on other sites

Basically you don't have an EndFunc before the Wend, which is throwing the While - Wend error too.

This is a pretty basic error, so I'm wondering if you actually know how to script and if these are code you actually wrote yourself?

Forget most of that, I just re-read your post, so undoubtedly you are a beginner.

Researching those keywords in the Help file is always a good place to start, and may have given you the clues to determine my explanation of the errors.

I suggest you do the freely available tutorials here, which will help you make sense of the stuff you are recording.

However, I really do not recommend that you start your experience with AutoIt, using Recorder programs. They are better used once you have a grasp of some of the basics.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Basically you don't have an EndFunc before the Wend, which is throwing the While - Wend error too.

This is a pretty basic error, so I'm wondering if you actually know how to script and if these are code you actually wrote yourself?

Forget most of that, I just re-read your post, so undoubtedly you are a beginner.

Researching those keywords in the Help file is always a good place to start, and may have given you the clues to determine my explanation of the errors.

I suggest you do the freely available tutorials here, which will help you make sense of the stuff you are recording.

However, I really do not recommend that you start your experience with AutoIt, using Recorder programs. They are better used once you have a grasp of some of the basics.

OK I have edited code, but error still occur

Yes, I'm a newbie, but have experience with the AHK

Link to comment
Share on other sites

Welcome to AutoIt and the forum!

To create more reliable scripts I suggest to move from Send/WinWait commands to the Control* commands.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Do not put the Func keyword inside a loop.

Opt("WinTitleMatchMode", 2)
HotKeySet ( "!^{q}", "_doit" )
HotKeySet("!{ESC}", "Terminate")

While 1
    Sleep(10)
WEnd

Func _doit()
    _WinWaitActivate("FastStone Image Viewer 4.2","")
    Send("{F2}")
    _WinWaitActivate("Rename","")
    Send("{HOME}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{SHIFTDOWN}{END}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{ESC}")
    _WinWaitActivate("FastStone Image Viewer 4.2","")
    Send("{ENTER}")
    _WinWaitActivate(".jpg  -  FastStone Image Viewer 4.2","")
    Send("{F2}")
    _WinWaitActivate("Rename","")
    Send("{CTRLDOWN}v{CTRLUP}{ENTER}")
    _WinWaitActivate(".jpg  -  FastStone Image Viewer 4.2","")
    Send("{BACKSPACE}")
    _WinWaitActivate("FastStone Image Viewer 4.2","")
    Send("{RIGHT}")
EndFunc

Func Terminate()
   Exit
EndFunc
Edited by czardas
Link to comment
Share on other sites

Now it's work but not loop.

Opt('WinWaitDelay',200)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
Opt("WinTitleMatchMode", 2)
HotKeySet ( "!^{q}", "_doit" )
HotKeySet("!{ESC}", "Terminate")
While 1
   Sleep(10)
WEnd
Func _doit()
_WinWaitActivate("FastStone Image Viewer 4.2","")
Send("{F2}")
_WinWaitActivate("Rename","")
Send("{HOME}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{SHIFTDOWN}{END}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{ESC}")
_WinWaitActivate("FastStone Image Viewer 4.2","")
Send("{ENTER}")
_WinWaitActivate(".jpg  -  FastStone Image Viewer 4.2","")
Send("{F2}")
_WinWaitActivate("Rename","")
Send("{CTRLDOWN}v{CTRLUP}{ENTER}")
_WinWaitActivate(".jpg  -  FastStone Image Viewer 4.2","")
Send("{BACKSPACE}")
_WinWaitActivate("FastStone Image Viewer 4.2","")
Send("{RIGHT}")
EndFunc
Func Terminate()
    Exit 0
Endfunc
Edited by nceipr
Link to comment
Share on other sites

So I guess you speak Amharic. Perhaps this dictionary will help.

Replace this part.

Func _doit()
    While 1
        _WinWaitActivate("FastStone Image Viewer 4.2","")
        Send("{F2}")
        _WinWaitActivate("Rename","")
        Send("{HOME}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{SHIFTDOWN}{END}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{ESC}")
        _WinWaitActivate("FastStone Image Viewer 4.2","")
        Send("{ENTER}")
        _WinWaitActivate(".jpg  -  FastStone Image Viewer 4.2","")
        Send("{F2}")
        _WinWaitActivate("Rename","")
        Send("{CTRLDOWN}v{CTRLUP}{ENTER}")
        _WinWaitActivate(".jpg  -  FastStone Image Viewer 4.2","")
        Send("{BACKSPACE}")
        _WinWaitActivate("FastStone Image Viewer 4.2","")
        Send("{RIGHT}")
    WEnd
EndFunc
Edited by czardas
Link to comment
Share on other sites

@nceipr
While 1
        _doit()
    Sleep(10)
WEnd

Or the loop version given by czardas.

 

Do not put the Func keyword inside a loop.

Oops, sometimes we (I) miss the obvious.

EDIT

Edited because it didn't read right.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

 

So I guess you speak Amharic. Perhaps this dictionary will help.

Replace this part.

Func _doit()
    While 1
        _WinWaitActivate("FastStone Image Viewer 4.2","")
        Send("{F2}")
        _WinWaitActivate("Rename","")
        Send("{HOME}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{SHIFTDOWN}{END}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{ESC}")
        _WinWaitActivate("FastStone Image Viewer 4.2","")
        Send("{ENTER}")
        _WinWaitActivate(".jpg  -  FastStone Image Viewer 4.2","")
        Send("{F2}")
        _WinWaitActivate("Rename","")
        Send("{CTRLDOWN}v{CTRLUP}{ENTER}")
        _WinWaitActivate(".jpg  -  FastStone Image Viewer 4.2","")
        Send("{BACKSPACE}")
        _WinWaitActivate("FastStone Image Viewer 4.2","")
        Send("{RIGHT}")
    WEnd
EndFunc

Everytime closes right after open

Or the loop version given by czardas.

 

Oops, sometimes we (I) miss the obvious.

EDIT

Edited because it didn't read right.

It's work but immediately without hotkey.

Link to comment
Share on other sites

Everytime closes right after open

 

Then there is something wrong with the method you are using.

It's work but immediately without hotkey.

 

Are you sure it works? - because there is not much difference between the two examples, The only difference is Sleep(10).

Edited by czardas
Link to comment
Share on other sites

Then there is something wrong with the method you are using.

 

Are you sure it works? - because there is not much difference between the two examples, The only difference is Sleep(10).

Yes, autoit closes immediately.

Link to comment
Share on other sites

  • Solution

I don't think you replaced the code like I said, which would explain why AutoIt exits.

Opt("WinTitleMatchMode", 2)
HotKeySet ( "!^{q}", "_doit" )
HotKeySet("!{ESC}", "Terminate")

While 1
    Sleep(10)
WEnd

Func _doit()
    While 1
        _WinWaitActivate("FastStone Image Viewer 4.2","")
        Send("{F2}")
        _WinWaitActivate("Rename","")
        Send("{HOME}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{SHIFTDOWN}{END}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{ESC}")
        _WinWaitActivate("FastStone Image Viewer 4.2","")
        Send("{ENTER}")
        _WinWaitActivate(".jpg  -  FastStone Image Viewer 4.2","")
        Send("{F2}")
        _WinWaitActivate("Rename","")
        Send("{CTRLDOWN}v{CTRLUP}{ENTER}")
        _WinWaitActivate(".jpg  -  FastStone Image Viewer 4.2","")
        Send("{BACKSPACE}")
        _WinWaitActivate("FastStone Image Viewer 4.2","")
        Send("{RIGHT}")
    WEnd
EndFunc

Func Terminate()
   Exit
EndFunc
Edited by czardas
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...