Jump to content

Save As Path


 Share

Recommended Posts

Greetings,

I was playing with the notpad tutorial and thought I'd extent it to give the file a name and then save it. I have been through the forum but can't find an example. Here's what I have so far:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "Do you want to save")
Send("!y")
WinWaitActive("Save As")
ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", "text.txt")
ControlCommand ( "Save As", "", "[ID:1137]", "showdropdown" , "" )
ControlClick("Save As", "", "[CLASS:SysListView; TEXT:Finish; INSTANCE:2]")

It give me the combo box, but I am lost as to how to select an option from the combo box. For instance if I wanted to save the file to My Documents or C:\My Files

Thanks,

Axslinger

Link to comment
Share on other sites

CODE
Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

Send("This is some text.")

WinClose("Untitled - Notepad")

WinWaitActive("Notepad", "Do you want to save")

Send("!y")

WinWaitActive("Save As")

ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", "C:\My Files

\text.txt")

;ControlCommand ( "Save As", "", "[iD:1137]", "showdropdown" , "" ) ;I think that it here is not necessary

ControlClick("Save As", "", "[CLASS:SysListView; TEXT:Finish; INSTANCE:2]")

Link to comment
Share on other sites

CODE
Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

Send("This is some text.")

WinClose("Untitled - Notepad")

WinWaitActive("Notepad", "Do you want to save")

Send("!y")

WinWaitActive("Save As")

ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", "C:\My Files

\text.txt")

;ControlCommand ( "Save As", "", "[iD:1137]", "showdropdown" , "" ) ;I think that it here is not necessary

ControlClick("Save As", "", "[CLASS:SysListView; TEXT:Finish; INSTANCE:2]")

That makes perfect sense. Thank you for that. Now for my next problem...

I spent at least an hour trying to click on Save and I can't get it to happen. I've used multiple incarnations of ControlClick and I just don't get it. I've tried referring to the button by "&Save", by control/instance number, etc, etc. Please tell me what is wrong with the last line in this code:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "Do you want to save")
Send("!y")
WinWaitActive("Save As")
ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", "C:\text.txt")
ControlClick ( "Save As", "", "[ID:1]", "Left" , "1")

Bear in mind, this is only one in many versions I have tried without success.

Brian

Link to comment
Share on other sites

That makes perfect sense. Thank you for that. Now for my next problem...

I spent at least an hour trying to click on Save and I can't get it to happen. I've used multiple incarnations of ControlClick and I just don't get it. I've tried referring to the button by "&Save", by control/instance number, etc, etc. Please tell me what is wrong with the last line in this code:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "Do you want to save")
Send("!y")
WinWaitActive("Save As")
ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", "C:\text.txt")
ControlClick ( "Save As", "", "[ID:1]", "Left" , "1")

Bear in mind, this is only one in many versions I have tried without success.

Brian

Here is something else I tried for saving the file. I tried using "send "[!s"] and it worked. But, I also tried

ControlClick("Save As", "", "[CLASS:Button; ClassnameNN:Button2; ID:1 Instance:2 TEXT:Save;]")

I had AutoIT Window Info running and put the mouse over the Save button so the info in the above code is correct. I don't get an error, but it doesn't save it either. It highlights a folder in the list view rather than clicking on the Save button. Grrr.

Brian

Link to comment
Share on other sites

It seems ControlSend actually sends "c;\text.txt" thats a semicolon instead of a colon (a windows "feature" or AutoIt bug). Put an exit in your code after ControlSend to verify what's in the filename combo box to confirm if you are getting the same.

Using ControlFocus and Send works properly.

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
Sleep(300)
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "Do you want to save")
Send("!y")
Sleep(300)
WinWaitActive("Save As")
ControlFocus("Save As", "", "[CLASS:Edit; INSTANCE:1]")
Send("c:\text.txt")
ControlClick("Save As", "", "[CLASS:Button; CLASSNN:Button2; INSTANCE:2; TEXT:&Save]")
Exit
Link to comment
Share on other sites

It seems ControlSend actually sends "c;\text.txt" thats a semicolon instead of a colon (a windows "feature" or AutoIt bug). Put an exit in your code after ControlSend to verify what's in the filename combo box to confirm if you are getting the same.

Using ControlFocus and Send works properly.

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
Sleep(300)
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "Do you want to save")
Send("!y")
Sleep(300)
WinWaitActive("Save As")
ControlFocus("Save As", "", "[CLASS:Edit; INSTANCE:1]")
Send("c:\text.txt")
ControlClick("Save As", "", "[CLASS:Button; CLASSNN:Button2; INSTANCE:2; TEXT:&Save]")
Exit
I was doing it as more of an exercise in accessing controls and saving files (I'm new to AutoIT and was simply learning). As I said, if I used Send "[!s]", then it actually saved the file, with the correct name and no problem with semi-colon. Thanks for your input, all ideas are good ideas!

Brian

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