#182716 - 2007-11-15 10:20 PM
Read Data from Internet explorer
|
SeaDub
Fresh Scripter
Registered: 2007-11-15
Posts: 8
|
I'm using KiXtart to input basic data into an Internet explorer window. Basically, it copies the data from a big excel list, and using sendkeys, it pastes the code into the Internet explorer window (using tab to get to the next field, etc). Unfortunately (yes, theres always an "Unfortunately") the Internet Explorer window that I'm inputing data into has an SAP backend, so it takes time to move on to the next record. Sendkeys does not "wait" for internet explorer to get to the next record before it tries to "Type" the data into the field, so in the end, I lose data. From what I can think of, I have 2 solutions. 1) Is there a way to make Sendkeys WAIT until Internet explorer is ready before it proceeds? 2) Is there a way for me to put Sendkeys in a for loop, and the only time it exits is when internet explorer is ready? Thinking maybe I could do a copy and paste, and if the Copy is EMPTY, then internet explorer isn't ready, but if the Copy shows DATA, that means that Internet explorer is ready.
I either totally confused you, or you got what I'm trying to do. Any ideas? 
Thanks so much for your help.
|
|
Top
|
|
|
|
#182720 - 2007-11-16 04:04 AM
Re: Read Data from Internet explorer
[Re: NTDOC]
|
SeaDub
Fresh Scripter
Registered: 2007-11-15
Posts: 8
|
Well the sleeps WOULD work, its just that.. sometimes SAP is fast, and sometimes its slow... so if I did like, 10 second sleeps... to ensure it worked... it would run awful slow.. thats why I was trying to make it "efficent"...
Any idea what that software was called?
|
|
Top
|
|
|
|
#182723 - 2007-11-16 05:05 AM
Re: Read Data from Internet explorer
[Re: SeaDub]
|
It_took_my_meds
Hey THIS is FUN
   
Registered: 2003-05-07
Posts: 273
Loc: Sydney, Australia
|
Hi,
I don't know how applicable this is to your situation, but assuming you want deal with SAP, and if you're up for it, you may wish to talk directly to it. SAP supports SOAP which is a fairly simple protocol to communicate through. To get you started, below is my function for communication via a SOAP web method along with some sample usage. This link may be of help as well SAP and SOAP Bindings
$Server="ims.csiro.au"
$Path="/WebService/Service.asmx?wsdl"
$SoapParameters = CreateObject("Scripting.Dictionary")
$SoapParameters.Add("XmlDoc", $XmlDoc.xml)
$SoapParameters.Add("uniqueids", $aUniqueid)
$SoapParameters.Add("Client", "Windows")
$SOAP = WebMethod($Server, $Path, "ProcessXmlDataSet", $SoapParameters)
Function WebMethod($Server, $Path, $MethodName, $SoapParameters)
Dim $Data,$Parameter,$Value,$oHttp,$Envelope,$Response,$Ticks
For Each $Parameter in $SoapParameters.Keys
$Data = $Data + '<'+ $Parameter + '>'
$Value = $SoapParameters.Item($Parameter)
If VarType($Value) & 8192
$Data = $Data + '<string>' + Join($Value, '</string><string>') + '</string>'
Else
$Data = $Data + $Value
EndIf
$Data = $Data + '</' + $Parameter + '>'
Next
; create an XmlHttp instance
$oHttp = CreateObject("Msxml2.XMLHTTP")
; Create the SOAP Envelope
$Envelope = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' +
' <soap:Envelope ' +
' xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
' xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"' +
' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
' <soap:Body>' +
' <' + $MethodName + ' xmlns="http://' + $Server + '/">' +
$Data +
' </' + $MethodName + '>' +
' </soap:Body>' +
'</soap:Envelope>'
; send the POST to the Web service
$oHttp.open("POST", "http://" + $Server + $Path, Not 1)
$oHttp.setRequestHeader("SOAPAction", '"http://' + $Server + '/' + $MethodName + '"')
$oHttp.setRequestHeader("Content-Type", 'text/xml; charset="utf-8"')
$oHttp.setRequestHeader("Connection", "close")
$oHttp.send($Envelope)
$Ticks=@TICKS
; a readyState of 4 means we're ready to use the data returned by XMLHTTP
While $oHttp.readyState<>4
If @TICKS-$Ticks>3000 Exit 1 EndIf
Loop
$Response = $oHttp.responseBody
If InStr($Response,'<' + $MethodName + 'Result>') And InStr($Response,'</' + $MethodName + 'Result>')
$Response = SubStr($Response, InStr($Response,'<' + $MethodName + 'Result>') + Len('<' + $MethodName + 'Result>'))
$WebMethod = Left($Response, InStr($Response,'</' + $MethodName + 'Result>') - 1)
EndIf
EndFunction
Cheers,
Richard
|
|
Top
|
|
|
|
#182728 - 2007-11-16 10:21 AM
Re: Read Data from Internet explorer
[Re: It_took_my_meds]
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
If none of the above suit you and you really want to stick with the sendkeys approach then look at something like AutoIT http://www.autoitscript.com
It has it's own scripting language, or you can use the COM object to control it from KiXtart.
AutoIT allows you to peek at the Window content, so that you can check on progress and wait for events.
Oh, and it costs nowt.
|
|
Top
|
|
|
|
#182748 - 2007-11-16 09:42 PM
Re: Read Data from Internet explorer
[Re: Richard H.]
|
SeaDub
Fresh Scripter
Registered: 2007-11-15
Posts: 8
|
Sounds good, I'll take a look into AutoIT and COM as well.
Thanks for your help!
|
|
Top
|
|
|
|
#182750 - 2007-11-16 10:00 PM
Re: Read Data from Internet explorer
[Re: SeaDub]
|
SeaDub
Fresh Scripter
Registered: 2007-11-15
Posts: 8
|
Alright... I found Witto's CopyToClipboard UDF... This could help me if I could figure out a way to Paste the value into a variable...
Anyone know if you can paste from your clipboard into a variable?
Thanks!
|
|
Top
|
|
|
|
#182759 - 2007-11-17 08:09 PM
Re: Read Data from Internet explorer
[Re: Witto]
|
SeaDub
Fresh Scripter
Registered: 2007-11-15
Posts: 8
|
WOW. OK I'm an idiot.. Thanks for the help. That should get it working..
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1188 anonymous users online.
|
|
|