Sign in to follow this  
Followers 0
darknezz19

loop with arays help

8 posts in this topic

This snippit of code was helped written by LinuZ, thanks amigo. It works great, except when none of the keywords turn up. When none are found in a give body of text on a webpage, it's not running the "Else" statement.

CODE
Send ( "^a^c" )

$text = ClipGet()

$oIE = _IEAttach ("480", "text")

Dim $terms[2]

$terms[0] = "jimmyjojack.com"

$terms[1] = "boofu";;writing the values to an array, change the arrays values ([2]) if you need more

$sText = _IEBodyReadText($oIE)

For $loop = 1 To $terms;;the loop start

If StringInStr($sText, $terms[$loop], 0) Then

;;; I found it

Send ( "{TAB}^C" )

Send ( "http://www.foobarfoo.com/ {ENTER}" )

WinWaitActive ( "", "Done" )

Sleep ( 800 )

MouseClick ( "Left", 700, 300, 1 )

Send ( "^v" )

;MouseClick ( "Right", 670, 395, 1 )

Else

;;; didn't find it

Send ( "{ALT}{LEFT}" )

Send ( "{TAB}{ENTER}" )

EndIf

Next;;Keeps on repeating till end of keywords

I tried tinkering around with it but loops are a new concept to me that I haven't yet fully grasped. Any help would be greatly appreciated:)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I think you should take a look at _IENavigate()

If i got you right this should be it:

#include <IE.au3>

Send ( "^a^c" )
$text = ClipGet()
$oIE = _IEAttach ("480", "text")



Dim $terms[2]
$terms[0] = "jimmyjojack.com"
$terms[1] = "boofu";;writing the values to an array, change the arrays values ([2]) if you need more

$sText = _IEBodyReadText($oIE)

For $loop = 1 To Ubound($terms)-1 ;the loop start
    If StringInStr($sText, $terms[$loop], 0) Then
        ;;; I found it
        _IENavigate($oIE,"http://www.foobarfoo.com/")
        _IELoadWait($oIE,800,2000) ;Waiting 800 ms to check if page is loaded and ready, if not timeout at 2000ms.
        MouseClick ( "Left", 700, 300, 1 ) ;Dont know what you are trying to achieve here, but if you are trying to clikc a link use _IELinkClickByText
        Send ( "^v" )
        ;MouseClick ( "Right", 670, 395, 1 )
    Else
        ;;; didn't find it
        _IENavigate($oIE,"http://www.foobarfoo.com/")
    EndIf
Next;;Keeps on repeating till end of keywords
Edited by jokke

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

Share this post


Link to post
Share on other sites

I really want to know what is wrong with this script too. I can't figure it out :/

Share this post


Link to post
Share on other sites

It's very obvious...

If StringInStr($sText, $terms[$loop], 0) Then

StringInStr returns the position of the string not if it exists or not, thus if it exists, it ought to be more than position 0.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

It's very obvious...

If StringInStr($sText, $terms[$loop], 0) Then

StringInStr returns the position of the string not if it exists or not, thus if it exists, it ought to be more than position 0.

That's not the problem(autoit handles that automatically anyway, no need to check if it's > 0, because if it's not above 0, it's taken as False, which wouldn't run the conditional code)

Jokke's code should work, but there's one small error in it:

For $loop = 1 To Ubound($terms)-1;the loop start

should be

For $loop = 0 To Ubound($terms)-1;the loop start

As arrays start at 0, not 1. :)

Edit: Typo. ;)

Edited by FreeFry

Share this post


Link to post
Share on other sites

@FreeFry,

Thanks for the clarification, tested myself and it's true that there is no need > 0 .

Share this post


Link to post
Share on other sites

hi everybody i'm new and i want to make a short script but i don't know anything about this program. let me explain what i want to do:

1)muose left click

2)pause (if i don't remember wrong sleep ()

3)press ENTER

4)infinite loop

Share this post


Link to post
Share on other sites

hi everybody i'm new and i want to make a short script but i don't know anything about this program. let me explain what i want to do:

1)muose left click

2)pause (if i don't remember wrong sleep ()

3)press ENTER

4)infinite loop

0. Don't hijack other people's topics. You have a new question, start a new topic.

1. Read the help file for MouseClick().

2. Read the help file for Sleep() if you just want a delay, or perhaps MsgBox() if you want to prompt the user to continue.

3. Read the help file for Send() and ControlSend().

4. Read the help file for While/WEnd or Do/Until.

5. Read the help file.

6. Don't reply to this post in this topic. Start a new one if you have more questions.

:)


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

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