Jump to content
Sign in to follow this  
bills

Possible to auto-copy text after a keyword?

Recommended Posts

bills

Id like my script to automatically copy (CTRL-C) the rest of the text on the row after a keyword on a site, does anyone know how to make that happen?

//Bill

Share this post


Link to post
Share on other sites
SpookMeister

Please define what you are grabbing the text from a little better, as that will likely give better answers to your specific useage... in the mean time I'll throw a sample together on how to do it for a simple string.

[edit] crude example

$source = "This is a line of text to use as an example"
$search = "line"
$searchlen = StringLen($search)
$position = StringInStr($source, $search)
$leftover = StringRight($source, StringLen($source) - $position - $searchlen)
ClipPut($leftover)
MsgBox(4096, "", "The clipboard now contains:" & @CRLF & $leftover)
Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
bills

The page im trying to get the text from is this: http://www.snuskigabrudar.com/trade.php

Id like to be able to get the web adress after "Send Traffic To: " and the emailadress after "Admin EMail: ".

Thanks for helping out!

//Bill

Share this post


Link to post
Share on other sites
MHz

Look into the source to search for the information that you want.

The info is there to use

#include <INet.au3>
ConsoleWrite(_INetGetSource('http://www.snuskigabrudar.com/trade.php'))

:)

Share this post


Link to post
Share on other sites
Xenobiologist

Look into the source to search for the information that you want.

The info is there to use

#include <INet.au3>
ConsoleWrite(_INetGetSource('http://www.snuskigabrudar.com/trade.php'))

:)

Hi,

use RegExp for grabbing the words.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
bills

Hi,

use RegExp for grabbing the words.

So long,

Mega

Can you give me an example? This is a bit more advanced than im used to :)

Share this post


Link to post
Share on other sites
bills

I cant get any of this to work :) can anyone help me out?

Share this post


Link to post
Share on other sites
PsaltyDS

I cant get any of this to work :) can anyone help me out?

You haven't shown any attempt at it yet. Post the code that doesn't work and you'll get lots of help.

:)


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

Share this post


Link to post
Share on other sites
bills

You haven't shown any attempt at it yet. Post the code that doesn't work and you'll get lots of help.

:)

Ok i have tried this one:

$oIE = _IECreate("http://www.snuskigabrudar.com/trade.php")
_IELoadWait($oIE)
$source = ConsoleWrite(_INetGetSource($oIE))
$search = "Send Traffic To: "
$searchlen = StringLen($search)
$position = StringInStr($source, $search)
$leftover = StringRight($source, StringLen($source) - $position - $searchlen)
ClipPut($leftover)
MsgBox(4096, "", "The clipboard now contains:" & @CRLF & $leftover)

But its the same here, cant get anyhing out of the sourcepage. :)

Edited by bills

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

you need to put the url into the func not the ieObject!

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
bills

Got it :) Thanks. How do I make it do this for the active window?

How do I make it stop at the first "<br>"?

This is what i got now:

$source = _INetGetSource("http://www.snuskigabrudar.com/trade.php")
$search = "Send Traffic To:"
$hitta = StringRegExp($source, $search)
$searchlen = StringLen($search)
$position = StringInStr($source, $search)
$leftover = StringRight($source, StringLen($source) - $position - $searchlen)
ClipPut($leftover)
MsgBox(4096, "", "The clipboard now contains:" & @CRLF & $leftover)

Thanks for all the help :)

Share this post


Link to post
Share on other sites
bills

Got it :) Thanks. How do I make it do this for the active window?

How do I make it stop at the first "<br>"?

This is what i got now:

$source = _INetGetSource("http://www.snuskigabrudar.com/trade.php")
$search = "Send Traffic To:"
$hitta = StringRegExp($source, $search)
$searchlen = StringLen($search)
$position = StringInStr($source, $search)
$leftover = StringRight($source, StringLen($source) - $position - $searchlen)
ClipPut($leftover)
MsgBox(4096, "", "The clipboard now contains:" & @CRLF & $leftover)
oÝ÷ Ù8ZK¢¶¥Ø^éiþ«¨µâ©àyØ­¶aÆ®¶­s`¢b33c¶ôRÒôT7&VFRgV÷C¶GG¢ò÷wwrç6çW6¶v''VF"æ6öÒ÷G&FRçgV÷C²¥ôTÆöEvBb33c¶ôR ¢b33c·6÷W&6RÒôTFö5&VDDÔÂb33c¶ôR¢b33c·6V&6ÒgV÷Cµ6VæBG&ff2Fó¢gV÷C°¢b33c·6V&6ÆVâÒ7G&ætÆVâb33c·6V&6¢b33c·÷6FöâÒ7G&ætå7G"b33c·6÷W&6RÂb33c·6V&6¢b33c¶ÆVgF÷fW"Ò7G&æu&vBb33c·6÷W&6RÂ7G&ætÆVâb33c·6÷W&6RÒb33c·÷6FöâÒb33c·6V&6ÆVâ¤6ÆWBb33c¶ÆVgF÷fW"¤×6t&÷CbÂgV÷C²gV÷C²ÂgV÷CµFR6Æ&ö&Bæ÷r6öçFç3¢gV÷C²fײ5$Äbfײb33c¶ÆVgF÷fW"

This works to get the source from the active page instead of an url, but how do i make it read from the searchword "Send Traffic To:" to the first "<br>" after the searchword?

Share this post


Link to post
Share on other sites
bills

I changed it to this:

$oIE = _IECreate("http://www.snuskigabrudar.com/trade.php")
_IELoadWait($oIE)

$source = _IEDocReadHTML ($oIE)
$search = "Send Traffic To:"
$searchlen = StringLen($search)
$position = StringInStr($source, $search)
$leftover = StringRight($source, StringLen($source) - $position - $searchlen)
ClipPut($leftover)
MsgBox(4096, "", "The clipboard now contains:" & @CRLF & $leftover)
oÝ÷ Ù8b³
+Ëhëmë(º·~º&¶rدz z)ìµæ¡ö§º¹[ºØhÁÚ"©ÚÞi×ë¢kazÇ­Èp¢·jºRzwS­§ßÄèªê-¶ayø«²Ú®¢Ùmn¸-ªê-iû^®Ø^±æ«r(­ßêº^(.­çb¶­jëh×6
$oIE = _IECreate("http://www.snuskigabrudar.com/trade.php")
_IELoadWait($oIE)
$source = _IEDocReadHTML ($oIE)
$beginning1 = "Send Traffic To: "
$searchlen1 = StringLen($beginning1)
$position1 = StringInStr($source, $beginning1)
$result1 = StringRight($source, StringLen($source) - $position1 - $searchlen1 + 1)

$end1 = "<br>"
$position2 = StringInStr($result1, $end1)
$result2 = StringLeft($result1, $position2 - 1)
ClipPut($result2)
MsgBox(4096, "", "The clipboard now contains:" & @CRLF & $result2)

Thanks for all of your help guys! //Bill

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

could be done much easier. Have a look at _StringBetween.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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  

×