Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Simple VBS script help

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,34761
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Simple VBS script help
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Simple VBS script help - 5/20/2006 3:25:30 PM   
  NeutralisTheEye

 

Posts: 2
Score: 0
Joined: 5/20/2006
Status: offline
So, some of this code may look odd, but that is because I am using this script in conjunction with a program called iMacros. Here is the jist of what the following code is supposed to do: The script logs me into a certain website (hence the "Login" script). Then, it searches the page for a link entitled "mine" (hence the "Search" script). If the link "mine" is not found, the following code is supposed to loop the "Search" script again until the link "mine" is found (the "mine" link is dynamic and only appears every so often, completely randomly). However, if the "mine" link is found, the following code is supposed to run the "Mine" script which will then in turn click the link.

The following code is working about 75%. My problem is that it continuously loops the "Search" script whether or not the "mine" link is in fact on the page, so it never is clicked. I am new to VBScripting, so I am quite sure that I am doing something wrong when I typed "Do Until instr...."

Any help on this would be extremely appreciated.

set iim1 = CreateObject ("InternetMacros.iim")
iret = iim1.iimInit()
iplay = iim1.iimPlay("Login")
iplay = iim1.iimPlay("Search")
extracted_text = iim1.iimGetLastExtract()

If iplay = 1 Then
if instr (extracted_text, "#EANF#") > 0 then
  Do Until instr (extracted_text, "#EANF#") < 0
    iplay = iim1.iimPlay("Search")
  Loop
else
  iplay = iim1.iimPlay("Mine")
End If
End if

If iplay < 0 Then
MsgBox ("Oops!")
End If
 
 
Post #: 1
 
 RE: Simple VBS script help - 5/20/2006 9:11:44 PM   
  ehvbs

 

Posts: 2220
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi NeutralisTheEye,

I was about to answer your question, because I liked the way you presented
your problem: giving a fair amount of context and a short piece of code showing
where you have difficulties. It would have been better if this code could
be executed 'as is', but on the other hand side, too much details/code of
your InternetMacros classes would distract from your problem.

But yesterday I accidentially entered
  "www.microsoft.com/bills/private/parts/download"
in my browser and found this "Digital Rights Enforcement Suite". The module
to check for bathtub singing isn't ready yet (will be part of service pack 12
(2010)) but I can scan the immediate nighbourhood of any Windows computer
(if it was online at least once) thru the monitor power LED.

You'll understand that this is much more fun than VBScript programming!

Just now I'm looking at this NeutralisTheEye, who is disappointed, because
nobody answered his question. (I can see his thoughts written on his forehead
by means of this marvellous "quantum blueteeth" module.) Now he thinks:

"I will solve my problem by breaking it into smaller parts and writing little
pieces of test code to tackle these subproblems. Obviously there is something
fishy with my use of the Instr function and the logical/sequential arrangement
of my 'get the new version of the site' and 'search for #EANF#' actions."

Asking the "ray bending wizard" to look at his monitor, I now can see
NeutralisTheEye created a new file "solutions.vbs". (Looks like NeutralisTheEye
is no better at inventing names than me.) What's the code?


      

Why does NeutralisTheEye call up the VBScript Docs? Ah - thats the Instr()
page. The code changes:


      

and the output:


      

What is NeutralisTheEye doing now?


      

Ah, concentrating on the current problem but marking what should be looked
into. I bet, NeutralisTheEye will code some IF/ELSE/END IF statements next.


      

Why does NeutralisTheEye glare at the output:


      

Ah, I see: a little bit of editing:


      

Reordering the function calls:


      

Now I surely will have to wait - but no - here it comes:


      

Some ray bending and I can read on NeutralisTheEye's forehead: "First
get the invariant part of the loop right, then add fancy if/then/else."
And "Let's keep this code and do the difficult part in a new function."


      

But this run breaks:

 ... Laufzeitfehler in Microsoft VBScript: Ungültige Zuweisung: 'loadSearchLoad'

Nice surprise: The "Digital Rights Enforcement Suite" is fully localized! Even
translating Legalese into German! NeutralisTheEye forgot to change the assignment
to the function name (happens to me all the time). New version:


      

and output:


      

Hey, there is a popup on my screen:

  "You have no Digital Rights to use this software meant for
   serious money making just for fun!
   'Digital Rights Enforcement Suite' will be uninstalled now."
   
Looks like I'll have to write my own code from now on again.

ehvbs
 

< Message edited by ehvbs -- 5/20/2006 9:14:59 PM >

(in reply to NeutralisTheEye)
 
 
Post #: 2
 
 RE: Simple VBS script help - 5/20/2006 11:46:40 PM   
  NeutralisTheEye

 

Posts: 2
Score: 0
Joined: 5/20/2006
Status: offline
o.O

...

what?

(in reply to NeutralisTheEye)
 
 
Post #: 3
 
 RE: Simple VBS script help - 5/21/2006 8:09:28 AM   
  DiGiTAL.SkReAM


Posts: 1193
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
quote:

ORIGINAL: NeutralisTheEye

o.O

...

what?


Oh, that's just ehvbs.  Sometimes he gets into the paint thinner, and everybody just has to ignore him.  Eventually, he'll come down and sober up in a dumpster somewhere wearing nothing but a lamp shade and smelling like a 2 week old bowl of tunafish salad.  Until then, we all just have to kind of go along with his posts, as he tends to meander a bit.

Cheers!

_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to NeutralisTheEye)
 
 
Post #: 4
 
 RE: Simple VBS script help - 5/21/2006 6:59:19 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
Set = "ehvbs"

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 5
 
 RE: Simple VBS script help - 5/22/2006 10:07:22 PM   
  ehvbs

 

Posts: 2220
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi all,

it is embarrassing to have to explain a joke and even more embarrassing
to have to say that some piece of text was meant as joke, but having
failed miserably at an attempt to be funny, I must do just that.

Hi NeutralisTheEye,

I owe you an apology because I answered to your question in an inappropriate
way that perhaps even distracted other members of this forum from giving it
the attention it deserves. I still think that the code in my posting could
give you some hints how to search different versions of a website for
specified content. If you are still willing to consider a contribution
of me:

' load the string to search in
extracted_text = iim1.iimGetLastExtract()
...
' will be true if Instr() returns a valid position of "#EANF#" in extracted_text
if instr (extracted_text, "#EANF#") > 0 then
' will be reached only if instr (extracted_text, "#EANF#") > 0
' as extracted_text isn't changed, the loop won't be entered
  Do Until instr (extracted_text, "#EANF#") < 0
'   will loop forever, if reached, because extracted_text isn't changed
    iplay = iim1.iimPlay("Search")
  Loop
else
' will be reached only if *Not* instr (extracted_text, "#EANF#") > 0
  iplay = iim1.iimPlay("Mine")
End If
...

As to digital screams and comic strips: I have analog ears and prefer "Calvin & Hobbes".

ehvbs

(in reply to ginolard)
 
 
Post #: 6
 
 RE: Simple VBS script help - 5/23/2006 12:39:28 AM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
Calvin & Hobbes is the greatest comic strip ever

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to ehvbs)
 
 
Post #: 7
 
 RE: Simple VBS script help - 5/23/2006 1:59:26 AM   
  mcds99


Posts: 441
Score: 4
Joined: 2/28/2006
Status: offline
I couldn't remember why I was grinning while reading ehvbs's reply...

When I got down to ehvbs's appology & " " & code & " " &  "I have analog ears and prefer "Calvin & Hobbes"."""
It dawned on me...

I couldn't keep up with the joke but something in my head knew it was a joke.





_____________________________

Sam

Keep it Simple Make it Fun KiSMiF

(in reply to ginolard)
 
 
Post #: 8
 
 RE: Simple VBS script help - 6/13/2006 2:03:50 AM   
  BiiGreeN


Posts: 13
Score: 0
Joined: 6/12/2006
From: Florida
Status: offline
I was checking the syntax to use the file scripting object and stumbled upon this thread...

I have a complete collection of calvin and hobbes books. I knew I liked this forum.

Then the... "I can see that he did..." and quantum blueteeth!

Laughing is important when you stare at the screen all day!

I'm still construting the access manipulation part of my code. Then I have to add it to the geoprocessing stuff and then I can try to run it... I have a funny feeling I'll be back with an error or two!

Have a GREAT DAY

(in reply to ginolard)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Simple VBS script help Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts