Jump to content

How do i "read the screen"?


Recommended Posts

I need to open a browser window (opera/ff), and then search for some text, after it, there is some other text that i want to copy to the clipboard. Is it possible? Hints? Thanks.

Getting the text from a window is usually easy: WinGetText().

You might also script the hot key actions to Opera to save the source, etc.

I haven't tried that on an Opera window. See what happens...

:)

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

thanks, but that would give me all the text on the web page, i want an specific line, in fact, an URL, something like http://xxxxx, how can i process it?

First figure out what will give you all the text, as you said. Once that works, you can parse the string easily with things like StringInString(), StringRegExp(), and _StringBetween().

:)

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

i'm making some progress ... unfortunatelly, the $text = WinGetText("Firefox", "...") is not working, in fact, i can't understand what the second parameter is: [optional] The text of the window to read., what is it talking about?

Anyway, i have this so far (ugly):

CODE

$runs = InputBox("Numero de vueltas", "Numero de vueltas?")

For $i = 1 to $runs Step 1

AutoItSetOption ("WinTitleMatchMode", 2 )

WinActivate("UltraEdit-32","")

Send ("^{HOME}")

Send ("{DOWN}{DOWN}")

Send ("+{END}")

Send ("^x")

Send ("{DELETE}")

WinActivate("Firefox","") ; activo el Firefox

Send ("^l") ; voy al address bar

Send ("^v") ; pego el URL

Send ("{ENTER}") ; voy al URL

Send ("^l") ; voy al address bar

WinWait ("Lix.in - Linkprotection - Mozilla Firefox", "")

Send ("{TAB}{TAB}{TAB}{TAB}") ; salteo 4 veces hasta el boton

Send ("{SPACE}") ; pulso el boton

WinWait ("RapidShare: 1-Click Webhosting - Mozilla Firefox", "")

Send ("^a") ; selecciono todo el texto

Send ("^c") ; lo copio al clipboard

$url = ClipGet() ; lo paso del clipboard a la variable $url

$pos = StringInStr($url, "http://") ; calgulo la posicion de http://

$url = StringTrimLeft($url, $pos-1) ; le resto todo lo anterior al texto

$url = StringLeft($url, StringInStr($url, " ")) ; le saco todo lo del siguiente espacio

ClipPut($url) ; lo pego en el clipboard

Sleep(500) ; pauseo .5 segs

Next

now, is it possible for me to iterate to all the lines on a clipboard capture? for example, lets say that i have this on the clipboard:

line1, etc, etc

line2, etc, etc

line3, etc, etc

how can i do something like

forall line in clipboard

i = i + 1

print 1, line

end

this would print

1 line1, etc, etc

2 line2, etc, etc

3 line3, etc, etc

My question is because i want to get a list from the clipboard, and process it, obviously. THANKS.

Edited by kwanbis
Link to comment
Share on other sites

The optional text parameter is to help identify the particular window you are interested in. If more than one window matches the title parameter, it will look for the one that contains that text.

For handling a string one line at a time, you can save it to a file and read it one line at time with FileReadLine(), or just StringSplit() to an array and loop through it.

:)

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

on the text on the clipboard, i yhought maybe lookking for the ENTER char or something as a delimiter at least.

Read the help file.

That's what StringSplit() does. It would take the string, split it on any char like @LF, and give it to you in an array. Check it out in the help file.

Try the example in the help file.

The help file is your friend.

See any pattern here?

:)

P.S. Read the help file...

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

right, thanks, i have, but to be honest, sometimes the help file is of no help ... like, "[optional] The text of the window to read" ... mh? what does that means?

"The optional text parameter is to help identify the particular window you are interested in. If more than one window matches the title parameter, it will look for the one that contains that text."

is much more understandable.

Link to comment
Share on other sites

...is much more understandable.

Honestly, that's why the humans keep us penguins around... to 'splain things! :)

Put anything you like in the clipboard and then try this:

#include <array.au3>

$Read = ClipGet()
If Not @error Then
    $avLines = StringSplit($Read, @LF)
    For $n = 1 To $avLines[0]
        $avLines[$n] = StringStripWS($avLines[$n], 3)
    Next
    _ArrayDisplay($avLines, "Results")
Else
    MsgBox(16, "Error", "StringSplit() returned @error = " & @error)
EndIf

:)

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