Jump to content

Recommended Posts

Posted

If you've already got the value, it's just a StringSplit() to break out the parts. Check it out in the help file:

$sVal = "130/27"
$avVal = StringSplit($sVal, "/")
$iVal = $avVal[1] + $avVal[2]
MsgBox(64, "Result", "Value is: " & $iVal)

:whistle:

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
Posted

As well, if your desired data is in a table, _IETableWriteToArray can make it easy to get the info from the page, then you can StringSplit it.

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Posted (edited)

Here the code is a cooperate site from intranet so there no access to it.. but i need some help on modify the codes....

CODE
#include <GUIConstants.au3>

#include <IE.au3>

#include <INet.au3>

#include <array.au3>

#include <String.au3>

GUICreate("lala",80,150,-1,-1,$WS_SIZEBOX+$WS_SYSMENU) ; will create a dialog box that when displayed is centered

Opt("GUICoordMode",2)

$Button_1 = GUICtrlCreateButton ("Login", 0, 0)

$Button_2 = GUICtrlCreateButton ("hunt", 0, 30)

GUISetState () ; will display an dialog box with 2 button

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Button_1

login() ; Will Run/Open Notepad

Case $msg = $Button_2

hunt() ; Will demonstrate Button 2 being pressed

EndSelect

Wend

Func login()

$sURL1 = "http://xxxxxx.xxxxx.xxxxxxx.com/xxxxx/xxxxx.jsp"

$soIE1 = _IECreate($sURL1, 1, 1)

$o_form1 = _IEFormGetObjByName($soIE1, "LOGIN")

$o_login1 = _IEFormElementGetObjByName($o_form1, "USERID")

$o_password1 = _IEFormElementGetObjByName($o_form1, "PASSWD")

_IEFormElementSetValue($o_login1, "howy")

_IEFormElementSetValue($o_password1, "numna")

$oSubmit = _IEFormElementGetObjByName($o_form1, "SignIn")

_IEAction($oSubmit, "click")

_IELoadWait($soIE1, 5000)

EndFunc

Func hunt()

$number1 = 4399990000

For $i1 = 0 To 200

$sURL1 = "http://xxxxxx.xxxxx.xxxxxxx.com/xxxxxx/ImtrWorkOrderSelect.jsp"

$soIE1 = _IECreate($sURL1, 1, 1)

$o_form1 = _IEFormGetObjByName($soIE1, "iMetroEquip")

$o_WOCATEGORY1 = _IEFormElementGetObjByName($o_form1, "WOCATEGORY")

$o_REPAIRTYPE1 = _IEFormElementGetObjByName($o_form1, "REPAIRTYPE")

$o_mobile1 = _IEFormElementGetObjByName($o_form1, "MTN")

_IEFormElementOptionselect ($o_WOCATEGORY1, "Customer", 1, "byText")

_IEFormElementOptionselect ($o_REPAIRTYPE1, "D30", 1, "byValue")

_IEFormElementSetValue($o_mobile1, $number1)

$oSubmit1 = _IEFormElementGetObjByName($o_form1, "submit_button")

_IEAction($oSubmit1, "click")

_IELoadWait($soIE1)

$oForm2 = _IEFormGetObjByName ($soIE1, "iMetroEquip")

$oText2 = _IEFormElementGetObjByName ($oForm2, "ZIP_5")

$sUrl2 = "http://xxxxxx.xxxxx.xxxxxxx.com/xxxxxx/xxxxxxxxxxxx.jsp?calledFrom=infodesk&MTN="

$sZip2 = "&ZIPCODE="

$sBill2 = "&BILLING_IND=V"

$trueURL2 = $sUrl2 & $number1 & $sZip2 & _IEFormElementGetValue ($oText2) & $sBill2

_IENavigate($soIE1, $trueURL2)

_IELoadWait($soIE1)

$html = _IEBodyReadHTML ($soIE1)

$sStart = "domesticUsage>"

$sEnd = "</SPAN>"

$Array1 = _StringBetween ($html, $sStart, $sEnd)

_ArrayToClip ($Array1)

$result = (ClipGet())

$sVal = $result

$avVal = StringSplit($sVal, "/ ")

$iVal = $avVal[1] + $avVal[2]

If $iVal >= 34 Then

$file = FileOpen("test.html", 1)

; Check if file opened for writing OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileWrite($file, "<a href=" & $trueURL2 & ">" & "CUSTOMER GOING OVER - " & $number1 & "</a>" & "<BR>" & @CRLF)

FileClose($file)

ElseIf $iVal <= 33 Then

MsgBox(4096,"", "We got No data.")

EndIf

$number1 += 1

Next

EndFunc

#1 problem

I notice it open one IE and then navigate etc. I would like to keep repeating the same method with different number yes it's repeating but it open IE again why not use same existen Iexplore that were navigating before? after it found the value needed and save go use the existen Navigate and do all over the hunt() but not reopen another IE use the sameone that been open.

2# Problem

I would like to make more split and add value and search more stringbetween on the following code to get value like internationlUsage>0/0</SPAN> and stringbetween get 0/0 and string split will despare add 0 + 0 = 0 etc.

CODE
---------------------------

Body Text

---------------------------

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 valign="top">

<TBODY>

<TR>

<TD align=right><INPUT class=btnHistClose onclick=java script:parent.closeHistory() type=button value=Close> </TD></TR></TBODY></TABLE><BR>

<CENTER>

<TABLE cellSpacing=0 cellPadding=0 width=450 border=0>

<TBODY>

<TR>

<TD class=TableTitle>&nbsp;&nbsp;SMS Usage <SPAN id=mdn style="FONT-SIZE: 11px; COLOR: blue">(439) 999-0000</SPAN></TD></TR></TBODY></TABLE>

<TABLE cellSpacing=0 cellPadding=0 width=450 border=0>

<TBODY>

<TR>

<TD class=FormLabel>&nbsp;&nbsp;Domestic Messages (Sent/Received) : </TD>

<TD class=FormValue><SPAN id=domesticUsage>244/244</SPAN></TD></TR>

<TR>

<TD class=FormLabel>&nbsp;&nbsp;International Messages (Sent/Received) : </TD>

<TD class=FormValue><SPAN id=internationlUsage>0/0</SPAN></TD></TR>

<TR>

<TD class=FormLabel>&nbsp;&nbsp;IN Network Messages (Sent/Received) : </TD>

<TD class=FormValue><SPAN id=inNetworkSMSUsage>32/30</SPAN></TD></TR>

<TR>

<TD class=FormLabel>&nbsp;&nbsp;Global Phone Messages (Sent/Received) : </TD>

<TD class=FormValue><SPAN id=gpPhoneMsgUsage>0/0</SPAN></TD></TR>

<TR>

<TD class=FormLabel>&nbsp;&nbsp;Last SMS Message : </TD>

<TD class=FormValue><SPAN id=lastSmsDate>07/18/2007 11:32 PM</SPAN></TD></TR>

<TR></TR>

<TR>

<TD class=TableTitle>&nbsp;&nbsp;MMS Usage </TD></TR>

<TR>

<TD class=FormLabel>&nbsp;&nbsp;MMS Message (Sent/Received) : </TD>

<TD class=FormValue><SPAN id=mmsMsgUsage>12/0</SPAN></TD></TR>

<TR>

<TD class=FormLabel>&nbsp;&nbsp;IN Network MMS Message (Sent/Received) : </TD>

<TD class=FormValue><SPAN id=inNetworkMMSUsage>4/4</SPAN></TD></TR>

<TR>

<TD class=FormLabel>&nbsp;&nbsp;Last MMS Message : </TD>

<TD class=FormValue><SPAN id=lastMMSDate>07/17/2007 10:37 PM</SPAN></TD></TR></TBODY></TABLE>

<TABLE cellSpacing=0 cellPadding=0 width=440 border=0>

<TBODY>

<TR>

<TD vAlign=top align=right height=10></TD></TR></TBODY></TABLE></CENTER>

---------------------------

OK

---------------------------

#3 problem

>"E:\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "E:\AutoIt3\new.au3"

E:\AutoIt3\Include\IE.au3 (267) : ==> The requested action with this object has failed.:

$o_object.navigate ($s_Url)

$o_object.navigate ($s_Url)^ ERROR

>Exit code: 1 Time: 115.533

just generated random. i think because 45 window was open work fine the script then crash must be overload

#4 Problem I dont want to get my copy and paste overwrite it by this code there any way to get the value and use it in stringbetween without clipget?

Edited by LukeJrs
Posted (edited)

Here what i got so far..... I want to add all those string total of 570 Value

CODE
$html = _IEBodyReadHTML ($soIE1)

$sStart1 = "domesticUsage>"

$sEnd1 = "</SPAN>"

$sStart2 = "internationlUsage>"

$sEnd2 = "</SPAN>"

$sStart3 = "inNetworkSMSUsage>"

$sEnd3 = "</SPAN>"

$sStart4 = "gpPhoneMsgUsage>"

$sEnd4 = "</SPAN>"

$sStart5 = "mmsMsgUsage>"

$sEnd5 = "</SPAN>"

$sStart6 = "inNetworkMMSUsage>"

$sEnd6 = "</SPAN>"

$Array1 = _StringBetween ($html, $sStart1, $sEnd1)

$Array2 = _StringBetween ($html, $sStart2, $sEnd2)

$Array3 = _StringBetween ($html, $sStart3, $sEnd3)

$Array4 = _StringBetween ($html, $sStart4, $sEnd4)

$Array5 = _StringBetween ($html, $sStart5, $sEnd5)

$Array6 = _StringBetween ($html, $sStart6, $sEnd6)

_ArrayToClip ($Array1)

$result = (ClipGet())

;MsgBox(0, "Data Found", $result)

$sVal = $result

$avVal = StringSplit($sVal, "/ ")

$iVal = $avVal[1] + $avVal[2]

;MsgBox(64, "Result", "Value is: " & $iVal)

If $iVal >= 34 Then

; MsgBox(4096,"", "We got data.")

;Check if file opened for writing OK

$file = FileOpen("test.html", 1)

; Check if file opened for writing OK

If $file = -1 Then

; MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileWrite($file, "<a href=" & $trueURL2 & ">" & "CUSTOMER GOING OVER - " & $number1 & "</a>" & "<BR>" & @CRLF)

FileClose($file)

ElseIf $iVal <= 33 Then

;MsgBox(4096,"", "We got No data.")

EndIf

Edited by LukeJrs
Posted

Why not avoid the StringSplit and get the text directly?

$oSpan1 = _IEGetObjById($oIE, "domesticUsage")

$Array1 = _IEPropertyGet($oSpan1, "innertext")

etc.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Posted (edited)

thanks sound better method but stringsplit is where the value of objid domestic usage = 244/244 will split into 2 var and remove the "/" and add them together.

do you have anything in mind how to prevent opening another browser and navigate the same one and repeat by navigating same browser without opening?

Edited by LukeJrs
Posted (edited)

This instances of of SplitString I was referring to were $Array1 = _StringBetween ($html, $sStart1, $sEnd1) - sorry I wasn't clear. This approach avoids neeing to use _IEBodyReadHTML and would be much more efficient.

Your other question is stated in a very confusing manner, so I am not certain what you are asking. If I were to take a guess however, I'd suggest that you create an initial browser at the beginning of your code (before your While loop)

$oIE = _IECreate()

and pass the the $oIE as a parameter to your functions

login($oIE)

and then use that object in your functions...

Func login($oIE1)

and then use _IENavigate($oIE1, "xxxx") in your functions instead of _IECreate.

If this is not it, then you'll need to do a better job of describing your question. One long run-on sentence with no punctuation between ideas makes it impossible to know for sure what you are asking.

Dale

Edit: typo

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Posted

I've fix the minor errors on array & stringsplit. The command it's working very good!

It seen to be two minor problem for the looping & error.

#1 Script crash

The server have javascripts running etc, at the moment my script start searching number and try get information in the body html

CODE
Func hunt()

$number1 = 4399990000

For $i1 = 0 To 200

$sURL1 = "http://xxxxxx.xxxxx.xxxxxxx.com/xxxxxx/ImtrWorkOrderSelect.jsp"

$soIE1 = _IECreate($sURL1, 1, 1)

$o_form1 = _IEFormGetObjByName($soIE1, "iMetroEquip")

$o_WOCATEGORY1 = _IEFormElementGetObjByName($o_form1, "WOCATEGORY")

$o_REPAIRTYPE1 = _IEFormElementGetObjByName($o_form1, "REPAIRTYPE")

$o_mobile1 = _IEFormElementGetObjByName($o_form1, "MTN")

_IEFormElementOptionselect ($o_WOCATEGORY1, "Customer", 1, "byText")

_IEFormElementOptionselect ($o_REPAIRTYPE1, "D30", 1, "byValue")

_IEFormElementSetValue($o_mobile1, $number1)

$oSubmit1 = _IEFormElementGetObjByName($o_form1, "submit_button")

_IEAction($oSubmit1, "click")

_IELoadWait($soIE1)

$oForm2 = _IEFormGetObjByName ($soIE1, "iMetroEquip")

$oText2 = _IEFormElementGetObjByName ($oForm2, "ZIP_5")

$sUrl2 = "http://xxxxxx.xxxxx.xxxxxxx.com/xxxxxx/xxxxxxxxxxxx.jsp?calledFrom=infodesk&MTN="

$sZip2 = "&ZIPCODE="

$sBill2 = "&BILLING_IND=V"

$trueURL2 = $sUrl2 & $number1 & $sZip2 & _IEFormElementGetValue ($oText2) & $sBill2

_IENavigate($soIE1, $trueURL2)

_IELoadWait($soIE1)

When it try to do this command

CODE
$oForm2 = _IEFormGetObjByName ($soIE1, "iMetroEquip")
and customer doesn't exist nor there a profile.

The server error appear in javascripts the java that launch when customer doesnt exist by the phone number I get this

CODE
//end mshee change

setTimeout( 'alert( "This Mobile number was not found in the billing system. " )', 20 );

}

on the server javapopup message saying "This Mobile number was not found in the billing system" then my script loop crash and script stop running.

Is there a way to disable that javapopupmsg or like a command If javapop then close javascript popupmsg and don't do $oForm2 = _IEFormGetObjByName ($soIE1, "iMetroEquip") and continue func search for another numbers.

like:

CODE
If javapop then closejavapop and research another number

Elseif java didn't popup then continue the autoit script

because I'm getting this error

CODE
>"E:\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "E:\AutoIt3\new.au3"

E:\AutoIt3\Include\IE.au3 (267) : ==> The requested action with this object has failed.:

$o_object.navigate ($s_Url)

$o_object.navigate ($s_Url)^ ERROR

>Exit code: 1 Time: 115.533

Posted

I suggest you break down your problems and focus on one item at a time. Your posts take far too much work for us to understand to hold our interest. You may find that the exercise of breaking it down will help you solve it on your own.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Posted (edited)

Sorry, that sounded confusing.

The script works good. The only problem is that the script crashed during the looping proccess because the script

CODE
couldn't requested action with this object has failed.:

$o_object.navigate ($s_Url)

The error only happen when the script have command to input the value to the forms object, and after it's done will navigate through $soIE and try collect following information there seen to be 1 number that doesn't exist and as soon it reach this command line _IEAction($oSubmit1, "click") after it's done will submit the form to the serverside, and if serverside number input not valid then serverside will execute a command line to call the alert function from the javascript which is located in the body part of html.
CODE
//end mshee change

setTimeout( 'alert( "This Mobile number was not found in the billing system. " )', 20 );

}

Cause to Crashed the script

Isn't there a way to close the pop-up msg alert, continue looping the script and keeping it from crashing?

How does the @ERROR commands work?

Edited by LukeJrs
Posted

What do you have against periods. commas and question marks? I simply cannot read what you type and be certain what you mean. Slow down and make what you type readable with some punctuation.

I'll take a quess and tell you to move your _IELoadWait before the _IENavigate -- you don't need one after _IENavigate because it calls it automatically.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Posted (edited)

RE-EDITED:

Sorry, that sounded confusing.

The script works good. The only problem is that the script crashed during the looping proccess because the script

CODE
couldn't requested action with this object has failed.:

$o_object.navigate ($s_Url)

The error only happen when the script have command to input the value to the forms object, and after it's done will navigate through $soIE and try collect following information there seen to be 1 number that doesn't exist and as soon it reach this command line _IEAction($oSubmit1, "click") after it's done will submit the form to the serverside, and if serverside number input not valid then serverside will execute a command line to call the alert function from the javascript which is located in the body part of html.
CODE
//end mshee change

setTimeout( 'alert( "This Mobile number was not found in the billing system. " )', 20 );

}

Cause to Crashed the script

Isn't there a way to close the pop-up msg alert, continue looping the script and keeping it from crashing?

How does the @ERROR commands work?

Edited by LukeJrs
Posted

CODE
//end mshee change

setTimeout( 'alert( "This Mobile number was not found in the billing system. " )', 20 );

}

Cause to Crashed the script

Isn't there a way to close the pop-up msg alert, continue looping the script and keeping it from crashing?

How does the @ERROR commands work?

Is it a standard Windows pop-up? If so, you can take care of it with standard AutoIt functions like:

ControlSend($WinTitle, "This Mobile number was not found", "", "{ENTER}")oÝ÷ Øç¢Ú^®©³*.r¥v,µ«­ç§²-zºè®+­ fiÊè"Ýý²;¬µ¦î[bö«¦å{­«)yÈçn±ëh]¶®º+r^¡ûazV¬µû§rب«~æyÒ'-q«±êë¢

:whistle:

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

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
×
×
  • Create New...