Jump to content

WinINet.au3 (FTP/HTTP/HTTPS/Gopher+)


-Ultima-
 Share

Recommended Posts

if i leave the file blank and run the first example you sent which is the one above it seems to update the video. is that okay today??

Local $asFiles[1][2] = [ _
    ["file", ""] _
]oÝ÷ Ú&¦ë-ëmx¢wî±çm¯(§Ú.׫²Ö§v+*.®Ç+`¢Ù+Ú®&ëØ(¡×«®Üç$x,¢;¬·§¶Ú&jG¬º·¢q©î±ì¨ºÇ+_¢»azêe¡§ZÖ¥²î²ÛhyØ­¶¯×¨¶­j··w+©yÖÞq«¬z)h¢F­¶¬{¦¦WØ­Âäy×è®;¬¶ê]jاØ^¾'^¢Ëajܭ業æÊêe¡§^u»­©­¯(§Ú¢jZ­ëh¶¶¶{hÜ(®KÛaz·­ë(ëax,¶­j·¢jez×¥ÉØ}êÞجy쨺ê]j׶[(¬zØZ¶Ì!É«­¢+Ø¥¹±ÕÅÕ½Ðí]¥¹%9йÔÌÅÕ½Ðì()±±=Á¸ ÅÕ½ÐíÝ¥¹¥¹Ð¹±°ÅÕ½Ðì¤((ÀÌØí¥¹ÑɹÐô}]¥¹%9Ñ}%¹ÑɹÑ=Á¸ ÅÕ½Ðí5½é¥±±ÅÕ½Ðì¤)%ÀÌØí¥¹ÑɹÐôôÀQ¡¸(5Í ½à À°ÅÕ½ÐíÉɽÈÅÕ½Ðì°ÅÕ½ÐíMÑÕÀÉɽÈÅÕ½Ðì¤)¹%(ÀÌØí¥ÀôÅÕ½ÐíÕÁ±½Ì¹±¥À¹ÑØÅÕ½Ðì(ÀÌØíÁ½ÉÐôÅÕ½ÐìàÀÅÕ½Ðì(ÀÌØí¥¹Ñɹѽ¹¹Ðô}]¥¹%9Ñ}%¹ÑɹÑ
½¹¹Ð ÀÌØí¥¹ÑɹаÀÌØí%9QI9Q}MIY%
}!QQ@°ÀÌØí¥À°ÀÌØíÁ½ÉФ()%ÉɽÈQ¡¸5Í  ½à À°ÅÕ½ÐíÉɽÈÅÕ½Ðì°ÅÕ½ÐíÉɽÈÈÅÕ½Ðì¤(((ÀÌØíÑôÅÕ½ÐíÁ½ÍÐôĵÀíÍ­¥¸õÁ¤µÀíÕÍɱ½¥¸õÍÕ¥¡Ñɽ´µÀíÁÍÍݽÉõáááááááàµÀí¥ôÄØÄÔÜÌàµÀíѥѱõÑÍйåI±±ä¥Ð]½É­ÌÅÕ½Ðììѹ½(ÀÌØíÑåÁôÅÕ½Ðí
½¹Ñ¹ÐµQåÁèÁÁ±¥Ñ¥½¸½àµÝÝܵ½É´µÕɱ¹½ÅÕ½ÐìµÀí
I1(ÀÌØí¹ÐôÅÕ½ÐíUÍȵ¹Ðè5½é¥±±¼Ð¸ÀÅÕ½ÐìµÀí
I1((ÀÌØí¹ÝÑôÀÌØí¹ÐµÀìÀÌØíÑåÁ((ÀÌØí¡ÑÑÁÉÅÕÍÐô}]¥¹%9Ñ}!ÑÑÁ=Á¹IÅÕÍÐ ÀÌØí¥¹Ñɹѽ¹¹Ð°ÅÕ½ÐíA=MPÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì¤(ÀÌØí¡Èô}]¥¹%9Ñ}!ÑÑÁIÅÕÍÑ!ÉÌ ÀÌØí¡ÑÑÁÉÅÕÍаÀÌØí¹ÝÑ°ÀÌØí!QQA}IE}1}¤)
½¹Í½±]É¥Ñ ÀÌØí¡ÈµÀì
I1¤((ÀÌØí͹ÉÅÕÍÐô}]¥¹%9Ñ}!ÑÑÁM¹IÅÕÍÐ ÀÌØí¡ÑÑÁÉÅÕÍбձбMÑÉ¥¹Q½   ¥¹Éä ÀÌØíѤ¤)±½°ÀÌØíÉ¥±ô  ¥¹Éä ÅÕ½ÐìÅÕ½Ðì¤)¼(ÀÌØíÉ¥±µÀìô}]¥¹%9Ñ}%¹ÑɹÑI¥± ÀÌØí¡ÑÑÁÉÅÕÍаÔÀÀÀ¤)U¹Ñ¥°ÉɽȱÐìÐìÀ=È9½Ðáѹ)5Í ½à À°ÅÕ½Ðí
½¹Ñ¹ÐÅÕ½Ðì°¥¹ÉåѽÍÑÉ¥¹ ÀÌØíÉ¥±¤¤
Edited by subfighter
Link to comment
Share on other sites

  • 2 months later...

I just started playing with the FTP.au3 and getting something to work for things I like and need to do to automate. This WinINet looks good. Are there samples to look at to get into this direction?

Dr SherlockAlways a way

Link to comment
Share on other sites

  • 3 weeks later...

Good work Ultima !

I'm just a scripter, so I had use for these simple functions which use somewhat modified versions of four of your WinInet UDF's ...

; Squirrely1 Functions:

;

; _ActiveInetConnection_IsLAN

; _ActiveInetConnection_IsDialup

; _ActiveInetConnection_IsThroughProxy

; _Dial_DefaultRASConnection

; _Disconnect_Dialup_Connection

; _Get_DefaultINetConnection_Name

; _IsSysConfiguredForDialup

; _LocalSystem_IsInet_Connected

; _Open_NetworkConnections_Folder

- contains some new syntax and different set of tests

Edited by Squirrely1

Das Häschen benutzt Radar

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
  • 6 months later...

Eh, edited first post with a slightly updated pack of these UDFs. The changes are relatively minor, but I've had them lying around for a very long time now, and don't feel right just leaving them alone. As originally stated in the first post, I was hoping this set of UDFs could/would be used as a thin wrapper around WinINet to provide a base for other UDFs requiring functionlity provided by WinINet (like FTP.au3), but lack of momentum and motivation set it back.

At this point, most (if not all) of the important WinINet functions are implemented, and should be usable in normal circumstances. The are a few example scripts, but they are far from complete. The FTP functions should have fairly complete usage examples, though. And yes, WinINetConstants.au3 is still very much unorganized, and may conflict with other includes.

If anyone else feels like they have the time and energy to pick this project up and run with it (assuming there's anything left to do), they're more than welcome. Just try to keep the original vision in mind: this is supposed to be a thin wrapper, so don't try to do too much with each function. That is, avoid building combo functions that call multiple WinINet functions just for convenience, because those probably belong on a different level than this low-level wrapper (or I suppose they could go in some *Ex() function).

Of course, the alternative is to leave feedback with potential changes for me to make. I'll still be around to check this thread from time to time, and might update the UDF set myself should the need arise, but at this point, I don't feel there is much left to do with this set of UDFs -- it's more-or-less complete. Its main problem is lack of examples to help get people started (and to be used as something like basic unit tests to verify functionality).

Too, I'm not sure if it's formatted acceptably to be included as part of the standard UDFs, which is partly why I haven't bothered to push for inclusion (the other reason being that FTPEx.au3 provides duplicate functionality in some cases, and I can't be bothered to update that set of UDFs too to wrap it around this set of UDFs).

Edited by -Ultima-

[ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ]

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...
  • 3 weeks later...

Hello,

Please excuse the automatic translation, my English is bad. :mellow:

I saw with interest that it is possible to extract information from a certificate with "WinINet".

You've given an example of the message: http://www.autoitscript.com/forum/index.php?showtopic=82588&st=0#entry771587

I need to extract more information than the expiration date.

Do you think this is possible?

I can find no reference to "ExpiryTime" on the Microsoft site but "ftExpiry" in this case what is the name "lpszSubjectInfo" ?

I'm lost, can you help me a little?

Thank you.

Link to comment
Share on other sites

  • 3 weeks later...

Thank you all for your kind educational and informative posts. I am kinda new here, even after searching a lot here and MSDN I was not properly able to ignore the "Certificate ERROR" in WinHTTP function and finally reached to WinINet.

The URL I am trying to access is "https://208.69.230.50/getHavaIp?hava_name=vgm", if you access from browser it will show certificate error and I have to add exception in Firefox. (IE7 Does not allow me to add exception)

The response of the URL is expected to be...

<ROOT>

<RETURNSTATUS>

<STATUS>1</STATUS>

<RESPONSECODE>408</RESPONSECODE>

<RESPONSEDETAIL>HAVA is not active</RESPONSEDETAIL>

</RETURNSTATUS>

</ROOT>

Someone please tell me what am I doing wrong in "_WinINet_InternetOpenUrl", it always fails. Here is that code I wrote... and thank you all for your kind patience and guidance.

====

#include <WinINet.au3>

; Initialize WinINet
_WinINet_Startup()

; Set variables
Global $sURIScheme = "https"
Global $sServerName = "third.havaremoteserver.com"
Global $iServerPort = 443

; Create handles
ConsoleWrite("Opening Internet connection ..." & @LF)
Global $hInternetOpen = _WinINet_InternetOpen("AutoIt/" & @AutoItVersion)
if @error Then
    ConsoleWrite("Open Internet connection: failed." & @LF)
Else
    ConsoleWrite("Open Internet connection: ok." & @LF)
EndIf

Global $hInternetOpenUrl = _WinINet_InternetOpenUrl($hInternetOpen, $sURIScheme & "://" & $sServerName, Default, $INTERNET_FLAG_SECURE)
if @error Then
    ConsoleWrite("Open Internet URL: failed." & @LF)
Else
    ConsoleWrite("Open Internet URL: ok." & @LF)
EndIf

; Cleanup
_WinINet_InternetCloseHandle($hInternetOpenUrl)
_WinINet_InternetCloseHandle($hInternetOpen)
_WinINet_Shutdown()

ConsoleWrite("End of program..." & @LF)
Link to comment
Share on other sites

Thank you all for your kind educational and informative posts. I am kinda new here, even after searching a lot here and MSDN I was not properly able to ignore the "Certificate ERROR" in WinHTTP function and finally reached to WinINet.

The URL I am trying to access is "https://208.69.230.50/getHavaIp?hava_name=vgm", if you access from browser it will show certificate error and I have to add exception in Firefox. (IE7 Does not allow me to add exception)

The response of the URL is expected to be...

<ROOT>

<RETURNSTATUS>

<STATUS>1</STATUS>

<RESPONSECODE>408</RESPONSECODE>

<RESPONSEDETAIL>HAVA is not active</RESPONSEDETAIL>

</RETURNSTATUS>

</ROOT>

Someone please tell me what am I doing wrong in "_WinINet_InternetOpenUrl", it always fails. Here is that code I wrote... and thank you all for your kind patience and guidance.

====

#include <WinINet.au3>

; Initialize WinINet
_WinINet_Startup()

; Set variables
Global $sURIScheme = "https"
Global $sServerName = "third.havaremoteserver.com"
Global $iServerPort = 443

; Create handles
ConsoleWrite("Opening Internet connection ..." & @LF)
Global $hInternetOpen = _WinINet_InternetOpen("AutoIt/" & @AutoItVersion)
if @error Then
    ConsoleWrite("Open Internet connection: failed." & @LF)
Else
    ConsoleWrite("Open Internet connection: ok." & @LF)
EndIf

Global $hInternetOpenUrl = _WinINet_InternetOpenUrl($hInternetOpen, $sURIScheme & "://" & $sServerName, Default, $INTERNET_FLAG_SECURE)
if @error Then
    ConsoleWrite("Open Internet URL: failed." & @LF)
Else
    ConsoleWrite("Open Internet URL: ok." & @LF)
EndIf

; Cleanup
_WinINet_InternetCloseHandle($hInternetOpenUrl)
_WinINet_InternetCloseHandle($hInternetOpen)
_WinINet_Shutdown()

ConsoleWrite("End of program..." & @LF)

====================================

Here is the one which I tried with WinHTTP function. unsuccessful again.

#include<WinHTTP.au3>

;https://208.69.230.50/getHavaIp?hava_name=vgm
$LocalIP = "208.69.230.50"
$hw_open = _WinHttpOpen()
$hw_connect = _WinHttpConnect($hw_open, $LocalIP)
$h_openRequest = _WinHttpOpenRequest($hw_connect, "get", "getHavaIp?")
$data = "hava_name=vgm"

_WinHttpSendRequest($h_openRequest,$WINHTTP_NO_ADDITIONAL_HEADERS, "",StringLen($data), 0)

_WinHttpWriteData($h_openRequest, $data)

_WinHttpReceiveResponse($h_openRequest)

MsgBox(0, 'Recived', _WinHttpReadData($h_openRequest))

_WinHttpCloseHandle($h_openRequest)

_WinHttpCloseHandle($hw_connect)

_WinHttpCloseHandle($hw_open)
Link to comment
Share on other sites

  • 2 weeks later...

When I run in V3.3.6.0 it shows an error that "@AutoItUnicode" is not a defined Macro. So I did some digging around the Help file and found that it was added on 16th May, 2008 - v3.2.12.0 to replace "@Unicode" but I can 't seem to find if it was deleted and why it's not in the macro list of the Help file?

I simply deleted from the UDF!

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • 3 weeks later...

Since about a month the following code doesn't work anymore:

$avResult = DllCall("wininet.dll", "dword", "InternetAutodial", "dword", 10)

the parameter with value 10 means 2+8, so FORCE_UNATTENDED + OVERRIDE_NET_PRESENT.

But it doesn't work anymore... I guess some windows update might have changed something in the wininet.dll, although I couldn't find information on the internet.

The DLLCall returns success ($avResult[0] = 1) and @error = 0. I just don't get what's wrong here.

This has always worked for me... I'm so said, my PC now doesn't establish the internet connection after startup any longer :(

[font="Courier New"]http://RomanK.hondadesigns.com[/font]
Link to comment
Share on other sites

  • 6 months later...

I have been trying to figure out a way to login to this link:

https://www.aplusmaint.net/beta/prog/login.php

Using variables "username" and "password"

My website designer says I need to do this using "POST".

But I can't seem to figure it out. No matter what I do I get blank information.

It would be great if someone could show me a "POST" example using a https website.

Thanks!

Link to comment
Share on other sites

  • 2 weeks later...

I've read that M$ doesn't support really well WinInet very well since Winhttp is released.

Funny when i see some application in C# that uses it intensively ( vClient for example )/

I can confirm that wininet works well and is the only solution to manage HTTPS connection without a certificate already installed.That's must

be why vClient uses it instead of WinHTTP.

But ... wininet is not, really not stable for async functions. I can post what i've done to make async works, but it crashes all the time.

My dream would be to handle Secure connection myself with TCP event driven udf, but nobody realeased an udf on how to handle this "secure" protocol.

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

  • 2 weeks later...

I want to retrieve data from a php page with POST or GET.

I tried with this POST method:

; start WinINet libary
$iStartup = _WinINet_Startup()
ConsoleWriteLog("_WinINet_Startup", @error, @extended, $iStartup)

$internet = _WinINet_InternetOpen("Mozilla")
If $internet == 0 Then
    MsgBox(0, "Error", "Setup Error")
EndIf
$ip = "mioServer"
$port = "80"
$internetconnect = _WinINet_InternetConnect($internet, $INTERNET_SERVICE_HTTP, $ip, $port)

If @error Then MsgBox(0, "Error", "Error 2")


$data = "action=autoit"  ; Data encoded
$type = "Content-Type: application/x-www-form-urlencoded"&@CRLF
$agent = "User-Agent: Mozilla/4.0"&@CRLF

$newdata = $agent & $type

$httprequest = _WinINet_HttpOpenRequest($internetconnect, "POST", "/public/Files/PHP/content.php" ) 

$addheader = _WinINet_HttpAddRequestHeaders($httprequest, $newdata, $HTTP_ADDREQ_FLAG_ADD)
ConsoleWrite($addheader & @CRLF)

$sendrequest = _WinINet_HttpSendRequest($httprequest,Default,StringToBinary($data)) ; 
ConsoleWrite($sendrequest & @CRLF)

local $readfile = "" ;Binary("")
Do
$readfile &= _WinINet_InternetReadFile($httprequest, 5000)
Until @error<>0 Or Not @extended
MsgBox(0, "Content", binarytostring($readfile) & @error & "  ex=" & @extended);

; end WinINet library
$iShutdown = _WinINet_Shutdown()

I tried also This GET:

$httprequest = _WinINet_HttpOpenRequest($internetconnect, "GET", "/public/Files/PHP/content.php?action=autoit" )

$sendrequest = _WinINet_HttpSendRequest($httprequest,Default)

My php has:

if (  $_REQUEST['action'] == "autoit" ) 
{
    $content = 'autoTest OK';
    echo ($content) ;
}

The answer is "", that is @error = 1 with Binary().

I tried with a Ajax html page from a browser and the answer is correct.

How should I make the script to receive the answer from the php page?

Edited by frank10
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...