Sign in to follow this  
Followers 0
brdude

Condition problem

9 posts in this topic

I am creating a script to download specific files from the web. It knows wich file to download because it gets the link from a Exel spread sheet. Now the number of links is that has to download from always changes. And some times it dosent contain a link. Well here is the problem I tried to set it so that if the variable contains nothing it dosent even try to visit that site. I am a c++ coder so I tried these two codes.

If $link <> "" Then

and

If $link <> ''Then

but neither work. I have been searching the forum but no luck so far. I would apreciate it if any one wold help me with this.

Thanks

Share this post


Link to post
Share on other sites



Hi,

doesn't look that wrong. Might show your script and / or the error?

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

There is no error but I have been checking of things and even where there is no link it still tries to visit that page.

But here is the code.

#include <IE.au3>

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",2)


$oIE = _IECreate ("www.specpage.com")
Sleep(5000)

WinActivate("Microsoft Excel")
WinWait("Microsoft Excel")


Send("{CTRLDOWN}c{CTRLUP}")
$name = ClipGet()
Sleep(500)


Send("{RIGHT}{CTRLDOWN}c{CTRLUP}")
$link = ClipGet()
Sleep(500)

_IENavigate ($oIE, $link)
    WinActivate("Windows Internet Explorer")
    WinWait("Windows Internet Explorer")
    Sleep(2000)
    
    MouseMove(30, 150)
    Sleep(5000)


While $name <> ""
    WinActivate("Microsoft Excel")
    WinWait("Microsoft Excel")


    if $link <>  Then
    Send("{LEFT}{DOWN}{CTRLDOWN}c{CTRLUP}")
    $name = ClipGet()
    Sleep(500)

    Send("{RIGHT}{CTRLDOWN}c{CTRLUP}")
    $link = ClipGet()
    Sleep(5000)
    
    _IENavigate ($oIE, $link)
    Sleep(5000)
    
    WinActivate("Windows Internet Explorer")
    WinWait("Windows Internet Explorer")
    Sleep(2000)
    
    MouseMove(30, 150)
    Sleep(5000)
    
    EndIf
    
    
    
WEnd

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

There is no error but I have been checking of things and even where there is no link it still tries to visit that page.

But here is the code.

CODE

#include <IE.au3>

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",2)

$oIE = _IECreate ("www.specpage.com")

Sleep(5000)

WinActivate("Microsoft Excel")

WinWait("Microsoft Excel")

Send("{CTRLDOWN}c{CTRLUP}")

$name = ClipGet()

Sleep(500)

Send("{RIGHT}{CTRLDOWN}c{CTRLUP}")

$link = ClipGet()

Sleep(500)

_IENavigate ($oIE, $link)

WinActivate("Windows Internet Explorer")

WinWait("Windows Internet Explorer")

Sleep(2000)

MouseMove(30, 150)

Sleep(5000)

While $name <> ""

WinActivate("Microsoft Excel")

WinWait("Microsoft Excel")

if $link <> Then

Send("{LEFT}{DOWN}{CTRLDOWN}c{CTRLUP}")

$name = ClipGet()

Sleep(500)

Send("{RIGHT}{CTRLDOWN}c{CTRLUP}")

$link = ClipGet()

Sleep(5000)

_IENavigate ($oIE, $link)

Sleep(5000)

WinActivate("Windows Internet Explorer")

WinWait("Windows Internet Explorer")

Sleep(2000)

MouseMove(30, 150)

Sleep(5000)

EndIf

WEnd

This is wrong:

if $link <>  Then

Missing the second operator to compare with:

if $link <>  "" Then

That gets you "If $link is not equal to an empty string, then..." as you would expect.

:whistle:

Edited by PsaltyDS

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

#5 ·  Posted (edited)

$link = ClipGet()
if $link <>  Then
Even if you put the "" back into the second line, are you sure that $link is really empty when you put a null clipget into it? Maybe clipget() puts some kind of character into $link even if the clip is "empty"... :whistle:

Try throwing this line into your script just after you set $link to clipget():

MsgBox(0,"$link",$link)
Edited by jefhal

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

There is no error but I have been checking of things and even where there is no link it still tries to visit that page.

But here is the code.

#include <IE.au3>

$name = ClipGet()
Sleep(500)
Send("{RIGHT}{CTRLDOWN}c{CTRLUP}")
$link = ClipGet()
Sleep(500)
well, did you ever check what's in $name and $link after the call to ClipGet(). msgbox() is your friend.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

well, did you ever check what's in $name and $link after the call to ClipGet(). msgbox() is your friend.

Cheers

Kurt

Sorry just got a chance to check it rigth now.

I added the code in and the message box comes out empty. I also checked the exel file to see if there was a space and it is empty. I also fixed the code I was messing with it and forgot to put it back sorry about that. For some reason the string comparation is not working. If it maters at all I am using the latest beta of autoit. Any thoughts on this guys?

Share this post


Link to post
Share on other sites

Sorry just got a chance to check it rigth now.

I added the code in and the message box comes out empty. I also checked the exel file to see if there was a space and it is empty. I also fixed the code I was messing with it and forgot to put it back sorry about that. For some reason the string comparation is not working. If it maters at all I am using the latest beta of autoit. Any thoughts on this guys?

One thing I've done is to check the length of the returned string.

If the length > 0 then you have something to pass on.

If StringLen($Link) > 0 then ...

Does this help at all?

Share this post


Link to post
Share on other sites

One last thing. I hope this isn't being presumptious,

but I've had a lot of fun (read ANGER) with using

sendkey operations between programs. They can be

finicky, you know?

I wanted to send you an example of using Excel's COM

object to make the process of retrieving the links

a little less susceptible to 'hiccups' like dialog forms,

interrupting windows, etc.

This is just an idea I had while perusing your code.

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