sachixakechi Posted July 21, 2012 Share Posted July 21, 2012 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 More sharing options...
Moderators Melba23 Posted July 21, 2012 Moderators Share Posted July 21, 2012 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted July 21, 2012 Share Posted July 21, 2012 Also the ID might change, think about using the button class and instance. 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 More sharing options...
sachixakechi Posted July 21, 2012 Author Share Posted July 21, 2012 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 More sharing options...
JohnOne Posted July 21, 2012 Share Posted July 21, 2012 Does it do the same as your other script, or not click at all? 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 More sharing options...
sachixakechi Posted July 21, 2012 Author Share Posted July 21, 2012 (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 July 21, 2012 by sachixakechi Link to comment Share on other sites More sharing options...
JohnOne Posted July 21, 2012 Share Posted July 21, 2012 How do you define the first time? I mean, do you re-boot your computer, and that is the first time? 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 More sharing options...
sachixakechi Posted July 21, 2012 Author Share Posted July 21, 2012 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 More sharing options...
Moderators Melba23 Posted July 21, 2012 Moderators Share Posted July 21, 2012 (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. I will now merge the 2 accounts - and I strongly advise that you do not create any more duplicates. M23P.S. You are also now able to post more than 3 times a day. A "thank you" would not go amiss! Edited July 21, 2012 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
sachixakechi Posted July 21, 2012 Author Share Posted July 21, 2012 @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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 21, 2012 Moderators Share Posted July 21, 2012 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
iamtheky Posted July 21, 2012 Share Posted July 21, 2012 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 More sharing options...
sachixakechi Posted July 21, 2012 Author Share Posted July 21, 2012 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 More sharing options...
JohnOne Posted July 21, 2012 Share Posted July 21, 2012 (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 July 21, 2012 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 More sharing options...
sachixakechi Posted July 21, 2012 Author Share Posted July 21, 2012 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! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now