Sign in to follow this  
Followers 0
sachixakechi

Script runs once, then stops?

15 posts in this topic

Hi, I'm new to using AutoIt and I have been writing a script to have my scanner automatically scan images for me. The problem is that my script seems to work fine once, then after I try to run it again, it stops working.

Here's what it looks like ("Stacy" is the folder that automatically opens up when the scan program saves the image):

WinMinimizeAll()

Run("C:\Windows\twain_32\escndv\escndv.exe")

ControlClick("EPSON Scan", "", "[iD:1031]")

WinWait("Stacy")

WinClose("Stacy")

WinClose("EPSON Scan")

The script seems to stop running at the 3rd line (it doesn't click the scan button for me). I used the AutoIt Window Info program to get the ControlID number of the scan button so I am 100% sure that is correct. Is there a reason why it isn't working?

Thanks for the help!

Share this post


Link to post
Share on other sites



sachixakechi,

Welcome to the AutoIt forum. :)

The way your script is written at the moment, it is not waiting for the "Epson Scan" GUI to appear before trying to click the "1031" button. So as you do not click the button, the "Stacy" GUI never appears and therefore the script hangs. :)

I suggest adding another WinWait line: ;)

WinMinimizeAll()
Run("C:Windowstwain_32escndvescndv.exe")
WinWait("EPSON Scan") ; Wait for the GUI to appear <<<<<<<<<<<<<<<<<<<<<<<<
ControlClick("EPSON Scan", "", "[ID:1031]")
WinWait("Stacy")
WinClose("Stacy")
WinClose("EPSON Scan")

You may even have to add a short Sleep to let the GUI settle in its final state. Does that work? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hi, thanks for the suggestion! I tried adding the WinWait line, but it still does not click the scan button for me...I also used class/instance like John suggested.

Here's the script now:

WinMinimizeAll()

Run("C:Windowstwain_32escndvescndv.exe")

WinWait("EPSON Scan")

ControlClick("EPSON Scan", "", "[CLASS:Button; INSTANCE:33]")

WinWait("Stacy")

WinClose("Stacy")

WinClose("EPSON Scan")

Could this be a problem with the scanner/scanner program and not my script? @___@

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Does it do the same as your other script, or not click at all?

it does the same thing as my previous script. After I changed it and tried running it, it worked fine. I saved, I then tried to run it again and the second time, it wouldn't work...

Edited by sachixakechi

Share this post


Link to post
Share on other sites

How do you define the first time?

I mean, do you re-boot your computer, and that is the first time?

Silly 3 post a day restriction makes it impossible to reply = =

I edited the script, saved, and then ran it. It worked and the scan ran successfully. After the windows closed out as per my script, I then tried to run the script again. The second time, it seems to stop before clicking the button.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

freshringo (or should I say sachixakechi),

That restriction is there to prevent idiots causing too much mayhem. Creating multiple accounts is a serious offence here - you have got away with it this time as I assume you have not yet read the Forum Rules. Please do so now and stick to them in future. :naughty:

I will now merge the 2 accounts - and I strongly advise that you do not create any more duplicates. ;)

M23

P.S. You are also now able to post more than 3 times a day. A "thank you" would not go amiss! ;)

Edited by Melba23
Changed member status

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

@Melba: My bad! u_u This project is pretty time sensitive so I was in a rush to work it out here. Thanks for your help :)

Share this post


Link to post
Share on other sites

sachixakechi,

My pleasure. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

is the escnvd.exe process still running after winclose? if so, can it run repeatedly if you kill this process at the end rather than just close the window?


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

is the escnvd.exe process still running after winclose? if so, can it run repeatedly if you kill this process at the end rather than just close the window?

Good point! I checked up on this and I think I may have found the problem. It looks like I have to kill the process rather than just closing for the script to run repeatedly. Thank you so much for your help, and my biology lab thanks you as well! xD

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Same thoughts, that the second window may actually be named something else

like "EPSON Scan(2)" maybe.

Maybe you should let process end naturally.

WinMinimizeAll()

$Process = Run("C:Windowstwain_32escndvescndv.exe")

WinWait("EPSON Scan")

ControlClick("EPSON Scan", "", "[CLASS:Button; INSTANCE:33]")

WinWait("Stacy")

WinClose("Stacy")

WinClose("EPSON Scan")

While ProcessExists($Process)

Sleep(100)

WEnd

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

I will tinker around with the script some more and see if I can get around forcefully killing the program. Thank you for your help!

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