Jump to content

Notepad problem?


cjwessel
 Share

Recommended Posts

I have created a script that opens a Notepad element and does a replace of a string. This looks like it works fine.

Where in run into problems is if the search string does not exist then Note pad closed but the script does not.

What can I do to check the error conditions with Notepad?

WinWaitActive("display.html - Notepad")

Send("!E")

Send("R")

Send("!ndisplay")

Send("!pwhy")

Send("!A")

Send("{ESC}{ESC}")

; Now quit by pressing Alt-f and then x (File menu -> Exit)

Send("!f")

Send("x")

; Now a screen will pop up and ask to save the changes, the window is called

; "Notepad" and has some text "Yes" and "No"

WinWaitActive("Notepad")

Send("y")

Link to comment
Share on other sites

I have created a script that opens a Notepad element and does a replace of a string. This looks like it works fine.

Where in run into problems is if the search string does not exist then Note pad closed but the script does not.

What can I do to check the error conditions with Notepad?

WinWaitActive("display.html - Notepad")

Send("!E")

Send("R")

Send("!ndisplay")

Send("!pwhy")

Send("!A")

Send("{ESC}{ESC}")

; Now quit by pressing Alt-f and then x (File menu -> Exit)

Send("!f")

Send("x")

; Now a screen will pop up and ask to save the changes, the window is called

; "Notepad" and has some text "Yes" and "No"

WinWaitActive("Notepad")

Send("y")

Why not just read the text from the Edit1 control, modify it with AutoIt and then write it back?
WinWaitActive("display.html - Notepad")
$hNotepad = WinGetHandle("display.html - Notepad")
$sText = ControlGetText($hNotepad, "", "[CLASS:Edit; INSTANCE:1]")
StringReplace($sText, "display", "why")
ControlSetText($hNotepad, "", "[CLASS:Edit; INSTANCE:1]")

:D

For that matter, why bother with Notepad at all? You could FileRead()/StringReplace()/FileWrite() event easier.

:D

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...