Jump to content

First inconsistancy for learning newbie - help, please.


 Share

Recommended Posts

Hello there.

I'm new at AutoIt and am working my way through some tutorials. I'm reading the PDF and am puzzled by the first 'notepad'

script.

The tutorial instructs me to add the line:

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

- which works fine. My question is, where does the text come from, and why does it work?

The actual text on the box, found using the 'Window Spy' executable, is as follows:

"The text in the Untitled file has changed.

Do you want to save the changes?"

...however, when I tried including that in the script (WinWaitActive("Notepad", "The text in the Untitled file has changed.

Do you want to save the changes?")

...it doesn't work.

Can somebody please explain this to me, and also advise how I am to find the correct text to use in the future?

I also have another question.. Can somebody please advise me how to open a shared folder on a network - specifically, a printer queue selection page on a print server.

Thanks in advance.

Edited by wreckage
Link to comment
Share on other sites

It doesn't work when you use the full window text as is since there is a line break in the text.

The line breaks from copied text aren't recognized as part of the string, they're seen as line breaks in the code. Don't know which line break you need to replace it with so it gets recognized properly, whether it's @CR, @LF, or @CRLF.

In any case, the window text matching succeeds on partial text matches, so you are better off just using a unique line of text from you target window rather than using all the visible text.

Edited by omikron48
Link to comment
Share on other sites

It doesn't work when you use the full window text as is since there is a line break in the text.

The line breaks from copied text aren't recognized as part of the string, they're seen as line breaks in the code. Don't know which line break you need to replace it with so it gets recognized properly, whether it's @CR, @LF, or @CRLF.

In any case, the window text matching succeeds on partial text matches, so you are better off just using a unique line of text from you target window rather than using all the visible text.

Thank-you very much, Omikron48. You have explained it very well.

Would you be kind enough to advise me how to open a shared folder on a network - specifically, a printer queue selection page on a print server?

I know how to enter text in the 'run' field, but I'd rather the server window just opened.

Thanks again.

Link to comment
Share on other sites

You can just make a new shortcut and type the location of the network folder.

Then all you need to do is double-click the shortcut.

Thanks for that, but I'll rephrase the question. I figured it was implicit as we are on the AutoIt forum. This script will be

for copying to user desktops.

Would you be kind enough to advise me, using AutoIt, how to open a shared folder on a network - specifically, a printer queue selection page on a print server?

I know how to enter text in the 'run' field, but I'd rather the server window just opened.

Thanks in advance.

Link to comment
Share on other sites

The shortcut isn't a bad ideal. However if you want a script to do the opening you can shellexecute the shortcut.

the explorer is an .exe file

you can run it and enter the folder you would like to look up,

i've used this in a gui with some buttons to open a specific folder

Run("explorer.exe")
$errorCheck = WinWait("[class:ExploreWClass]", "", 5)
If Not $errorCheck Then
   MsgBox(0, "Error", "WinWait timed out while opening Explorer.exe")
   Exit
EndIf
ControlFocus("[class:ExploreWClass]", "", "Edit1")
Send("C:\Documents and Settings\All Users\Documents\My Music\Sample Music")
Sleep(500)
Send("{enter}")
Edited by Googamanga
Link to comment
Share on other sites

Thanks, Googamanga for the helpful code snippet!

Cheers.

the explorer is an .exe file

you can run it and enter the folder you would like to look up,

i've used this in a gui with some buttons to open a specific folder

Run("explorer.exe")
$errorCheck = WinWait("[class:ExploreWClass]", "", 5)
If Not $errorCheck Then
   MsgBox(0, "Error", "WinWait timed out while opening Explorer.exe")
   Exit
EndIf
ControlFocus("[class:ExploreWClass]", "", "Edit1")
Send("C:\Documents and Settings\All Users\Documents\My Music\Sample Music")
Sleep(500)
Send("{enter}")

Link to comment
Share on other sites

Actually, it's more like:

Run(explorer.exe /root,"C:\Documents and Settings\All Users\Documents\My Music\Sample Music"

;OR

Run(explorer.exe /root,\\computer1\sharedfolder)

Here's the commandline arguments for explorer: http://support.microsoft.com/kb/152457

Edited by omikron48
Link to comment
Share on other sites

Actually, it's more like:

Run(explorer.exe /root,"C:\Documents and Settings\All Users\Documents\My Music\Sample Music"

;OR

Run(explorer.exe /root,\\computer1\sharedfolder)

Here's the commandline arguments for explorer: http://support.microsoft.com/kb/152457

You will need some quotes in the right places:-)
Run("explorer.exe /e,C:\Documents and Settings\All Users")

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

the explorer is an .exe file

you can run it and enter the folder you would like to look up,

i've used this in a gui with some buttons to open a specific folder

Run("explorer.exe")
$errorCheck = WinWait("[class:ExploreWClass]", "", 5)
If Not $errorCheck Then
 MsgBox(0, "Error", "WinWait timed out while opening Explorer.exe")
 Exit
EndIf
ControlFocus("[class:ExploreWClass]", "", "Edit1")
Send("C:\Documents and Settings\All Users\Documents\My Music\Sample Music")
Sleep(500)
Send("{enter}")

Welcome to the forum.

Some people hide the address bar within Windows (file) explorer; so your code might not work for them.

If this code is just for your use and you don't want to use the command line info posted above for some reason (like reusing one explorer window to go to multiple locations) look into using the Control... functions instead of Send. They are more reliable.

Run("explorer.exe")
$errorCheck = WinWait("[class:ExploreWClass]", "", 5)
If Not $errorCheck Then
    MsgBox(0, "Error", "WinWait timed out while opening Explorer.exe")
    Exit
EndIf
ControlFocus("[class:ExploreWClass]", "", "Edit1")
ControlSetText("[class:ExploreWClass]", "", "Edit1", "C:\Documents and Settings\All Users\")
Sleep(500)
ControlSend("[class:ExploreWClass]", "", "Edit1", "{ENTER}")

[size="1"][font="Arial"].[u].[/u][/font][/size]

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