Jump to content

Script runs once, then stops?


Recommended Posts

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!

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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? @___@

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

sachixakechi,

My pleasure. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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?

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

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

Link to comment
Share on other sites

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.

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...