Sign in to follow this  
Followers 0
nceipr

no matching "Wend"; "EndFunc" statements

19 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

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

Share this post


Link to post
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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Put a loop inside the function.

I'm sorry but I don't understand - I'm not native speaker. Can u code it?

Share this post


Link to post
Share on other sites

Ethiopia

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

@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

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

2 czardas: Thanks a lot, good man :thumbsup:

I also add Opt("SendKeyDelay", 1) and it's work perfectly

Share this post


Link to post
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
Sign in to follow this  
Followers 0