Jump to content
Sign in to follow this  
anyways

Copying and pasting line from notepad

Recommended Posts

anyways

This is the script for copying and pasting a random line from a notepad

$notepad10 = WinGetText("qpwords.txt - Notepad")

$lines10 = StringSplit($notepad10,@crlf,1)

$randomline10 = Random(1, $lines10[0], 1)

Clipput($lines10[$randomline10])

Send(Clipget())

I dont wish anymore to take a random line, i want to take the line in order each time the script restart. Lets say I want to copy/paste line 1 the first time, then when the script restart, copy/paste the second line and so on. What would be the function to use?

Thank you

Edited by anyways

Share this post


Link to post
Share on other sites
Paulie

i did a little modification. This will copy the next line form notepad every time you press Home. it's easier than trying to save the current line between script restarts. Also, i used fileread instead of WinGetText. You don't need to have notepad open!

HotKeySet("{HOME}","NextLine")

Global $Line=1

While 1
Sleep(100)
WEnd

Func NextLine()
$Path = "qpwords.txt" ;if not in scriptdir, use full file path
$File = FileOpen($Path,0)
$Current = FileReadLine($File,$Line)
ClipPut($Current)
Send(ClipGet())
FileClose($File)
$Line+=1
EndFunc

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  

×