Sign in to follow this  
Followers 0
wreckage

First inconsistancy for learning newbie - help, please.

12 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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.

Edited by omikron48

Share this post


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

Share this post


Link to post
Share on other sites

If it's something you can do in Run, then you can try using the Run or ShellExecute functions.

Share this post


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

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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


Link to post
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}")

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

Share this post


Link to post
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]

Share this post


Link to post
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]

Share this post


Link to post
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
Sign in to follow this  
Followers 0