Jump to content

I want to open a notepad and then move to its last line


Ajays
 Share

Recommended Posts

Hi,

I am problem at the step 9 and 10. Here are the steps i am trying to do with autoit script:

1. open a notepad.

2. Write this line on it - STEP 1 : This is first Line

3. Then get its title name with the gettitle function.

4. Close the notepad.

5. Open the notepad with openfile function.

6. And write the title of the notepad in the notepad.

7. Close the notepad.

8. Open the same notepad with Run(notepad.exe) function.

9. And then i want to enter this line - STEP2 - This is second Line at the last line of the notepad.

10.BUt i am not able to move the cursor at the last line of the notepad when i open the notepad for the second time

Please let me know if you have any solution.

Here is the script:

$AT_log_file = "c:\AGT\Already System - 2009U1.txt"

Run("notepad.exe")

WinWaitActive("Untitled - Notepad","",5)

WinActivate("Untitled - Notepad")

WinMenuSelectItem("Untitled - Notepad", "", "&File", "&Save")

Send($AT_log_file)

Send("{Enter}")

sleep(4000)

If WinExists("Save As") Then

Send("{TAB 1}")

Send("{Enter}")

EndIf

Send("STEP 1 : This is first Line{Enter}")

Send("^s")

sleep(4000)

$title = WinGetTitle("Already - ", "")

sleep(4000)

WinActive("Already - Notepad")

WinClose("Already System - 2009U1.txt - Notepad")

$file = FileOpen("c:\AGT\Already System - 2009U1.txt", 1)

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileWrite($file, $title)

FileClose($file)

sleep(2000)

Run("notepad.exe")

Sleep(2000)

WinMenuSelectItem("Untitled - Notepad", "", "&File", "&Open")

Send($AT_log_file)

sleep(1000)

send("{Enter}")

sleep(4000)

send("STEP2 - This is second Line{Enter}")

send("^s")

Regards,

Ajay

lastline.au3

Link to comment
Share on other sites

This works..........

WinWait("Links to Favorite Topics.txt - Notepad","")

If Not WinActive("Links to Favorite Topics.txt - Notepad","") Then WinActivate("Links to Favorite Topics.txt - Notepad","")

WinWaitActive("Links to Favorite Topics.txt - Notepad","")

Send("{CTRLDOWN}{END}{CTRLUP}{ENTER}")

REB

Insert the name of your file in place of "Links to Favorite Topics.txt"

REB

Edited by reb

MEASURE TWICE - CUT ONCE

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