Jump to content
Simpel

Again WinHTTP and Proxy

Recommended Posts

Hi there.

I'm testing this code:

#include "WinHttp.au3"

; http://www.w3schools.com/php/demo_form_validation_escapechar.php
$sUserName = "SomeUserName"
$sEmail = "some.email@something.com"
$sDomain = "www.w3schools.com"
$sPage = "/php/demo_form_validation_escapechar.php"

; Data to send
$sAdditionalData = "name=" & $sUserName & "&email=" & $sEmail

; Initialize and get session handle
$hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hOpen = ' & $hOpen & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

; Get connection handle
$hConnect = _WinHttpConnect($hOpen, $sDomain)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hConnect = ' & $hConnect & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

; Make a request
$hRequest = _WinHttpOpenRequest($hConnect, "POST", $sPage)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hRequest = ' & $hRequest & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

; Send it. Specify additional data to send too. This is required by the Google API:
$hSendRequest = _WinHttpSendRequest($hRequest, "Content-Type: application/x-www-form-urlencoded", $sAdditionalData)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hSendRequest = ' & $hSendRequest & @CRLF & '>Error code: ' & @error & @TAB & "@extended: " & @extended & @CRLF) ;### Debug Console

; Wait for the response
$hReceiveResponse = _WinHttpReceiveResponse($hRequest)

; See what's returned
Dim $sReturned
If _WinHttpQueryDataAvailable($hRequest) Then ; if there is data
    Do
        $sReturned &= _WinHttpReadData($hRequest)
    Until @error
EndIf

; Close handles
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

; See what's returned
ConsoleWrite("Returned: " & $sReturned & @CRLF)

But sending a request fails.

Console outputs this:

>Running:(3.3.12.0) ...
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
@@ Debug(14) : $hOpen = 0x00000000007DF540
>Error code: 0
@@ Debug(18) : $hConnect = 0x00000000008271C0
>Error code: 0
@@ Debug(22) : $hRequest = 0x00000000008B88E0
>Error code: 0
@@ Debug(26) : $hSendRequest = 0
>Error code: 1 @extended: 0
Returned:
+>17:00:18 AutoIt3.exe ended.rc:0
+>17:00:18 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 0.6003

I'm testing it at work. There, we always have to identify at a proxy to be allowed to go to internet. But requests via inet.au3 will work. Maybe our firewall will block the request?

Any ideas? I don't have any possibilities to test at home, because of OSX.

 

Regards, Conrad

Edited by Simpel
formating code + [Solved] + Problem again

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites

If you need to identify proxy IE uses then you can use _WinHttpGetIEProxyConfigForCurrentUser() function.

;...
$aIEproxy = _WinHttpGetIEProxyConfigForCurrentUser()
$sProxy = $aIEproxy[2]

$hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0", $WINHTTP_ACCESS_TYPE_NAMED_PROXY, $sProxy)
;...

 

Share this post


Link to post
Share on other sites
_ArrayDisplay($aIEproxy)

says:

[0]         1
[1]
[2]
[3]

and:

ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sProxy = ' & $sProxy & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

says:

@@ Debug(15) : $sProxy = 
@@ Debug(21) : $hOpen = 0
>Error code: 0

$aIEproxy[0] = 1 means autodetect, correct? If I now try your modified "$hOpen" it's not working.


SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites

ipconfig /all replies

WINS-Proxy activated - NO

If I use intranet I'm always fine. When I want to use internet connection I first have to type in username and password.


SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites

Yes.

If I open a site in IE or FF. FF says something like: "Proxy moz-proxy://xxxprx01.xxx-xxx.de:8080 Needs username and password".


SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites
$sProxy = "xxxprx01.xxx-xxx.de:8080"

Now I'm a bit forward. $hSendRequest includes now "credentials are missing - username and password". Fine.

How to put username and password into the proxy variable? "USERNAME:PASSWORD@xxxprx01.xxx-xxx.de:8080" is not working.


SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites

My guess you are dealing with proxy that supports session based authentication. That means that for every session you have to authenticate.
If that's true you need to extend _WinHttpOpen() and add authentication routine. Like this maybe:

#include "WinHttp.au3"

Global Const $sAddress = "http://xxxprx01.xxx-xxx.de:8080" ; address of your proxy that requires authorization

; Credentials
Global Const $sUserName = "user", $sPassword = "password"
; Open session (with credentials from above)
Global $hOpen = OpenProxySession($sAddress)


; Try some site now
$hConnect = _WinHttpConnect($hOpen, "http://google.com")
; Simple-request it...
MsgBox(64, "Returned (first 1400 characters of google.com)", StringLeft(_WinHttpSimpleRequest($hConnect), 1400) & "...")
; Close handle
_WinHttpCloseHandle($hConnect)


; Finally close session
_WinHttpCloseHandle($hOpen)



Func OpenProxySession($sAddress)
    ; Initialize and get session handle
    Local $hOpen = _WinHttpOpen()
    If $hOpen Then
        ; Get connection handle
        Local $hConnect = _WinHttpConnect($hOpen, $sAddress)

        If $hConnect Then
            ; Specify the reguest
            Local $hRequest = _WinHttpOpenRequest($hConnect)
            If $hRequest Then
                ; Send the request
                _WinHttpSendRequest($hRequest)

                ; Wait for the response
                _WinHttpReceiveResponse($hRequest)

                ; Query status code
                Local $iStatusCode = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_STATUS_CODE)
                ; Check status code
                If $iStatusCode = $HTTP_STATUS_DENIED Or $iStatusCode = $HTTP_STATUS_PROXY_AUTH_REQ Then
                    ; Query Authorization scheme
                    Local $iSupportedSchemes, $iFirstScheme, $iAuthTarget
                    If _WinHttpQueryAuthSchemes($hRequest, $iSupportedSchemes, $iFirstScheme, $iAuthTarget) Then
                        ; Set passed credentials
                        _WinHttpSetCredentials($hRequest, $iAuthTarget, $iFirstScheme, $sUserName, $sPassword)
                        ; Send request again now
                        _WinHttpSendRequest($hRequest)
                        ; And wait for the response again
                        _WinHttpReceiveResponse($hRequest)
                        ; Excellent. You should be in if credentials were ok!!!
                    EndIf
                EndIf
                _WinHttpCloseHandle($hRequest)
            EndIf
            _WinHttpCloseHandle($hConnect)
        EndIf
    EndIf
    ; Return session handle
    Return $hOpen
EndFunc

But that's really only my guess.

Share this post


Link to post
Share on other sites

Scratch that, this should work:

#include "WinHttp.au3"

Global Const $sProxy = "http://xxxprx01.xxx-xxx.de:8080" ; address of your proxy that requires authorization
; Credentials
Global Const $sUserName = "username", $sPassword = "password" ; set correct 

; Open session
Global $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240", $WINHTTP_ACCESS_TYPE_NAMED_PROXY, $sProxy)
;~ _WinHttpSetOption($hOpen, $WINHTTP_OPTION_REDIRECT_POLICY, $WINHTTP_OPTION_REDIRECT_POLICY_NEVER)

; Try some site now
$hConnect = _WinHttpConnect($hOpen, "http://www.w3.org/")

$hRequest = _WinHttpSimpleSendRequest_ProxyAuth($hConnect)
; Simple-read...
MsgBox(4096, "http://www.w3.org/ says", _WinHttpSimpleReadData($hRequest))


; Close handles
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)



Func _WinHttpSimpleSendRequest_ProxyAuth($hConnect, $sType = Default, $sPath = Default, $sReferrer = Default, $sDta = Default, $sHeader = Default)
    ; Specify the reguest
    Local $hRequest = _WinHttpSimpleSendRequest($hConnect, $sType, $sPath, $sReferrer, $sDta, $sHeader)
    If $hRequest Then
        ConsoleWrite(_WinHttpQueryHeaders($hRequest) & @CRLF) ; let's print what the proxy says
        ; Query status code
        Local $iStatusCode = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_STATUS_CODE)
        ; Check status code
        If $iStatusCode = $HTTP_STATUS_PROXY_AUTH_REQ Then
            ; Query Authorization scheme
            Local $iSupportedSchemes, $iFirstScheme, $iAuthTarget
            If _WinHttpQueryAuthSchemes($hRequest, $iSupportedSchemes, $iFirstScheme, $iAuthTarget) Then
                ; Set passed credentials
                _WinHttpSetCredentials($hRequest, $iAuthTarget, $iFirstScheme, $sUserName, $sPassword)
                ; Send request again now
                _WinHttpSendRequest($hRequest)
                ; And wait for the response again
                _WinHttpReceiveResponse($hRequest)
                ; Excellent. You should be in if credentials were ok!!!
            EndIf
        EndIf
    EndIf
    Return $hRequest
EndFunc

However I'm not sure what will happen if you "open" address that redirects to another address. Proxy I tested this with doesn't cache credentials, and therefore redirects fail. If that would happen to you then uncomment the line below _WinHttpOpen() and test it again.

Share this post


Link to post
Share on other sites

Thank you. It's working.

Sorry for delay. I had to test it under various conditions. And it took me a long time to understand how WinHttp.au3 and your snippet works.

Sometimes my code was running and then with little changes not.

Thanks and regards, Conrad


SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites

Hi,

now it's broken. They changed something. This is your code modified by me:

#include "WinHttp.au3"

Global Const $sProxy = "http://PROXY:8080" ; address of your proxy that requires authorization
; Credentials
Global Const $sUserName = "USER", $sPassword = "PASSWORD" ; set correct

; Open session
Global $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240", $WINHTTP_ACCESS_TYPE_NAMED_PROXY, $sProxy)
;~ _WinHttpSetOption($hOpen, $WINHTTP_OPTION_REDIRECT_POLICY, $WINHTTP_OPTION_REDIRECT_POLICY_NEVER)

; Try some site now
$hConnect = _WinHttpConnect($hOpen, "http://posttestserver.com")

$hRequest = _WinHttpSimpleSendRequest_ProxyAuth($hConnect)
; Simple-read...
MsgBox(4096, "http://posttestserver.com/ says", _WinHttpSimpleReadData($hRequest))

$msg = _POST()
MsgBox(0, '', $msg)
ClipPut($msg)
Exit

; Close handles
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

Func _POST()
   Local $sData = ("Something to test and post.")
   Local $vRequest = _WinHttpSimpleRequest($hConnect, "POST", "http://posttestserver.com/post.php", $WINHTTP_NO_REFERER, $sData, "Content-Type: application/x-www-form-urlencoded")
   If @error Then Return "Unable To Send Request"
   Return $vRequest
EndFunc

Func _WinHttpSimpleSendRequest_ProxyAuth($hConnect, $sType = Default, $sPath = Default, $sReferrer = Default, $sDta = Default, $sHeader = Default)
    ; Specify the reguest
    Local $hRequest = _WinHttpSimpleSendRequest($hConnect, $sType, $sPath, $sReferrer, $sDta, $sHeader)
    If $hRequest Then
;~         ConsoleWrite(_WinHttpQueryHeaders($hRequest) & @CRLF) ; let's print what the proxy says
        ; Query status code
        Local $iStatusCode = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_STATUS_CODE)
        ; Check status code
        If $iStatusCode = $HTTP_STATUS_PROXY_AUTH_REQ Then
            ; Query Authorization scheme
            Local $iSupportedSchemes, $iFirstScheme, $iAuthTarget
            If _WinHttpQueryAuthSchemes($hRequest, $iSupportedSchemes, $iFirstScheme, $iAuthTarget) Then
                ; Set passed credentials
                _WinHttpSetCredentials($hRequest, $iAuthTarget, $iFirstScheme, $sUserName, $sPassword)
                ; Send request again now
                _WinHttpSendRequest($hRequest)
                ; And wait for the response again
                _WinHttpReceiveResponse($hRequest)
                ; Excellent. You should be in if credentials were ok!!!
            EndIf
        EndIf
    EndIf
    Return $hRequest
EndFunc

The output my clipboard contains:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<!-- FileName: index.html
     Language: [en]
-->
<!--Head-->
<head>
  <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  <meta http-equiv="X-UA-Compatible" content="IE=7" />
  <title>Proxy Message</title>
  <script src="/mwg-internal/de5fs23hu73ds/files/javascript/sw.js" type="text/javascript" ></script>
  <link rel="stylesheet" href="/mwg-internal/de5fs23hu73ds/files/default/stylesheet.css" />
</head>
<!--/Head-->
<!--Body-->
<body onload="swOnLoad();">
  <table class='bodyTable'>
    <tr>
      <td class='bodyData' background='/mwg-internal/de5fs23hu73ds/files/default/img/bg_body.gif'>
<!--Logo-->
<table class='logoTable'>
  <tr>
    <td class='logoData'>
      <a href='http://www.xxxxxxxxxxxxxxx.de'>
        <img src='/mwg-internal/de5fs23hu73ds/files/default/img/logo_mwg.png'></a>
    </td>
  </tr>
</table>
<!--/Logo-->
<!--Contents-->
<!-- FileName: authenticationrequired.html
     Language: [en]
-->
<!--Title-->
<table class='titleTable' background='/mwg-internal/de5fs23hu73ds/files/default/img/bg_navbar.jpg'>
  <tr>
    <td class='titleData'>
      Authentication Required
    </td>
  </tr>
</table>
<!--/Title-->

<!--Content-->
<table class="contentTable">
  <tr>
    <td class="contentData">
      You must be authenticated to access this URL.
    </td>
  </tr>
</table>
    
<script language="javascript" type="text/javascript">
   urlprotocol = "http";
   statuscode=407;

   if(statuscode==401 && urlprotocol == "ftp"){
      document.write("<form name=\"ftpform\" method=\"get\" action=\"\">");
      document.write("<table class=\"contentData\">");
      document.write("<tr><td class=\"contentData\" colspan=2>Please enter your credentials in the form below and click \"Access FTP\" button if your browser doesn't present authentication promt for FTP sites.</td></tr>");
      document.write("<tr><td class=\"contentData\">Username:</td><td><input type=\"text\" id=\"ftpUsername\" name=\"ftpUsername\" size=40 /></td></tr>");
      document.write("<tr><td class=\"contentData\">Password:</td><td><input type=\"password\" id=\"ftpPassword\" name=\"ftpPassword\" size=40 /></td></tr>");
      document.write("<tr><td class=\"contentData\" colspan=2 align=center><input type=\"button\" onclick=\"redirectToFTP();\" value=\"Access FTP\" /></td></tr>");
      document.write("</table>");
      document.write("</form>");
   }
   
   function redirectToFTP(){
      var username=escape(document.getElementById("ftpUsername").value);
      var password=escape(document.getElementById("ftpPassword").value);
      location.href = "ftp://"+username+":"+password+"@posttestserver.com:80/http://posttestserver.com/post.php"
   }
</script>
<!--/Content-->

<!--Info-->
<table class="infoTable">
  <tr>
    <td class="infoData">
      <b>URL: </b><script type="text/javascript">break_line("http://posttestserver.com/http://posttestserver.com/post.php");</script><br />
    </td>
  </tr>
</table>
<!--/Info-->

<!--/Contents-->
<!--Policy-->
<table class='policyTable'>
  <tr>
    <td class='policyHeading'>
      <hr>
      Company Acceptable Use Policy
    </td>
  </tr>
  <tr>
    <td class='policyData'>
      This is an optional acceptable use disclaimer that appears on every page. You may change the wording or remove this section entirely in index.html.
    </td>
  </tr>
</table>
<!--/Policy-->
<!--Foot-->
<table class='footTable'>
  <tr>
    <td class='helpDeskData' background='/mwg-internal/de5fs23hu73ds/files/default/img/bg_navbar.jpg'>
      For assistance, please contact your system administrator.
    </td>
  </tr>
  <tr>
    <td class='footData'>
      generated <span id="time">2016-05-09 21:46:25</span> by McAfee Web Gateway
      <br />
<br />
      Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240
    </td>
  </tr>
</table>
<!--/Foot-->
      </td>
    </tr>
  </table>
</body>
<!--/Body-->
</html>

_WinHttpSimpleReadData is working _WinHttpSimpleRequest not. What's wrong?

Regards, Conrad

Edited by Simpel

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

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

  • Similar Content

    • By Docfxit
      I'm getting an error in this script:
      Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) TrayTip("clears any tray tip","",0) AutoItSetOption("TrayIconDebug", 1) ;0-off #include "OSVersion.au3" Run('C:\Dnload\9xAddons\TestThis.exe') MsgBox("","Test","$ProgramFiles - " & $ProgramFiles & @CRLF & "_OSVersion() - " & _OSVersion()) Exit This is the error I am getting:

      The variables should be defined in the #include "OSVersion.au3"
      Func _OSVersion() Global $OSVersion Local $sWinVer = FileGetVersion('winver.exe') $OS_Version = @OSVersion $servicepack_version = StringReplace(@OSServicePack, "Service Pack ", "SP") If @error = -1 Then $servicepack_version = "" ConsoleWrite($OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') & @CRLF) ConsoleWrite(@OSArch & @CRLF) If $OSVersion = 'Win7' Or $OSVersion = 'Win7SP1' Or $OSVersion = 'Win7X64' Or $OSVersion = 'Win7SP1x64' Then $ProgramFiles = "C:\Programs\" Else $ProgramFiles = "C:\Program Files\" EndIf Return $OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') EndFunc ;==>_OSVersion What do I need to do to resolve the error?
      Thanks,
      Docfxit
    • By coles
      Hi All,
      Need a help with Autoit task, I am trying to copy an XML file and edit that XML file and copy it back
      The script i have attached if the script we use to copy files to client from server, so basically what it does is
      Going through a Set of IP address and 
      Map the drive Copy the file Write copy process was success Goes on a loop through IP's to check all machines have updated files   #include <File.au3> #include <iNet.au3> #include <_XMLDomWrapper.au3> func latestUpdate($address, $name) Local $result Local $hFileIndexHTML DriveMapDel ( "G:" ) ConsoleWrite('Trying: ' & $address & "/" & $name & @CRLF); $result = DriveMapAdd ( "G:", "\\" & $address & "\C$", 0, $name & "\adminname","adminpswd") ;Copying the file from Mapped drive to local if $result = 1 Then FileCopy( "G:\Program Files\test.xml", "C:\sample\test.xml", 1); ConsoleWrite('Copying Updated File: ' & $address & @CRLF); $hFileIndexHTML = FileOpen("C:\sample\test.txt", 1) FileWrite($hFileIndexHTML, $address & @CRLF) FileClose($hFileIndexHTML) EndIf EndFunc func done($file, $address) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) if ( $address = $line ) Then ConsoleWrite('Already done: ' & $file & " " & $address & @CRLF); return true EndIf Next return false EndFunc func getMachineName($ipaddress) return _TCPIpToName($ipaddress) EndFunc func process($address) local $machineName $machineName = getMachineName($address) if ($machineName = "") Then ConsoleWrite("No machine found at:" & $address & @CRLF) Else ConsoleWrite("Machine found at:" & $address & " - " & $machineName & @CRLF) if ( done( "C:\sample\test.txt", $address) = false ) then if ( $machineName <> "" ) then latestUpdate($address, $machineName) else endif endif EndIf EndFunc TCPStartup() while 1=1 PROCESS("10.10.1.1") sleep( 1000 * 60 * 10) wend The XML file i am trying to copy is unique and different in all machines (Machine name,ID's etc), But whole structure is the same (ie, the num of lines ) [That's the reason i can't copy a single file to all the machines].
      I was thinking of using _FileWriteToLine  to replace 3 lines with new data 
      eg:
      _FileWriteToLine("c:\sample\test.xml", 71,  "<RIA>"http://goog.html"</RIA>", True) 
      _FileWriteToLine("c:\sample\test.xml", 350,  "<col header="Status" width="7%" dataFld="status_code" style="" preprocesser="processES" template="" hidden="0"/>", True) 
      _FileWriteToLine("c:\sample\test.xml", 650,  "<col header="Units" width="11%" dataFld="units" style="" preprocesser="" template="fU(units)" hidden="0"/>", True) 
      These lines inside XML  
      340<em>
      341<gd
      342-360 is similar as blah blah <col header="Status" width="7%" dataFld="status_code" style="" preprocesser="processES" template="" hidden="0"/>
      same goes for 650th line also
       
      I would like to get opinion of copying this file as this is a highly critical file needed to keep machines running
       
      Do you think using _file write to line is risky?. Do you think i have to copy the file from parent folder to another folder after replacing the lines and then copy from there back to client system. This is all what i can think now, Any comments/suggestions will be much appreciated.
       
       
       
       
       
    • By Arm_And_Hammer
      I need to open a program for part of my script; the name of the program is "Cisco IP Communicator". The two ways I know to open the program right now are to either to click on the desktop shortcut ("Cisco IP Commincator.lnk") or by viewing the shortcut's target file location, and running the .exe file ("communicatork9.exe").

      The code I'm using is as follows: 
       
      #RequireAdmin
      $ciscoApp = "C:\Program Files (x86)\Cisco Systems\Cisco IP Communicator\communicatork9.exe"
      Run($ciscoApp)


      Whenever I run this script, I am prompted for administrator access and then nothing happens. If anyone has any suggestions on how to fix this issue, I'd really appreciate it. Thanks!
       
    • By tecc
      As explained elsewhere the idea is to highlight a phone number in an e-mail, docx or PDF and to press Capslock to get get it formatted properly and pasted into our softphone client and dial the number. Problem here is twofold:

      - the number gets pasted and dialing starts but then interrupts (as if ESC were pressed) and then immediately dialing starts again and the call goes out
      - once the number has been dialed successfully and the clipboard emptied, another press on Capslockon another highlighted phone number should do the same.
        What happens though is that this new number does get pasted but not formatted. Any idea what's wrong with my loop/function?
       
      #include <Clipboard.au3> While ProcessExists("3CXWin8Phone.exe") HotKeySet("{CAPSLOCK}", "GetNumber") WEnd Func GetNumber() Opt("SendCapslockMode",0) Send("{CAPSLOCK OFF}") Send("^c") $n = ClipGet() $n = StringRegExpReplace("0" & $n , _ '^(?:0\+49|0\d|(0)\+(\d\d))(?:\h*\(0\))?\D*0?(\d+)\D*(\d+)\D*', "0$1$2$3$4") ClipPut ($n) WinActivate("3CX - ") WinWaitActive("3CX - ") Send("^v") Sleep(500) Send("{ENTER}") ClipPut ("") EndFunc Exit  
    • By diego_bihalva
      Hi guys!
       I'm looking for your help  
      The problem is: when I got the iFrame object at the page's source code, the return was "ok", but when I tryed to pick the iFrame's source code, the result is "nothing". Even use the _IETagNameAllGetCollection and others similar functions the result is the same: "nothing"
       
      Au3 Script:
      ... #include<IE.au3> Local $oIE = ... Local $oFrame = _IEGetObjById($oIE, "_wicket_window_3") ConsoleWrite(IsObj($oFrame) & @CRLF) ;RESULT = 1 ConsoleWrite($oFrame.outerHtml & @CRLF) ;RESULT = NOTHING Principal Page's source code:
      Note: the form tag doesn't have a ID or Name, but if I look for iFrame from $oIE source code, It's "ok". <html> ... <body> ... DIVs, INPUTS, and so forth ... <div class="wicket-modal" id="_wicket_window_0" role="dialog" aria-labelledby="Portal da Portabilidade de Crédito" style="left: 283px; top: 273.5px; width: 800px; visibility: visible; position: absolute;"> ... DIVs, INPUTS, and so forth ... <form style="border-width: 0px; margin: 0px; padding: 0px; position: static; background-color: transparent;"> ... DIVs, INPUTS, and so forth ... <iframe class="wicket_modal" id="_wicket_window_3" src="" frameborder="0" style="height: 620px;" allowtransparency="false"></iframe> ... DIVs, INPUTS, and so forth ... </form> ... DIVs, INPUTS, and so forth ... </div> ... DIVs, INPUTS, and so forth ... </body> </html>  
      iFrame's "_wicket_window_3" source code, viewed by IE Element Inspector (I WANNA GET THIS):
      <html xmlns="http://www.w3.org/1999/xhtml"><head><script src="/static/js/jquery-1.8.3.js" type="text/javascript"></script> <script src="../../wicket/resource/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/res/js/wicket-event-jquery-ver-1408133796000.js" type="text/javascript"></script> <script src="../../wicket/resource/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/res/js/wicket-ajax-jquery-ver-1408133796000.js" type="text/javascript"></script> <script src="../../wicket/resource/org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow/res/modal-ver-1408133800000.js" type="text/javascript"></script> <link href="../../wicket/resource/org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow/res/modal-ver-1408133800000.css" rel="stylesheet" type="text/css"> <script id="wicket-ajax-base-url" type="text/javascript"> /*<![CDATA[*/ Wicket.Ajax.baseUrl="ctc/portabilidadeContaSalario/detalhar?3"; /*]]>*/ </script> <script src="../../../../static/js/jquery-ui/jquery-ui.min.js" type="text/javascript"></script> <link href="../../../../static/js/jquery-ui/jquery-ui.min.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="robots" content="noindex"> <link href="../../static/css/ctc.css" rel="stylesheet" type="text/css"> <link href="../../static/css/ctc_custom.css" rel="stylesheet" type="text/css"> <script src="../../static/js/deployJava.js" charset="utf-8"></script></head><body><object width="0" height="0" id="deployJavaPlugin" classid="clsid:CAFEEFAC-DEC7-0000-0001-ABCDEFFEDCBA" data="data:application/x-oleobject;base64,rO/+ysfeAAAAAavN7/7cugAKAAAAAAAAAAAAAA=="></object> <script src="../../static/js/jquery-ctc.js" charset="utf-8"></script> <script src="../../static/js/signUtils.js" charset="utf-8"></script> <script src="../../static/js/json3.in.js" charset="utf-8"></script> <script src="../../static/js/menu2.js" charset="utf-8"></script> <script src="../../static/js/componentTicket.js" charset="utf-8"></script> <script src="../../static/js/appletScript.js" charset="utf-8"></script> <script src="../../static/js/biginteger/bigInteger.js" charset="utf-8"></script> <link href="../../favicon.ico" rel="icon" type="image/ico"> <script id="jquery.blockui" src="../../static/js/jquery.blockUI.js" type="text/javascript" charset="utf-8"></script> <script id="jquery.maskedinput" src="../../static/js/jquery.maskedinput-1.3.1.min.js" type="text/javascript" charset="utf-8"></script> <script id="jquery.priceformat" src="../../static/js/jquery.price_format.2.0.js" type="text/javascript" charset="utf-8"></script> <script src="/csrfTokenS" type="text/javascript"></script> <script type="text/javascript"> /*<![CDATA[*/ Wicket.Event.add(window, "domready", function(event) { Wicket.Ajax.ajax({"sc":"content:contentChild:contentForm:RightContent:ContentDiv:wizardPortabilidade:divTab:tabsWizard:0:tabWizard:divTabContent:divContent:tabContent:dataForm:divTitle:btnRecolheAbba","c":"btnRecolheAbba4e","u":"./detalhar?3-1.IBehaviorListener.0-rootContent-BaseMainContent-BaseBlocoDireito-layoutForm-content-contentChild-contentForm-RightContent-ContentDiv-wizardPortabilidade-divTab-tabsWizard-0-tabWizard-divTabContent-divContent-tabContent-dataForm-divTitle-btnRecolheAbba","e":"click","f":"dataForm4d","m":"POST"});; $(document).ready(function(){if(isChrome()) { $('#contentChild').css({ 'border-top':'solid 1px white'});}window.scrollTo(0,0);; $("#cpfCli4f").mask("999.999.999-99",{}); $("#cpfCli4f").mask("999.999.999-99",{}); $("#TelCli50").mask("(99)99999999?9",{});}); Wicket.Ajax.ajax({"sc":"content:contentChild:contentForm:RightContent:ContentDiv:wizardPortabilidade:divTab:tabsWizard:0:tabWizard:divTabContent:divContent:tabContent:dataForm:containnerButtons:containerAcionsButtons:1:actionButton","c":"actionButton51","u":"./detalhar?3-1.IBehaviorListener.0-rootContent-BaseMainContent-BaseBlocoDireito-layoutForm-content-contentChild-contentForm-RightContent-ContentDiv-wizardPortabilidade-divTab-tabsWizard-0-tabWizard-divTabContent-divContent-tabContent-dataForm-containnerButtons-containerAcionsButtons-1-actionButton","e":"click","f":"dataForm4d","m":"POST"});; Wicket.Ajax.ajax({"c":"dataForm4d","u":"./detalhar?3-1.IBehaviorListener.0-rootContent-BaseMainContent-BaseBlocoDireito-layoutForm-content-contentChild-contentForm-RightContent-ContentDiv-wizardPortabilidade-divTab-tabsWizard-0-tabWizard-divTabContent-divContent-tabContent-dataForm","e":"submit","f":"dataForm4d","m":"POST"});; Wicket.Ajax.ajax({"c":"contentForm52","u":"./detalhar?3-1.IBehaviorListener.0-rootContent-BaseMainContent-BaseBlocoDireito-layoutForm-content-contentChild-contentForm","e":"submit","f":"contentForm52","m":"POST"});; Wicket.Ajax.ajax({"c":"layoutForm","u":"./detalhar?3-1.IBehaviorListener.0-rootContent-BaseMainContent-BaseBlocoDireito-layoutForm","e":"submit","f":"layoutForm","m":"POST"});; ;}); /*]]>*/ </script> <title>Portal da Portabilidade de Crédito</title> <div id="rootContent"> <div id="main" style="margin: 0px;"> <div id="corpo"> <div id="blocoDireito" style="padding: 0px; top: 0px;"> <form id="layoutForm" action="./detalhar?3-1.IFormSubmitListener-rootContent-BaseMainContent-BaseBlocoDireito-layoutForm&amp;SECURITYTOKEN=HIMY-BPSD-5C7F-20H2-XERE-E38O-YKYZ-VVB7-H53V-M9FA-B4CB-P3E6-557U-T5J7-IB1Q-N256" method="post" defaultform="true"><div style="left: -100px; top: -100px; width: 0px; height: 0px; overflow: hidden; position: absolute;"><input name="layoutForm_hf_0" id="layoutForm_hf_0" type="hidden"></div> <div id="messagePanel" style="display: none;"></div> <div id="pagina"> <div id="contentChild"> <div id="contentForm52" defaultform="true"> <div id="right" style="margin: 0px;"> <div id="conteudo" style="margin: 0px;"> <span><h3 style="margin: 0px 0px 10px; padding: 0px;"> <font color="gray">NU Portabilidade: </font>201807110000056998252 <br><font color="gray">Situação: </font>Aceite Compulsório por falta de resposta do Participante Folha de Pagamento <br><font color="gray">Data: </font>17/07/2018 <br><font color="gray">Motivo: </font>Aceite Compulsório por falta de resposta do Participante Folha de Pagamento</h3></span> <span> <div class="passos" id="divBreadCrumb53"> <div class="passo ativo"> <div class="passo numero ativo"><span>1</span></div> <div class="passoTexto"><span>Cliente</span></div> <br class="clr"> <div class="passoStatus"><span>Você está aqui</span></div> </div> <div class="passo inativo"> <div class="passo numero inativo"><span>2</span></div> <div class="passoTexto"><span>Participante</span></div> <br class="clr"> <div class="passoStatus"><span>Você está aqui</span></div> </div> </div> <div id="divTab54"> <div class="passosConteudo"> <div> <div id="AbaCliente_0" ticket="Identificação do cliente" containnerpath="AbaCliente_0" containnerid="AbaCliente_0"> <div id="dataForm4d" defaultform="true"> <table style="width: 726px;" border="0" cellspacing="0" cellpadding="0"> <tbody><tr> <td class="destaqueTb" style="width: 100%;"> <span class="tituloTb">Identificação do cliente</span> <span class="imgTb"><input name="content:contentChild:contentForm:RightContent:ContentDiv:wizardPortabilidade:divTab:tabsWizard:0:tabWizard:divTabContent:divContent:tabContent:dataForm:divTitle:btnRecolheAbba" class="btRecolher" id="btnRecolheAbba4e" type="button"></span> </td> </tr> <tr> <td class="blocoDados2 itemVisivel" id="divContent_tabContent"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tbody><tr> <td> <div class="dados"> <span>CPF *</span><br> <input name="content:contentChild:contentForm:RightContent:ContentDiv:wizardPortabilidade:divTab:tabsWizard:0:tabWizard:divTabContent:divContent:tabContent:dataForm:divContent:cpfCli" disabled="disabled" id="cpfCli4f" style="width: 210px;" maxlength="15" value="01234567890" ticket="CPF" mask="CPF" unmask="true" ticketpath="AbaCliente_0"> </div> </td> </tr> <tr> <td colspan="2"> <div class="dados"> <span>Nome *</span><br> <input name="content:contentChild:contentForm:RightContent:ContentDiv:wizardPortabilidade:divTab:tabsWizard:0:tabWizard:divTabContent:divContent:tabContent:dataForm:divContent:NomCli" disabled="disabled" id="NomCli55" style="width: 550px;" type="text" maxlength="80" value="JOAO DA SILVA" ticket="Nome" ticketpath="AbaCliente_0"> </div> </td> </tr> <tr> <td> <div class="dados"> <span>Telefone</span><br> <input name="content:contentChild:contentForm:RightContent:ContentDiv:wizardPortabilidade:divTab:tabsWizard:0:tabWizard:divTabContent:divContent:tabContent:dataForm:divContent:TelCli" disabled="disabled" id="TelCli50" style="width: 210px;" type="text" value="" ticket="Telefone" mask="TELEFONE_DDD_XSD" unmask="false" ticketpath="AbaCliente_0"> </div> </td> <td> <div class="dados"> <span>Email</span><br> <input name="content:contentChild:contentForm:RightContent:ContentDiv:wizardPortabilidade:divTab:tabsWizard:0:tabWizard:divTabContent:divContent:tabContent:dataForm:divContent:EmailCli" disabled="disabled" id="EmailCli56" style="width: 300px;" type="text" maxlength="50" value="" ticket="Email" ticketpath="AbaCliente_0"> </div> </td> </tr> <tr> <td> <div class="dados"> <span>Código Autenticação do Beneficiário</span><br> <input name="content:contentChild:contentForm:RightContent:ContentDiv:wizardPortabilidade:divTab:tabsWizard:0:tabWizard:divTabContent:divContent:tabContent:dataForm:divContent:codigoAutenticacaoBeneficiario" disabled="disabled" id="codigoAutenticacaoBeneficiario57" style="width: 210px;" type="text" maxlength="100" value="" ticket="Código Autenticação do Beneficiário" ticketpath="AbaCliente_0"> </div> </td> </tr> </tbody></table> </td> </tr> </tbody></table> <div class="botoes"> <input name="ACTION" class="botao botaoPadrao" id="actionButton51" type="submit" value="Próximo"> </div> </div> </div> </div> </div> </div> <div class="botoes" id="divBotoes58" style="margin: -30px 0px 4px;"> </div> </span> <span></span> </div> </div> </div> </div> <div id="popUpWindow59" style="display: none;"> <div id="content5a" style="display: none;"></div> </div> <div id="popupConfirmacao5b" style="display: none;"> <div id="content5c" style="display: none;"></div> </div> </div> <input name="SECURITYTOKEN" type="hidden" value="XXXX"></form> <br class="clr"> </div> </div> </div> <script type="text/javascript"> /*<![CDATA[*/ $(document).ready(function() { setInterval(function() { var data = new Date(); var options = { year: "numeric", month: "numeric", day: "numeric" }; $('#dataHora').html(data.toLocaleTimeString("pt-BR", options)); }, 1000); }); /*]]>*/ </script> </div> <div style="display: none;"> <h1 id="blockUIView"><img width="40" height="40" style="top: 15px; position: relative;" src="../../static/imagens/big-roller.gif"><span id="messageWait">Por favor, aguarde...</span></h1> </div> <span id="confirmationDialog5d" style="display: none;"> </span> <script>var attributes = {"id":"ecpfApplet","codebase":"*","height":"1","width":"1","code":"br.org.cip.applet.EcpfApplet"}; var parameters = {"jnlp_href":"/jnlp/generator/ecpf.jnlp"}; var version = "1.6"; var applet = deployJava.runApplet(attributes,parameters,version);</script><applet width="1" height="1" id="ecpfApplet" codebase="*" code="br.org.cip.applet.EcpfApplet"><PARAM NAME="_cx" VALUE="26"><PARAM NAME="_cy" VALUE="26"> <param name="jnlp_href" value="/jnlp/generator/ecpf.jnlp"><param name="codebase_lookup" value="false"> </applet> <span id="asynchronousComponent5e" style="display: none;">Asynchronous</span> <script type="text/javascript"> /*<![CDATA[*/ /*** $(document).ready(function() { alert('Completou a renderização'); }); $("#tableRender").ready(function() { alert("Table rendered finish"); }); ****/ $.blockUI.defaults.message = $('#blockUIView'); var assyncProcess = false; $(document).ajaxStart(function() { if(!assyncProcess) $.blockUI(); }).ajaxStop(function() { if(!assyncProcess) $.unblockUI(); }); var fieldNamesError = new Array(); var fieldNamesNoError = new Array(); function fieldsDecorator(fieldError,fieldNoError) { fieldNamesError = fieldError==null?fieldNamesError:fieldError; fieldNamesNoError = fieldNoError==null?fieldNamesNoError:fieldNoError; } function decorator() { $.each(fieldNamesError, function( key, val ) { var selectorID = val;//"[ticket='"+val+"']"; $(selectorID).addClass("inputError"); }); $.each(fieldNamesNoError, function( key, val ) { var selectorID = val;//"[ticket='"+val+"']"; $(selectorID).removeClass("inputError"); }); } function isInternetExplorer() { var ie = navigator.userAgent.toString().toLowerCase().indexOf('msie')>0; return ie; } function isChrome() { var chrome = navigator.userAgent.toString().toLowerCase().indexOf('chrome')>0; return chrome; } function assynchronousProcessing(imageurl,message) { assyncProcess = true; $.unblockUI(); $.blockUI({ message: '<h1><img height="40" width="40" style="position:relative; top:15px;" src="'+imageurl+'" /> '+message+'...</h1>' }); } /*]]>*/ </script> </body></html> Well, I'll appreciate all kind of help.
      Thank you!
×
×
  • Create New...