Jump to content

If Title is?


gnorris
 Share

Recommended Posts

I want to have a script look for one of a few Window Titles and take actions depending on what it see's. The application I'm making is called JustMoveIt and does pretty much what it's name suggest. If a prompt comes up while moving files it answers for me.

The reason this came up is because I recently purchased a 2TB External Hard Drive and am moving data from a 1TB external hard drive (that's mostly full). Since the process is so huge I want to be able to just start the move then walk away and do something else. The problem is that when Windows moves files a variety of Prompts tend to come up and the Move process simply freezes until a response is given. Obviously if I'm away from my computer I can't answer the questions though I already know the answers (If sharing, continue, if merging, yes, if overwriting, yes). Right now I have a script that just deals with that first one (Sharing) as there's no option to say yes to all. I would however like to have it work for the other cases as well. My current script is:

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.4.0

Author: myName

Script Function:

Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

; Ultimately this script will continue move even if sharing, merge folders, and overwrite

; files. Until find way to say if title is this program only continues even if sharing.

AutoItSetOption ("WinTitleMatchMode", 2) ;Tells program how to read WinWaitActive

while 1=1 ;start loop

WinWaitActive ("Sharing") ;wait for Sharing thing to come up

send ("{ENTER}") ; Enter, says Continue

WEnd ;End loop

Since I don't know the order in which the prompts will come up WinWaitActive is really ineffective but, no matter how I phrase it I've not found any references on how to compare titles.

For now I just want to use send keys to answer the prompts, if I can get it working that far then I'll try to be a bit more fancy with something like selecting the checkbox (if it exist) to do this for all items. I could also eventually add some mouse movement or something to prevent things like auto-lock and auto-sleep from interfering (If the screen locks up then Move is no longer the focus and which may also mean that anything the move command brings up won't be focused thus, it won't be able to select anything). Also, obviously enough I can't implement the mouse moving thing if it's always waiting so I have to wait until I find an alternative to this script.

For those who are like: Who the heck is this guy: The name's Greg, I've been using AutoIt off and on for at least a year now (that's when I created this account) though I really can't remember when I started. The last forum activity I had was when I was forwarding emails from a yahoo to hotmail account (probably when I created this account) and trying to automate it with a script. Unfortunately, that script ended up failing miserably as there was no way of dealing with the variable wait times (the URL either didn't change or changed unpredictably and the load times varied from 30 seconds to a couple of minutes or more [bad connection and slow servers] so even with ff.au3 it was impossible).

Link to comment
Share on other sites

I imagine reading your post that you want something like:

While 1
    Select
        Case WinExists("Sharing")
            ; Deal with it
        Case WinExists("Merging")
            ; Deal with it
        Case WinExists("Overwriting")
            ; Deal with it
    EndSelect
    Sleep(10)
WEnd

I may have misunderstood what you wanted but that sounds about right.

Link to comment
Share on other sites

I imagine reading your post that you want something like:

While 1
    Select
        Case WinExists("Sharing")
            ; Deal with it
        Case WinExists("Merging")
            ; Deal with it
        Case WinExists("Overwriting")
            ; Deal with it
    EndSelect
    Sleep(10)
WEnd

I may have misunderstood what you wanted but that sounds about right.

Thanks, that itself sounds like it would work but, when I looked it up in the help I found WinActive which is an even better match to what I want to do (since I don't want try doing something just because it exist. Perhaps I could use WinExist as well and make the Window Active if it isn't. I'll have to test this later when I have access to my large externals again (currently at school where I get internet).
Link to comment
Share on other sites

Got it working for the most part. There are a few parts that still just pseudo code or English statements as I've not yet come across the circumstances or when I did I forgot to write code to automate those parts. For instance the overwrite section has a case statement but, no actual code yet (I plan to use mouse movement for this part which will require a bit more study time as I've yet to implement anything more that mouse movement which you'll see in my code). SO without further ado here's the code for JustMoveIt.au3:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.4.0
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
; Ultimately this script will continue move even if sharing, merge folders, and overwrite
; files.  Until find way to say if title is this program only continues even if sharing.
AutoItSetOption ("WinTitleMatchMode", 2) ;Tells program how to read WinWaitActive
Global $Time = 0 ; Declare the Time Variable
While 1
    $Time = $Time+1 ; Add 1 every time the loop begins
    if ($Time=120000) Then ; if 20 Minutes have passed
        MouseMove(770, 450) ; Move the mouse to the middle of the screeen
        sleep(10) ; pause 10 milli's
        MouseMove(760, 450) ; Move the mouse slightly left
        EndIf
    Select
    Case WinActive("Moving") ; This is to prevent accidental selections.
        ; Do nothing
    Case WinExists("Sharing") ; If the Window about Shared files comes up.
        WinActivate("Sharing") ; if the Window isn't active, activate it
        send("{ENTER}") ; Select Continue
        $Time = 0 ; reset Time to 0 (avoid extra MoveMent
    Case WinExists("Folder Replace") ; If the Window about Merging appears
        ; May eventually change this to be more like the one below.
        WinActivate("Folder Replace") ; if the Window isn't active, activate it
        send("{ENTER}") ; Merge the Folders.
        $Time = 0 ; reset Time to 0 (avoid extra MoveMent
    Case WinExists("Moving","Move and Replace") ; If a window exist with title Moving
        ; and text Move and Replace then.
        
        ; Search for the text Do this for all conflicts
        
        ; Use mouse to select checkbox to the left of this text (need to get the location
            ; data then manipulate it to hover over then click the check box)
            
        ; Whether or not the above happens move the mouse to the text "Move and Replace" Then
            ; click that.
        $Time = 0 ; reset Time to 0 (avoid extra MoveMent
    Case WinExists("System File") ; If the Window about Moving System Files comes up.
        ; Same approach as Overwrite
        $Time = 0 ; reset Time to 0 (avoid extra MoveMent
    EndSelect
    sleep(10)
WEnd

The MouseMove part is because I have my screen set to lock after 30-minutes so if I'm not there to answer questions and a question doesn't pop up in 20 minutes it'll move the mouse to prevent screen lock.

Unfortunately I'm not really sure when I'll get around to finishing this code as it's really somewhat specialized to the movement of large data but, if nothing else then perhaps someone else will find use of it and perhaps even finish the idea.

Link to comment
Share on other sites

There might be an easier way for you - google a program call YCOPY - no prompts from what I remember.

Simple, free, set and forget, copy utility. When a file can't be copied Ycopy skips it continues with the other files. A printable report is generated of files that were unable to be copied. No more poring over directories and files to find out where the copy was up to, skip the affected files and continue the copy. A real time saver for computer technicians, IT people or anyone routinely faced with this task.

LINK http://download.cnet.com/Ycopy/3000-2248_4-10494065.html

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

I'll have to check those other programs out sometime but, even if I end up using a different program than my own to copy/move data it's still good practice and a good reference for future programs. Plus, I don't have to worry about running out of room for programs on my internal (those other programs are probably more than a couple Kilobyte's of source code) (I only have a 250GB internal 50GB of which are devoted to C:\). I use the externals for Video's and Disc Images which take a lot of room.

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