Sign in to follow this  
Followers 0
Aconx

Ctrl + C

5 posts in this topic

Hi

I was planing on making a script that would:

1. download a file and load it in to the program

2. when a specific key was pushed, copy whatever is highlighted in a program (Ctrl + C)

3. retrive whatever was copied and search through tha downloaded file after the pice of text

4. then display whatever corosponding information the copied text had in the file(.txt) in a popup

I worked alittle with AutoIt a year ago but i didn't get to much into it. It dose not look to hard to make all of this when I was looking through the doc's at least the downloading and pushing the button.

What i whant to know is, if it is possible to load whatever string is stored as a copie from Ctrl +C? How would you retrive it.

The secound thing I was woundering about is how you load a .txt file an fro exampel search trough it?

Share this post


Link to post
Share on other sites



Read a txt file: FileRead/FileReadLine/_FileReadToArray are some options. (Also look at FileOpen/FileClose)

Using Ctrl+C you could use ControlSend()/Send() - ^c for copy, to copy to the clip board look at ClipPut(). Take a look at ClipGet() to retrieve text from the clip board.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I was posting to your other post ( before it was moved here )

Welcome to the forums... this is the support area

my reply was

What i whant to know is, if it is possible to load whatever string is stored as a copie from Ctrl +C? How would you retrive it.

The secound thing I was woundering about is how you load a .txt file an fro exampel search trough it?

First Ctrl +C is "copy", the beta Autoit has a command known as ClipGet() and ClipPut()

example

$bak = ClipGet()

MsgBox(0, "Clipboard contains:", $bak)

to search through a file you can use FileOpen() and search through it

example

$sloc = @TempDir & "\stest.txt"

$ssearch = "Your word"

$sfile = FileOpen($sloc, 0)

While 2

$sline = FileReadLine($sfile)

If @error Then

MsgBox(262208, "Fail", "The string was NOT found ")

FileClose($sfile)

Exit

EndIf

If StringInStr($sline, $ssearch) Then

$iMsgBoxAnswer = MsgBox(262212,"Sucess","The string was found " & @CRLF & @CRLF & "Continue Search?")

If $iMsgBoxAnswer = 7 Then

FileClose($sfile)

Exit

EndIf

EndIf

WEnd

hope that helps

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Thanks for all, I will try it later today.

However I am more experinced with Java and so on.

If i would like to modefy the script so that it searches through the text and then Makes a popup with all the text after the found string to a certain charactar ex:'¤' or some thing else.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

$MyString = 'AutoIt is wonderful you will rEaLly**Love it!!'
$StringToFind = 'Really'
MsgBox(0, '', StringTrimLeft($MyString, StringInStr($MyString, $StringToFind) + StringLen($StringToFind) - 1))

Edit: Another Way could be:

$MyString = 'AutoIt is wonderful you will rEaLly**Love it!!'
$StringToFind = 'Really'
MsgBox(0, '', StringRight($MyString, StringLen($MyString) - StringLen($StringToFind) + 1 - StringInStr($MyString, $StringToFind)))

Edit2: Or you can use a ready made UDF (w0uter made this one) it can get the string between 2 choices, or just the remaining string.

$MyString = 'AutoIt is wonderful you will rEaLly**Love 0 it!!'
$StringToFind = 'Really'
$Remaining = _StringBetween($MyString, $StringToFind)
MsgBox(0, 'Remaining Words', $Remaining)

Func _StringBetween($s_String, $s_Start, $s_End = 0); $s_End is an optional parameter.
    $s_Start = StringInStr($s_String, $s_Start)+StringLen($s_Start)
    return StringMid($s_String, $s_Start, StringInStr($s_String, $s_End)-$s_Start)
EndFunc
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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