Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/27/2020 in all areas

  1. Nine

    Bat file to Autoit exe

    Instead of using this prehistoric DOS approach, I would recommend that you create a simple AutoIt GUI that can provide a more robust, secure interface. It only takes a few minutes, you could add some input verification and automate pretty much all you want within your script without relying to external program.
    2 points
  2. Another option would be to introduce AutoitX to your team so that they could continue coding in Python and take advantage of some Autoit features.
    2 points
  3. Bert

    AutoIT vs Python question

    Both languages are good to work with. One big difference between them is Python has multi-threading support. AutoIT doesn't. Unless you are building major applications, this should not be a problem. AutoIt is also intended for windows. Python is portable. AutoIt is very easy to do automation. When it was first conceived, that was the intent of the language. Over the years it grew into the language it is today. I code in many languages, depending on the need. No one language is the swiss army knife of computer languages. If your team is comfortable with Python & it meets their needs, then I'd go with that. You may want to do a demo on how to do things in both languages if you see how things could be made easier. You may find AUtoIt is easier or Python is easier - it ALL depends on your needs. One big thing with AUtoIT is you don't need to have libraries. All the coding you need can be placed in a single script and compiled. Scripts to automate can be very simple. The forum has thousands of examples of scripts that can do just about anything. Not sure if this answers your question.
    2 points
  4. You could try using Tidy with the /gd switch to generate docs for each test script. The report is a text file, but it might be something you could work with. https://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/Tidy.html Adam
    2 points
  5. water

    AD - Active Directory UDF

    Version 1.6.3.0

    17,290 downloads

    Extensive library to control and manipulate Microsoft Active Directory. Threads: Development - General Help & Support - Example Scripts - Wiki Previous downloads: 30467 Known Bugs: (last changed: 2020-10-05) None Things to come: (last changed: 2020-07-21) None BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort
    1 point
  6. I was asking @eltorro serveral times for any support for XML DOM wrapper (COM) - with no success So I took matters into my hands ..... I want to present XMLWrapperEx.au3 - BETA Version Want to join to the project ? Here is some description: ; #INDEX# ======================================================================================================================= ; Title .........: XMLWrapperEx.au3 ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: Functions to use for reading and writing XML using msxml. ; Remarks .......: BETA Version ; Author ........: mLipok ; Version .......: "1.1.1.01" ; _XML_MiscProperty_UDFVersion() #CS This UDF is created on the basis of: https://www.autoitscript.com/forum/topic/19848-xml-dom-wrapper-com/ For this reason, I attach also the last known (to me) previous version ($_XMLUDFVER = "1.0.3.98" _XMLDomWrapper_1.0.3.98_CN.au3 ) For the same reason I continue to recognize the achievements of the work of my predecessors (they are still noted in each Function header). . . . . !!!!!!!!! This is BETA VERSION (all could be changed) !!!!!!!!! . . . WORK IN PROGRES INFORMATION: For now 2015-09-01 the descripion (Function Header) can not entirely correctly describe the function. TODO: in many places I used "TODO" as a keyword to find what should be done in future . I want to: PREVENT THIS: The unfortunate nature of both the scripts is that the func return results are strings or arrays instead of objects. .     I want to: USE THIS CONCEPT:     .   All function should use Refernce to the object as first Function parameter     .   All function should return in most cases objects. There should be separate functions to Change Object collection to array     .   All function should use COM Error Handler in local scope.     .   All function should return @error which are defined in #Region XMLWrapperEx.au3 - @ERROR Enums     .    All function should have the same naming convention     .    All variables should have the same naming convention     .    There should not to be any Global Variable - exception is $g__oXMLDOM_Events     .   It should be possible easy to use XML DOM Events     .        https://msdn.microsoft.com/en-us/library/ms764697(v=vs.85).aspx     .   It should be possible easy to Debug     .    Ultimately, you should be able to do anything with your XML without having to use your own Error Handler. #CE More info inside zip archive. This UDF can be downloaded from here: REMARK: This UDF was formerly named: XMLWrapperEx.au3
    1 point
  7. I was chatting with some college kids at a Starbucks about Autoit & they just assumed I am a noob programmer when they heard my enthusiasm about coding AutoIt... Which they have never heard of... I find Autoit to be highly undervalued & underestimated in the engineering world... You can accomplish, build & test things 5X faster than with any other language. Also, Autoit serves as a powerful unique software integration medium. Also, Autoit can build almost anything Python can build & if Python has some libraries that Autoit lacks I just run those compiled python files with Autoit. Anyways... the question is has anyone been dismissed as a noob coder for programming Autoit as their go-to main programming language? Other than a larger library I don't think there are any noticeable performance differences between Python & Autoit right?
    1 point
  8. This topic give you access to an AutoIt functions library I maintain which is called PAL, Peter's AutoIt Library. The latest version 1.29 contains 231 functions divided into these topics: window, desktop and monitor GUI, mouse and color GUI controls including graphical buttons (jpg, png) GUI numberbox controls for integer, real, binary and hexadecimal input logics and mathematics include constants string, xml string and file string dialogues and progress bars data lists: lists, stacks, shift registers and key maps (a.ka. dictionaries) miscellaneous: logging/debugging, process and system info Change log and files section on the PAL website (SourceForge). A lot of these functions were created in the development of Peace, Peter's Equalizer APO Configuration Extension which is a user interface for the system-wide audio driver called Equalizer APO.
    1 point
  9. When sound files have to be played, Sound.au3 UDF comes to our mind immediately. It is simple and easy to use. But WMPlayer.ocx has a lot more features: it can play video clips and flac audio files, which Sound.au3 UDF cannot. Below are quick and dirty comparison of codes utilizing two different methods. Both of them do exactly the same thing: play back a playlist of audio files, with a simple slider control. 1. Use of Sound.au3 UDF #include <GUIConstants.au3> #include <Sound.au3> #include <Misc.au3> $hGui = GUICreate("Sound.au3", 400, 75, -1, -1) $Label1 = GUICtrlCreateButton("", 0, 0, 400, 20) GUICtrlSetState(-1, $GUI_DISABLE) $Shuttle = GUICtrlCreatePic(StringReplace(@AutoItExe, "autoit3.exe", "\examples\gui\msoobe.jpg"), 0, 0, 20, 20) $Pause = GUICtrlCreateButton("Pause", 160, 40, 80, 20) $Progress = GUICtrlCreateLabel("0:00", 4, 25, 45, 20, $SS_LEFT) ; current media position $Length = GUICtrlCreateLabel("0:00", 350, 25, 45, 20, $SS_RIGHT) ; media length GUISetState(@SW_SHOW) Local $aPlayList[3] ; Put your own mp3 file paths in this playlist $aPlayList[0] = 2 ; number of files in the playlist $aPlayList[1] = "D:\Music - Classics\Beethoven - Piano Concerto 5 in Eb Major Allegro.mp3" $aPlayList[2] = "D:\Music - Pops\Adele - Hello.mp3" $nFiles = 0 For $i = 1 To $aPlayList[0] If Not FileExists($aPlayList[$i]) Then $nFiles += 1 EndIf Next If $nFiles = $aPlayList[0] Then MsgBox(0, "Sound.au3", "None of the files listed in $aPlayList array exists.", 5) GUIDelete($hGui) Exit EndIf $iPos = 0 ; x coordinate of $Shuttle cntrol in progress bar $hDLL = DllOpen("user32.dll") ; to dectect mouse down on the $Shuttle control $sliderLength = 380 ; in pixels $adlibInterval = 250 ; in milliseconds $nFile = 0 While 1 $nFile += 1 If $nFile > $aPlayList[0] Then $nFile = 1 EndIf $sFullPath = $aPlayList[$nFile] $aSound = _SoundOpen($sFullPath) If $aSound = 0 Then MsgBox(0, "Sound.au3", $sFullPath & @CRLF & @CRLF & "Cannot open this file.", 5) ContinueLoop EndIf _SoundPlay($aSound) $sFile = StringMid($sFullPath, StringInStr($sFullPath, "\", 0, -1)+1) GUICtrlSetData($Label1, $sFile) $mediaLength = _SoundLength($aSound, 2) / 1000 ; in seconds GUICtrlSetData($Length, Int($mediaLength/60) & ":" & StringFormat("%02i", Mod($mediaLength, 60))) AdlibRegister("Slider", $adlibInterval) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _SoundClose($aSound) Exit Case $Pause If GUICtrlRead($Pause) = "Pause" Then _SoundPause($aSound) AdlibUnRegister() GUICtrlSetData($Pause, "Resume") Else _SoundResume($aSound) AdlibRegister("Slider") GUICtrlSetData($Pause, "Pause") EndIf Case $Shuttle AdlibUnRegister() $x = MouseGetPos(0) $xOffset = $x - $iPos While _IsPressed("01", $hDLL) = 1 $x = MouseGetPos(0) If $x > 380+$xOffset Then $x = 380+$xOffset ElseIf $x < $xOffset Then $x = $xOffset EndIf $iPos = $x - $xOffset GUICtrlSetPos($Shuttle, $iPos) Sleep(1) WEnd $mediaPos = Round($iPos/$sliderLength*$mediaLength) $iHour = Int($mediaPos/3600) $iMin = Int(Mod($mediaPos, 3600)/60) $iSec = Mod($mediaPos, 60) _SoundSeek($aSound, $iHour, $iMin, $iSec) _SoundPlay($aSound) AdlibRegister("Slider", $adlibInterval) GUICtrlSetData($Pause, "Pause") EndSwitch If _SoundStatus($aSound) = "stopped" Then ; playing, paused, stopped ExitLoop EndIf WEnd WEnd Func Slider() $mediaPos = _SoundPos($aSound, 2)/1000 $iPos = $mediaPos * $sliderLength / $mediaLength GUICtrlSetPos($Shuttle, $iPos) GUICtrlSetData($Progress, Int($mediaPos/60) & ":" & StringFormat("%02i", Mod($mediaPos, 60))) EndFunc 2. Use of WMPlayer.ocx #include <GuiConstants.au3> #include <Misc.au3> $hGui = GUICreate("WMPlayer.OCX", 400, 75, -1, -1) $Label1 = GUICtrlCreateButton("", 0, 0, 400, 20) GUICtrlSetState(-1, $GUI_DISABLE) $Shuttle = GUICtrlCreatePic(StringReplace(@AutoItExe, "autoit3.exe", "examples\gui\msoobe.jpg"), 0, 0, 20, 20) $Pause = GUICtrlCreateButton("Pause", 160, 40, 80, 20) $Progress = GUICtrlCreateLabel("0:00", 4, 25, 45, 20, $SS_LEFT) ; current media position $Length = GUICtrlCreateLabel("0:00", 350, 25, 45, 20, $SS_RIGHT) ; media length GUISetState(@SW_SHOW) Local $aPlayList[3] ; Put your own mp3 file paths in this playlist $aPlayList[0] = 2 ; number of files in the playlist $aPlayList[1] = "D:\Music - Classics\Beethoven - Piano Concerto 5 in Eb Major Allegro.mp3" $aPlayList[2] = "D:\Music - Pops\Adele - Hello.mp3" $nFiles = 0 For $i = 1 To $aPlayList[0] If Not FileExists($aPlayList[$i]) Then $nFiles += 1 EndIf Next If $nFiles = $aPlayList[0] Then MsgBox(0, "WMPlayer.ocx", "None of the files listed in $aPlayList array exists.", 5) GUIDelete($hGui) Exit EndIf $oPlayer = ObjCreate("WMPlayer.OCX") If Not IsObj($oPlayer) Then MsgBox(0, "WMPlayer.OCX", "Cannot create a WMP object.", 5) GUIDelete($hGui) Exit EndIf $iPos = 0 ; x coordinate of $Shuttle cntrol in progress bar $hDLL = DllOpen("user32.dll") ; to dectect mouse down on the $Shuttle control $sliderLength = 380 ; in pixels $adlibInterval = 250 ; in milliseconds $oPlayer.Settings.Volume = 100 $nFile = 0 While 1 $nFile += 1 If $nFile > $aPlayList[0] Then $nFile = 1 EndIf $sFullPath = $aPlayList[$nFile] $oPlayer.URL = $sFullPath $hTimer = TimerInit() While $oPlayer.playState <> 3 ; 1 - stopped, 2 - paused, 3 - playing If TimerDiff($hTimer) > 3000 Then MsgBox(0, "WMPlayer.OCX", $sFullPath & @CRLF & @CRLF & "Cannot play this file.", 5) ExitLoop EndIf Sleep(5) WEnd If $oPlayer.playState <> 3 Then ContinueLoop EndIf $sFile = StringMid($sFullPath, StringInStr($sFullPath, "\", 0, -1)+1) GUICtrlSetData($Label1, $sFile) $mediaLength = Int($oPlayer.currentMedia.Duration) ; in seconds GUICtrlSetData($Length, Int($mediaLength/60) & ":" & StringFormat("%02i", Mod($mediaLength, 60))) AdlibRegister("Slider", $adlibInterval) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE $oPlayer.Close Exit Case $Pause If GUICtrlRead($Pause) = "Pause" Then $oPlayer.Controls.Pause AdlibUnRegister() GUICtrlSetData($Pause, "Resume") Else $oPlayer.Controls.Play AdlibRegister("Slider") GUICtrlSetData($Pause, "Pause") EndIf Case $Shuttle AdlibUnRegister() $x = MouseGetPos(0) $xOffset = $x - $iPos While _IsPressed("01", $hDLL) = 1 $x = MouseGetPos(0) If $x > 380+$xOffset Then $x = 380+$xOffset ElseIf $x < $xOffset Then $x = $xOffset EndIf $iPos = $x - $xOffset GUICtrlSetPos($Shuttle, $iPos) Sleep(1) WEnd $mediaPos = $iPos/$sliderLength*$mediaLength $oPlayer.Controls.currentPosition = $mediaPos $oPlayer.Controls.Play AdlibRegister("Slider", $adlibInterval) GUICtrlSetData($Pause, "Pause") EndSwitch If $oPlayer.playState = 1 Then ExitLoop EndIf WEnd WEnd Func Slider() $mediaPos = $oPlayer.Controls.currentPosition $iPos = $mediaPos * $sliderLength / $mediaLength GUICtrlSetPos($Shuttle, $iPos) GUICtrlSetData($Progress, Int($mediaPos/60) & ":" & StringFormat("%02i", Mod($mediaPos, 60))) EndFunc
    1 point
  10. Codecrypter version 3.1 is released; a major upgrade, made possible by the incorporation of TheXman's CryptoNG suite (with permission, of course). Many thanks to TheXman for allowing me to incorporate Bcrypt dll calls (works in 32/64-bit, in Win7 and up), which perform almost as fast as Ward's machine code routines, wherever Bcrypt is available (NB perhaps not on WinXP and earlier OS versions, so if you're maintaining paleoware, stick to Ward's algo). For now, only AES encryption is actively supported, but any coder familiar with CryptoNG will be able to swap that for any other symmetric encryption algorithm by changing one global variable. I've taken this opportunity to fix a whole ream of minor bugs (why did no-one tell me before that obfuscation messed with WinAPI_UniqueHardwareID calls?!), and re-tested the various encryption options (on helloworld, goodbyeworld, farewellworld, and a few other random scripts). However, since a lot of refactoring has taken place, it is likely that new bugs will now rear their repugnant visage. If you do encounter such a beastie, please also test whether it goes away when you select the alternate encryption engine (Ward's vs TheXman's), and let me know in this thread either way. And if you want me to have a look at your issue, please make the effort to post the smallest-possible reproducer script with your question/bug-report. Thanks. There's also a new, short and simple HowToGuide (CodeCrypter explained in five easy steps), and some minor edits in the FAQ. Hope you like it.
    1 point
  11. Nine

    SRER limitation

    Working for me, got the 1 with your new input string...
    1 point
  12. Why do you want to switch? In general you will only convince people when there are big differences which you need in your team acsolution for. https://github.com/pywinauto/pywinauto
    1 point
  13. Nine

    SRER limitation

    Try this : $sOutput = StringUnique_Delim($s, ",") MsgBox('', '', $sOutput) Func StringUnique_Delim($sString = "", $delim = ",") Return StringTrimLeft(StringRegExpReplace($delim & $sString, '(,+\b\d+\b)(?=.*?\b\1\b)|,{2}|,$', ""),1) EndFunc ;==>StringUnique_Delim
    1 point
  14. Musashi

    Bat file to Autoit exe

    I didn't consider your remark to be harsh, otherwise I would not have given it a 'Like' . Sometimes answers will be provided, that are within the scope of the user question, although more appropriate solutions would be preferable. That is exactly what you did - you have suggested a better approach.
    1 point
  15. Skysnake

    Hide my code in the .exe

    Why not simply make it open source? 🙃
    1 point
  16. Another option : Send('FILECMD.CMD "Sample{+ 5}.exe"{enter}')
    1 point
  17. You should not copy System.Net.dll or System.Net.Mail.dll anywhere. They are included in the Global Assembly Cache. You just need to tell the code that it needs these dlls. Use this code to make Net.NetworkCredential work: tst00.au3 #include "DotNetAll.au3" sendEmail3() Func sendEmail3() Local $oCode = DotNet_LoadVBcode( FileRead( "tst00.vb" ), "System.dll | System.Net.dll | netstandard.dll" ) If Not IsObj( $oCode ) Then Return ConsoleWrite( "DotNet_LoadVBcode ERR" & @CRLF ) ConsoleWrite( "DotNet_LoadVBcode OK" & @CRLF ) EndFunc tst00.vb Imports System Imports System.Net Imports netstandard Public Class Class1 Public myCredentials As Net.NetworkCredential End Class Read Microsoft documentation to find out what imports and dlls you need. And just add one or a few lines at a time until you have all the imports and dlls in place and the code works so far. And test code in SciTE so you get all error messages in the console.
    1 point
  18. When sending "raw" data, the string is sent as-is, without translating any of the special characters (+!^) or keys ({key}). So an alternate solution would be to break up the string into what you want to send as-is (raw) and the sending of keys like {ENTER}. #RequireAdmin Run(@ComSpec) WinWait("[CLASS:ConsoleWindowClass]") WinActivate("[CLASS:ConsoleWindowClass]") WinWaitActive("[CLASS:ConsoleWindowClass]") Send('FILECMD.CMD "Sample+++++.exe"', 1) Send('{enter}')
    1 point
  19. Yes, you are right my bad. And I do not see your png. Better to embed the plus...
    1 point
  20. Current Tidy Beta v19.1127.1402.2 will only list variables that start with $ or @ in the xref variable report. Jos
    1 point
  21. FYI, WMI has this field only in Win10. It won't work in Win7...
    1 point
  22. Try to send it raw : Send('FILECMD.CMD "Sample+.exe"{enter}', 1) As + means shift. Or embed + with {+}
    1 point
  23. You could give CodeScanner a whirl (link in my sig below); it won't answer all your queries, but should help in tackling some of them.
    1 point
  24. none. My internet is messed up and created a double entry
    1 point
  25. Thanks for your code, but it wasn't what i want Totally thanks for your care.
    1 point
  26. Or maybe something like: #include <File.au3> ConsoleWrite(_UniqueFileName(@ScriptDir & "\Filename.txt") & @CRLF) Func _UniqueFileName($_sFilePath) If FileExists($_sFilePath) = 0 Then Return $_sFilePath Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" Local $aPathSplit = _PathSplit($_sFilePath, $sDrive, $sDir, $sFileName, $sExtension) Local $i = 1 While 1 $_sFilePath = $sDrive & $sDir & $sFileName & "-" & $i & $sExtension If FileExists($_sFilePath) = 0 Then Return $_sFilePath $i += 1 WEnd EndFunc
    1 point
  27. ..make sure each function is self sufficient with proper error returns. That if an expected value is not as such ( $aArray is not an array, etc. ) is checked for. All these will take extra .01 ms. or so, but is worth it in the long run. Tidy and that's it. no clue. Don't remember seeing any.
    1 point
  28. LarsJ

    Autoit variable to dot Net

    No no no. These functions can only be used in relation to standard Windows code. Eg. The Windows API functions used to implement most official AutoIt UDFs (the include files) and internal AutoIt code. These functions cannot be used in relation to .NET code. There is a fundamental difference between standard Windows code and .NET code. The differences may be compared to the differences on Windows and Linux operating systems. But just as techniques exist to integrate Windows and Linux operating systems to some extent, so do techniques for integrating standard Windows code and .NET code. And these are such techniques that need to be used here. In AutoIt, there are no internal functions to support the techniques, and the techniques are at a somewhat experimental level. To get an impression of the code in question, take a look at the code on the pages of this thread. It's not that easy.
    1 point
  29. You also need to add references to System.Net and System.Net.Mail. Use this code: Local $oCode = DotNet_LoadVBcode( FileRead( "Class1.vb" ), "System.Net.dll | System.Net.Mail.dll | clsSendEmail.dll" )
    1 point
  30. @jchd That is an interesting statement. When I was working at Oracle, we were using ROWID all the time even if the table has a unique index. It was very practical when we were reusing the same row multiple times. The typical usage was when you fetch a row, make some modifications on it, and then update that row, using the ROWID on the update was by far the fastest way to do it. Maybe SQLite does not react as Oracle do when manipulating ROWID.
    1 point
  31. Please have a look at my OutlookEX UDF (for download please see my signature). Example script: #include <OutlookEX.au3> Local $iAttachmentCount = 0, $sAttachmentNames = "" Global $oOutlook = _OL_Open() MsgBox(0, "Select", "Please select one or multiple items ...") Global $oSelection = $oOutlook.ActiveExplorer().Selection For $oSel In $oSelection $iAttachmentCount = $oSel.attachments.Count $sAttachmentNames = "" $aAttachments = _OL_ItemAttachmentGet($oOutlook, $oSel) MsgBox(0, "_OL_ItemAttachmentGet", "@error = " & @error & ", @extended = " & @extended) _ArrayDisplay($aAttachments) If $iAttachmentCount > 0 Then For $i = 1 To $aAttachments[0][0] $sAttachmentNames = $aAttachments[$i][2] & @CRLF Next EndIf MsgBox(0, "Selection", "Subject: " & @CRLF & StringLeft($oSel.Subject, 100) & @CRLF & @CRLF & "Body:" & @CRLF & StringLeft($oSel.Body, 100) & @CRLF & @CRLF & "Attachments: " & $iAttachmentCount & @CRLF & $sAttachmentNames) Next
    1 point
  32. Version 1.4.1.0 of the UDF has been released. Please test before using in production! For download please see my signature.
    1 point
  33. I create CHM file's with Precision Helper. It's pretty easy to use but you need a decent HTML editor for the pages of your manual/help file. I use BlueGriffon. Let me hear if you need more info but it's quite easy to set up. For every UDF I created a HTLM file. Of course I could have create an automatic HTML file creator tool which scans the UDF's to create HTLM pages but I didn't bother. Most UDF's have additional info like an example which need to be written. To my opinion every library and program need a manual, a CHM file and/or website. Precision Helper can also created the pages for a help manual website. For the images in my programs and in a manual I use Inkscape and the Gimp.
    1 point
  34. What this script does Extracts the list of GDPR fines from website enforcementttracker.com and returns a 2D array holding all items. N.B. The numbers of the following list can be found in the script as comments. WebDriver functionality used Tested with Firefox Start geckodriver to automate Firefox from a different location (needs to be modified by you in the scripts source) Maximize the browser window Retrieve all values from the "Show n entries" dropdown and select the second to last (50 entries) Sort the table by clicking on a table header Scroll to the end of the page Search and click a button GDPR fines Version 1.au3 GDPR fines Version 2.au3
    1 point
  35. Ok, here is the translation of the question, as i did had this question in mind today when i find this on google and in my despair found that the correct answer wasn't here: He asked: How and From where, should anyone in need, could open mouse capture program. (as it isn't obvious from where can anybody open it) The correct answer is: You have to go in the folder where you installed autoit.exe and open Au3Info.exe I've searched scite menu for a button to open this to no avail ...
    1 point
  36. j0kky

    Winsock UDF

    Hi guys, some time ago I tried to deal with client\server application using native winsock functions, but I encountered some difficult because their limitations, so I decided to write a new UDF based on winsock library. Some functions are simply wrappers of native function, but some other are completely renewed and there are a lot of improvements. Check it out! Each function has a detailed description and I attached 5 simple example script ; #INDEX# ======================================================================================================================= ; Title .........: Winsock ; AutoIt Version : 3.3.14.2 ; Language ......: English ; Description ...: Functions that assist with Winsock library management. ; Author(s) .....: j0kky ; =============================================================================================================================== ; #CONSTANTS# =================================================================================================================== Global Const $TCP_DATA_EOT = 2 ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _TCPStartup ; _TCPListen ; _TCPAccept ; _TCPRecv ; _TCPConnect ; _TCPSend ; _TCPNameToIP ; _TCPCloseSocket ; _TCPShutdown ; _GetIps ; _UDPStartup ; _UDPBind ; _UDPSendTo ; _UDPRecvFrom ; _UDPCloseSocket ; _UDPShutdown ; =============================================================================================================================== ; #WRAPPER# ===================================================================================================================== Func _TCPStartup() $iResult = TCPStartup() Return SetError(@error, 0, $iResult) EndFunc ;==>_TCPStartup ; #WRAPPER# ===================================================================================================================== Func _TCPListen($iIPAddr, $iPort, $iMaxPendingConnection = 0) If Not $iMaxPendingConnection Then $iResult = TCPListen($iIPAddr, $iPort) Else $iResult = TCPListen($iIPAddr, $iPort, $iMaxPendingConnection) EndIf Return SetError(@error, 0, $iResult) EndFunc ;==>_TCPListen ; #FUNCTION# ==================================================================================================================== ; Name...........: _TCPAccept ; Description ...: Permits an incoming connection attempt on a socket. ; Syntax.........: _TCPAccept($iMainsocket) ; Parameters ....: $iMainsocket - The main socket identifier (SocketID) as returned by _TCPListen function. ; Return values .: On success it returns an array: ; |[0] - The connected socket identifier. ; |[1] - The external address of the client ; |[2] - The external port which the client are communicating on ; On failure it returns -1 and sets @error to non zero: ; |-1 - internal error ; |-2 - missing DLL (Ws2_32.dll) ; |-3 - undefined error ; |-4 - invalid parameter (not used in this function) ; |Any Windows Socket Error Code retrieved by WSAGetLastError ; Author ........: j0kky ; Modified ......: 1.0.0 ; Links .........: accept: https://msdn.microsoft.com/en-us/library/windows/desktop/ms737526(v=vs.85).aspx ; error codes: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx ; =============================================================================================================================== Func _TCPAccept($iMainsocket) $iMainsocket = Number($iMainsocket) If $iMainsocket < 0 Then Return SetError(-4, 0, -1) ; invalid parameter Local $hWs2 = DllOpen("Ws2_32.dll") If @error Then Return SetError(-2, 0, -1) ;missing DLL Local $bError = 0, $nCode = 0, $hSock = 0 Local $tagSockAddr = "short sin_family; ushort sin_port; " & _ "STRUCT; ulong S_addr; ENDSTRUCT; " & _ ;sin_addr "char sin_zero[8]" If Not $bError Then $aRet = DllCall($hWs2, "int", "ioctlsocket", "uint", $iMainsocket, "long", 0x8004667e, "ulong*", 1) ;FIONBIO If @error Then $bError = -1 ElseIf $aRet[0] <> 0 Then ;SOCKET_ERROR $bError = 1 EndIf EndIf If Not $bError Then $tSockAddr = DllStructCreate($tagSockAddr) $aRet = DllCall($hWs2, "uint", "accept", "uint", $iMainsocket, "ptr", DllStructGetPtr($tSockAddr), "int*", DllStructGetSize($tSockAddr)) If @error Then $bError = -1 ElseIf ($aRet[0] = 4294967295) Or ($aRet[0] = -1) Then ;INVALID_SOCKET $bError = 1 $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $bError = -1 ElseIf ($aRet[0] = 0) Or ($aRet[0] = 10035) Then ;WSAEWOULDBLOCK $nCode = -10 ;internal function value, it means no error EndIf Else $hSock = $aRet[0] $aRet = DllCall($hWs2, "ptr", "inet_ntoa", "ulong", DllStructGetData($tSockAddr, "S_addr")) If @error Then $bError = -1 ElseIf $aRet[0] = Null Then $bError = 1 Else $sIPAddr = DllStructGetData(DllStructCreate("char[15]", $aRet[0]), 1) $aRet = DllCall($hWs2, "ushort", "ntohs", "ushort", DllStructGetData($tSockAddr, "sin_port")) If @error Then $bError = -1 Else $nPort = $aRet[0] Local $aResult[3] = [$hSock, $sIPAddr, $nPort] EndIf EndIf EndIf EndIf If $bError < 0 Then $nCode = -1 ;internal error $nReturn = -1 ;failure If $hSock Then TCPCloseSocket($hSock) ElseIf $bError > 0 Then If Not $nCode Then $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $nCode = -1 Else $nCode = $aRet[0] EndIf If $nCode = 0 Then $nCode = -3 ;undefined error EndIf If $nCode = -10 Then $nCode = 0 $nReturn = -1 If $hSock Then TCPCloseSocket($hSock) Else $nReturn = $aResult EndIf DllClose($hWs2) Return SetError($nCode, 0, $nReturn) EndFunc ;==>_TCPAccept ; #FUNCTION# ==================================================================================================================== ; Name...........: _TCPRecv ; Description ...: Receives data from a connected socket. ; Syntax.........: _TCPRecv($iMainsocket, $iMaxLen, $iFlag = 0) ; Parameters ....: $iMainsocket - The array as returned by _TCPAccept ; or the connected socket identifier (SocketID) as returned by _TCPConnect. ; $iMaxLen - max # of characters to receive (usually 2048). ; $iFlag - values can be added together ; |$TCP_DATA_DEFAULT (0) - Text data. [Default] ; |$TCP_DATA_BINARY (1) - Binary data. ; |$TCP_DATA_EOT (2) - Returns data received and ; set @error to -6 when it reaches the End of Text ASCII character (Chr(3)) ; Return values .: On success it returns the binary/string sent by the connected socket. ; On failure it returns "" and sets the @error or @extended flag to non-zero: ; @error values: ; |-1 - internal error ; |-2 - missing DLL (Ws2_32.dll) ; |-3 - undefined error ; |-4 - invalid parameter ; |Any Windows Socket Error Code retrieved by WSAGetLastError ; @extended values: ; |1 - connection closed ; |2 - End of Text reached ; Author ........: j0kky ; Modified ......: 1.0.0 ; Remarks .......: If Unicode strings need to be transmitted they must be encoded/decoded with StringToBinary()/BinaryToString(). ; $iFlag = 2 must be set in couple with _TCPSend ; You must check for both @error and @extended, @extended could be set with @error set to zero ; Links .........: recv: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740121(v=vs.85).aspx ; error codes: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx ; =============================================================================================================================== Func _TCPRecv($iMainsocket, $iMaxLen, $iFlag = 0) If IsArray($iMainsocket) And (UBound($iMainsocket, 0) = 1) And (UBound($iMainsocket) > 0) Then $iMainsocket = $iMainsocket[0] If $iFlag = Default Then $iFlag = 0 $iMainsocket = Number($iMainsocket) $iMaxLen = Number($iMaxLen) $iFlag = Number($iFlag) If $iMainsocket < 0 Or _ $iMaxLen < 1 Or _ Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(-4, 0, -1) ; invalid parameter Local $hWs2 = DllOpen("Ws2_32.dll") If @error Then Return SetError(-2, 0, -1) ;missing DLL Local $bError = 0, $nCode = 0, $nExtended = 0 If Not $bError Then $aRet = DllCall($hWs2, "int", "ioctlsocket", "uint", $iMainsocket, "long", 0x8004667e, "ulong*", 1) ;FIONBIO If @error Then $bError = -1 ElseIf $aRet[0] <> 0 Then ;SOCKET_ERROR $bError = 1 EndIf EndIf Local $tBuf If $iFlag Then $tBuf = DllStructCreate("byte[" & $iMaxLen & "]") Else $tBuf = DllStructCreate("char[" & $iMaxLen & "]") EndIf $aRet = DllCall($hWs2, "int", "recv", "uint", $iMainsocket, "ptr", DllStructGetPtr($tBuf), "int", $iMaxLen, "int", 0) If @error Then $bError = -1 ElseIf ($aRet[0] = -1) Or ($aRet[0] = 4294967295) Then ;SOCKET_ERROR $bError = 1 $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $bError = -1 ElseIf $aRet[0] = 0 Or $aRet[0] = 10035 Then ;WSAEWOULDBLOCK $nCode = -10 ;internal function value, it means no error EndIf ElseIf $aRet[0] = 0 Then $bError = 1 $nCode = -10 $nExtended = 1 ;connection closed Else Local $sResult = DllStructGetData($tBuf, 1) ;data If BitAND($iFlag, 2) = 2 Then ;EOT If StringRight($sResult, 1) = Chr(3) Then $sResult = StringTrimRight($sResult, 1) $nExtended = 2 ;End of Text reached EndIf EndIf EndIf If $bError < 0 Then $nCode = -1 ;internal error $nReturn = "" ;failure ElseIf $bError > 0 Then If Not $nCode Then $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $nCode = -1 Else $nCode = $aRet[0] EndIf If $nCode = 0 Then $nCode = -3 ;undefined error EndIf If $nCode = -10 Then $nCode = 0 $nReturn = "" Else $nReturn = $sResult EndIf DllClose($hWs2) Return SetError($nCode, $nExtended, $nReturn) EndFunc ;==>_TCPRecv ; #FUNCTION# ==================================================================================================================== ; Name...........: _TCPConnect ; Description ...: Create a socket connected to an existing server. ; Syntax.........: _TCPConnect($sIPAddr, $iDestPort, $sSourceAddr = "", $iSourcePort = 0, $iTimeOut = 0) ; Parameters ....: $sIPAddr - Destination IP. ; |Internet Protocol dotted address(IpV4) as "192.162.1.1". ; $iDestPort - Destination port. ; |1 : 65534 - port on which the created socket will be connected. ; $sSourceAddr - Source IP ; |Internet Protocol dotted address(IpV4) as "192.162.1.1". [Default = ""] ; $iSourcePort - Source port. ; |1 : 65534 - port on which the created socket will be bind (on the local PC). [Default = 0] ; $iTimeOut - The maximum time in milliseconds for _TCPConnect to wait for connection. ; |Any value > 0 [Default = 0 and it will be equal to Opt("TCPTimeout")]. ; Return values .: On success it returns the main socket identifier. ; |Any value > 0 ; On failure it returns -1 and sets @error to non zero: ; |-1 - internal error ; |-2 - missing DLL (Ws2_32.dll) ; |-3 - undefined error ; |-4 - invalid parameter ; |-5 - not connected ; |-6 - timed out ; |Any Windows Socket Error Code retrieved by WSAGetLastError ; Author ........: j0kky ; Modified ......: 1.0.0 ; Remarks .......: This function is used by a client to communicate with the server and it allows to choose a source IP, ; a source port and to set a timeout for the connection. ; Links .........: bind: https://msdn.microsoft.com/en-us/library/windows/desktop/ms737550(v=vs.85).aspx ; connect: https://msdn.microsoft.com/en-us/library/windows/desktop/ms737625(v=vs.85).aspx ; select: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740141(v=vs.85).aspx ; error codes: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx ; =============================================================================================================================== Func _TCPConnect($sIPAddr, $iDestPort, $sSourceAddr = "", $iSourcePort = 0, $iTimeOut = 0) If $sSourceAddr = Default Then $sSourceAddr = "" If $iSourcePort = Default Then $iSourcePort = 0 If $iTimeOut = Default Then $iTimeOut = 0 $sIPAddr = String($sIPAddr) $iDestPort = Number($iDestPort) $sSourceAddr = String($sSourceAddr) $iSourcePort = Number($iSourcePort) $iTimeOut = Number($iTimeOut) If Not ($iDestPort > 0 And $iDestPort < 65535) Or _ Not ($iSourcePort >= 0 And $iSourcePort < 65535) Or _ Not ($iTimeOut >= 0) Then Return SetError(-4, 0, -1) ; invalid parameter StringRegExp($sIPAddr, "((?:\d{1,3}\.){3}\d{1,3})", 3) ;$STR_REGEXPARRAYGLOBALMATCH If @error Then Return SetError(-4, 0, -1) If $sSourceAddr <> "" Then StringRegExp($sSourceAddr, "((?:\d{1,3}\.){3}\d{1,3})", 3) ;$STR_REGEXPARRAYGLOBALMATCH If @error Then Return SetError(-4, 0, -1) EndIf Local $hWs2 = DllOpen("Ws2_32.dll") If @error Then Return SetError(-2, 0, -1) ;missing DLL Local $bError = 0, $nCode = 0 Local $tagSockAddr = "short sin_family; ushort sin_port; " & _ "STRUCT; ulong S_addr; ENDSTRUCT; " & _ ;sin_addr "char sin_zero[8]" Local $hSock = DllCall($hWs2, "uint", "socket", "int", 2, "int", 1, "int", 6); AF_INET, SOCK_STREAM, IPPROTO_TCP If @error Then $bError = -1 ElseIf ($hSock[0] = 4294967295) Or ($hSock[0] = -1) Then ;INVALID_SOCKET $bError = 1 Else $hSock = $hSock[0] EndIf If Not $bError Then $aRet = DllCall($hWs2, "ulong", "inet_addr", "str", $sIPAddr) If @error Then $bError = -1 ElseIf ($aRet[0] = -1) Or ($aRet[0] = 4294967295) Or ($aRet[0] = 0) Then ;INADDR_NONE or INADDR_ANY $bError = 1 Else $sIPAddr = $aRet[0] EndIf EndIf If Not $bError Then $aRet = DllCall($hWs2, "ushort", "htons", "ushort", $iDestPort) If @error Then $bError = -1 Else $iDestPort = $aRet[0] EndIf EndIf If (Not $bError) And ($sSourceAddr <> "") Then $aRet = DllCall($hWs2, "ulong", "inet_addr", "str", $sSourceAddr) If @error Then $bError = -1 ElseIf ($aRet[0] = -1) Or ($aRet[0] = 4294967295) Or ($aRet[0] = 0) Then ;INADDR_NONE or INADDR_ANY $bError = 1 Else $sSourceAddr = $aRet[0] EndIf EndIf If (Not $bError) And $iSourcePort Then $aRet = DllCall($hWs2, "ushort", "htons", "ushort", $iSourcePort) If @error Then $bError = -1 Else $iSourcePort = $aRet[0] EndIf EndIf If (Not $bError) And ($sSourceAddr Or $iSourcePort) Then $tSockAddr = DllStructCreate($tagSockAddr) DllStructSetData($tSockAddr, "sin_family", 2) ;AF_INET If $iSourcePort Then DllStructSetData($tSockAddr, "sin_port", $iSourcePort) Else DllStructSetData($tSockAddr, "sin_port", 0) EndIf If $sSourceAddr Then DllStructSetData($tSockAddr, "S_addr", $sSourceAddr) Else DllStructSetData($tSockAddr, "S_addr", 0x00000000) ;INADDR_ANY EndIf $aRet = DllCall($hWs2, "int", "bind", "uint", $hSock, "ptr", DllStructGetPtr($tSockAddr), "int", DllStructGetSize($tSockAddr)) If @error Then $bError = -1 ElseIf $aRet[0] <> 0 Then ;SOCKET_ERROR $bError = 1 EndIf $tSockAddr = 0 EndIf If Not $bError Then $aRet = DllCall($hWs2, "int", "ioctlsocket", "uint", $hSock, "long", 0x8004667e, "ulong*", 1) ;FIONBIO If @error Then $bError = -1 ElseIf $aRet[0] <> 0 Then ;SOCKET_ERROR $bError = 1 EndIf EndIf If Not $bError Then $tSockAddr = DllStructCreate($tagSockAddr) DllStructSetData($tSockAddr, "sin_family", 2) ;AF_INET DllStructSetData($tSockAddr, "sin_port", $iDestPort) DllStructSetData($tSockAddr, "S_addr", $sIPAddr) $aRet = DllCall($hWs2, "int", "connect", "uint", $hSock, "ptr", DllStructGetPtr($tSockAddr), "int", DllStructGetSize($tSockAddr)) If @error Then $bError = -1 ElseIf $aRet[0] <> 0 Then ;SOCKET_ERROR -> functional with connect() on non-blocking sockets $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $bError = -1 ElseIf ($aRet[0] <> 0) And ($aRet[0] <> 10035) Then ;WSAEWOULDBLOCK $bError = 1 EndIf EndIf $tSockAddr = 0 EndIf If Not $bError Then If $iTimeOut = 0 Then $iTimeOut = Opt("TCPTimeout") If $iTimeOut < 1 Then $iTimeOut = 100 Local $tagFd_set = "uint fd_count; uint fd_array[64]" Local $tFd_set_writefds = DllStructCreate($tagFd_set) DllStructSetData($tFd_set_writefds, "fd_count", 1) DllStructSetData($tFd_set_writefds, "fd_array", $hSock, 1) Local $tFd_set_exceptfds = DllStructCreate($tagFd_set) DllStructSetData($tFd_set_exceptfds, "fd_count", 1) DllStructSetData($tFd_set_exceptfds, "fd_array", $hSock, 1) Local $tTimeval = DllStructCreate("long tv_sec; long tv_usec") DllStructSetData($tTimeval, "tv_sec", Floor($iTimeOut / 1000)) DllStructSetData($tTimeval, "tv_usec", Round(Mod($iTimeOut, 1000) * 1000)) $aRet = DllCall($hWs2, "int", "select", _ "int", $hSock, "ptr", 0, "ptr", DllStructGetPtr($tFd_set_writefds), "ptr", DllStructGetPtr($tFd_set_exceptfds), "ptr", DllStructGetPtr($tTimeval)) If @error Then $bError = -1 ElseIf $aRet[0] = 0 Then ;time expired $bError = 1 $nCode = -6 ;timed out, similar to WSAETIMEDOUT ElseIf ($aRet[0] = -1) Or ($aRet[0] = 4294967295) Then ;SOCKET_ERROR $bError = 1 Else If Not (DllStructGetData($tFd_set_writefds, "fd_count") = 1) Then $bError = 1 If DllStructGetData($tFd_set_exceptfds, "fd_count") = 1 Then $tBuf = DllStructCreate("int") $aRet = DllCall("Ws2_32.dll", "int", "getsockopt", _ "uint", $hSock, "int", 0xffff, "int", 0x1007, "ptr", DllStructGetPtr($tBuf), "int*", DllStructGetSize($tBuf)) ;SO_ERROR If @error Then $bError = -1 ElseIf $aRet[0] = 0 Then $nCode = DllStructGetData($tBuf, 1) EndIf Else $nCode = -5 ;NOT_CONNECTED EndIf EndIf EndIf EndIf If $bError < 0 Then $nCode = -1 ;internal error $nReturn = -1 ;failure If $hSock Then TCPCloseSocket($hSock) ElseIf $bError > 0 Then If Not $nCode Then $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $nCode = -1 Else $nCode = $aRet[0] EndIf If $nCode = 0 Then $nCode = -3 ;undefined error EndIf $nReturn = -1 If $hSock Then TCPCloseSocket($hSock) Else $nReturn = $hSock EndIf DllClose($hWs2) Return SetError($nCode, 0, $nReturn) EndFunc ;==>_TCPConnect ; #MODIFIED WRAPPER# ============================================================================================================ ; Name...........: _TCPSend ; Description ...: Wrapper of _TCPSend function, see the guide. ; Syntax.........: _TCPSend($iMainsocket, $iData, $iFlag = 0) ; Parameters ....: $iMainsocket - The array as returned by _TCPAccept ; or the connected socket identifier (SocketID) as returned by _TCPConnect. ; $iData - Data sent. ; |Text or binary data ; $iFlag - values can be added together ; |$TCP_DATA_DEFAULT (0) - It doesn't add anything at the end of the string [Default] ; |$TCP_DATA_EOT (2) - It adds an End of Text ASCII character (Chr(3)) at the end of the string ; Return values .: see the guide. ; Author ........: j0kky ; Modified ......: 1.0.0 ; Remarks .......: If Unicode strings need to be transmitted they must be encoded/decoded with StringToBinary()/BinaryToString(). ; $iFlag = $TCP_DATA_EOT must be set in couple with _TCPRecv, so don't use it for external application ; Links .........: send: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740149(v=vs.85).aspx ; error codes: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx ; =============================================================================================================================== Func _TCPSend($iMainsocket, $iData, $iFlag = 0) If IsArray($iMainsocket) And (UBound($iMainsocket, 0) = 1) And (UBound($iMainsocket) > 0) Then $iMainsocket = $iMainsocket[0] If BitAND($iFlag, 2) = 2 Then $iData = String($iData) & Chr(3) $iResult = TCPSend($iMainsocket, $iData) Return SetError(@error, 0, $iResult) EndFunc ;==>_TCPSend ; #WRAPPER# ===================================================================================================================== Func _TCPNameToIP($sName) $iResult = TCPNameToIP($sName) Return SetError(@error, 0, $iResult) EndFunc ;==>_TCPNameToIP ; #FUNCTION# ==================================================================================================================== ; Name...........: _GetIps ; Description ...: Get local and public IP address of a network/computer ; Syntax.........: _GetIps($iServerName = "") ; Parameters ....: $iServerName - The server name which can retrieve your public IP ; |For example: "www.something.com/somethingelse" [Default = ""] ; Return values .: On success it returns an array: ; |[0] - Local IP (on LAN) of the adapter used to connect to Internet. ; |[1] - Public IP. ; On failure it returns -1 and sets @error to non zero: ; |-1 - internal error ; |-2 - missing DLL (Ws2_32.dll) ; |-3 - undefined error ; |-4 - invalid parameter (not used) ; |-5 - servers are offline ; |-6 - IP retrieving failed ; |Any Windows Socket Error Code retrieved by WSAGetLastError ; Author ........: j0kky ; Modified ......: 1.0.0 ; Remarks .......: It works with Winsock library, so it must be initialized with _TCPStartup(). ; Local and public IPs are both retrieved through internet. ; Links .........: error codes: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx ; =============================================================================================================================== Func _GetIps($iServerName = "") If $iServerName = Default Then $iServerName = "" $iServerName = String($iServerName) $iServerName = StringRegExpReplace($iServerName, "^http.?://", "") If StringInStr($iServerName, "/") Then If StringRegExp($iServerName, "/(.*)", 1)[0] Then If StringRight($iServerName, 1) = "/" Then $iServerName = StringTrimRight($iServerName, 1) EndIf Else $iServerName &= "/" EndIf If Not StringRegExp($iServerName, ".+\..{2,}") Then $iServerName = "" ; invalid parameter Local $hWs2 = DllOpen("Ws2_32.dll") If @error Then Return SetError(-2, 0, -1) ;missing DLL Local $bError = 0, $nCode = 0, $sLocalIP = "", $sPublicIP = "" Local $tagSockAddr = "short sin_family; ushort sin_port; " & _ "STRUCT; ulong S_addr; ENDSTRUCT; " & _ ;sin_addr "char sin_zero[8]" Local $hSock = DllCall($hWs2, "uint", "socket", "int", 2, "int", 1, "int", 6); AF_INET, SOCK_STREAM, IPPROTO_TCP If @error Then $bError = -1 ElseIf ($hSock[0] = 4294967295) Or ($hSock[0] = -1) Then ;INVALID_SOCKET $bError = 1 Else $hSock = $hSock[0] EndIf If Not $bError Then If $iServerName Then Local $aGetIPURL[][2] = [["www.myexternalip.com/raw"], ["checkip.dyndns.org/"], ["bot.whatismyipaddress.com/"], [$iServerName]], $nElements = 0 Else Local $aGetIPURL[][2] = [["www.myexternalip.com/raw"], ["checkip.dyndns.org/"], ["bot.whatismyipaddress.com/"]], $nElements = 0 EndIf For $i = 0 To (UBound($aGetIPURL) - 1) $sServerIp = TCPNameToIP(StringRegExp($aGetIPURL[$i][0], "(.*?)/", 1)[0]) If $sServerIp <> "" Then $aGetIPURL[$nElements][0] = $aGetIPURL[$i][0] $aGetIPURL[$nElements][1] = $sServerIp $nElements += 1 EndIf Next If $nElements Then ReDim $aGetIPURL[$nElements][2] Else $bError = 1 $nCode = -5 ;there is no valid server for checking IP EndIf EndIf If Not $bError Then $aRet = DllCall($hWs2, "ushort", "htons", "ushort", 80) If @error Then $bError = -1 Else $iDestPort = $aRet[0] EndIf EndIf If Not $bError Then For $i = 0 To (UBound($aGetIPURL) - 1) $sServerIp = $aGetIPURL[$i][1] If Not $bError Then $aRet = DllCall($hWs2, "int", "ioctlsocket", "uint", $hSock, "long", 0x8004667e, "ulong*", 1) ;FIONBIO If @error Then $bError = -1 ElseIf $aRet[0] <> 0 Then ;SOCKET_ERROR $bError = 1 EndIf EndIf If Not $bError Then $aRet = DllCall($hWs2, "ulong", "inet_addr", "str", $sServerIp) If @error Then $bError = -1 ElseIf ($aRet[0] = -1) Or ($aRet[0] = 4294967295) Or ($aRet[0] = 0) Then ;INADDR_NONE or INADDR_ANY $bError = 1 Else $sServerIp = $aRet[0] EndIf EndIf If Not $bError Then $tSockAddr = DllStructCreate($tagSockAddr) DllStructSetData($tSockAddr, "sin_family", 2) ;AF_INET DllStructSetData($tSockAddr, "sin_port", $iDestPort) DllStructSetData($tSockAddr, "S_addr", $sServerIp) $aRet = DllCall($hWs2, "int", "connect", "uint", $hSock, "ptr", DllStructGetPtr($tSockAddr), "int", DllStructGetSize($tSockAddr)) If @error Then $bError = -1 ElseIf $aRet[0] <> 0 Then ;SOCKET_ERROR -> functional with connect() on non-blocking sockets $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $bError = -1 ElseIf ($aRet[0] <> 0) And ($aRet[0] <> 10035) Then ;WSAEWOULDBLOCK $bError = 1 EndIf EndIf $tSockAddr = 0 EndIf If Not $bError Then Local $tagFd_set = "uint fd_count; uint fd_array[64]" Local $tFd_set_writefds = DllStructCreate($tagFd_set) DllStructSetData($tFd_set_writefds, "fd_count", 1) DllStructSetData($tFd_set_writefds, "fd_array", $hSock, 1) Local $tFd_set_exceptfds = DllStructCreate($tagFd_set) DllStructSetData($tFd_set_exceptfds, "fd_count", 1) DllStructSetData($tFd_set_exceptfds, "fd_array", $hSock, 1) Local $tTimeval = DllStructCreate("long tv_sec; long tv_usec") DllStructSetData($tTimeval, "tv_sec", Floor(500 / 1000)) DllStructSetData($tTimeval, "tv_usec", Round(Mod(500, 1000) * 1000)) $aRet = DllCall($hWs2, "int", "select", _ "int", $hSock, "ptr", 0, "ptr", DllStructGetPtr($tFd_set_writefds), "ptr", DllStructGetPtr($tFd_set_exceptfds), "ptr", DllStructGetPtr($tTimeval)) If @error Then $bError = -1 ElseIf ($aRet[0] = 0) Or ($aRet[0] = -1) Or ($aRet[0] = 4294967295) Then $bError = 1 Else If Not (DllStructGetData($tFd_set_writefds, "fd_count") = 1) Then $bError = 1 EndIf EndIf If Not $bError And Not $sLocalIP Then $tSockAddr = DllStructCreate($tagSockAddr) $aRet = DllCall($hWs2, "int", "getsockname", "uint", $hSock, "ptr", DllStructGetPtr($tSockAddr), "int*", DllStructGetSize($tSockAddr)) If @error Then $bError = -1 ElseIf $aRet[0] <> 0 Then ;SOCKET_ERROR $bError = 1 Else $aRet = DllCall($hWs2, "ptr", "inet_ntoa", "ulong", DllStructGetData($tSockAddr, "S_addr")) If @error Then $bError = -1 ElseIf $aRet[0] = Null Then $bError = 1 Else $sLocalIP = DllStructGetData(DllStructCreate("char[15]", $aRet[0]), 1) ;IP address EndIf EndIf $tSockAddr = 0 EndIf If Not $bError Then $sRequest = "GET /" & StringRegExp($aGetIPURL[$i][0], "/(.*)", 1)[0] & " HTTP/1.1" & @CRLF & _ "Host: " & StringRegExp($aGetIPURL[$i][0], "(.*?)/", 1)[0] & @CRLF & _ "Connection: close" & @CRLF & @CRLF TCPSend($hSock, $sRequest) Local $sRecv = "", $hTimer = TimerInit() While 1 $sRecv &= _TCPRecv($hSock, 2048) If @error Or @extended Then If @error Then $bError = 1 ExitLoop EndIf If TimerDiff($hTimer) > 2500 Then ExitLoop Sleep(10) WEnd EndIf If Not $bError Then $aPublicIP = StringRegExp($sRecv, "((?:\d{1,3}\.){3}\d{1,3})", 3) ;STR_REGEXPARRAYGLOBALMATCH If Not @error Then $sPublicIP = $aPublicIP[0] ExitLoop Else $bError = 1 EndIf EndIf If $bError And $i = (UBound($aGetIPURL) - 1) Then $nCode = -6 ExitLoop Else $bError = 0 $nCode = 0 TCPCloseSocket($hSock) EndIf Local $hSock = DllCall($hWs2, "uint", "socket", "int", 2, "int", 1, "int", 6); AF_INET, SOCK_STREAM, IPPROTO_TCP If @error Then $bError = -1 ElseIf ($hSock[0] = 4294967295) Or ($hSock[0] = -1) Then ;INVALID_SOCKET $bError = 1 Else $hSock = $hSock[0] EndIf Next EndIf If $bError < 0 Then $nCode = -1 ;internal error $nReturn = -1 ;failure ElseIf $bError > 0 Then If Not $nCode Then $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $nCode = -1 Else $nCode = $aRet[0] EndIf If $nCode = 0 Then $nCode = -3 ;undefined error EndIf $nReturn = -1 Else Local $nReturn[2] = [$sLocalIP, $sPublicIP] EndIf If $hSock Then TCPCloseSocket($hSock) DllClose($hWs2) Return SetError($nCode, 0, $nReturn) EndFunc ;==>_GetIps ; #MODIFIED WRAPPER# ============================================================================================================ ; Name...........: _TCPCloseSocket ; Description ...: Wrapper of TCPCloseSocket function, see the guide. ; Syntax.........: _TCPCloseSocket($iMainsocket) ; Parameters ....: $iMainsocket - The array as returned by _TCPAccept ; or the connected socket identifier (SocketID) as returned by _TCPListen and _TCPConnect. ; Return values .: see the guide. ; Author ........: j0kky ; Modified ......: 1.0.0 ; Links .........: recv: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740121(v=vs.85).aspx ; error codes: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx ; =============================================================================================================================== Func _TCPCloseSocket($iMainsocket) If IsArray($iMainsocket) And (UBound($iMainsocket, 0) = 1) And (UBound($iMainsocket) > 0) Then $iMainsocket = $iMainsocket[0] $iResult = TCPCloseSocket($iMainsocket) Return SetError(@error, 0, $iResult) EndFunc ;==>_TCPCloseSocket ; #WRAPPER# ===================================================================================================================== Func _TCPShutdown() $iResult = TCPShutdown() Return SetError(@error, 0, $iResult) EndFunc ;==>_TCPShutdown ; #WRAPPER# ===================================================================================================================== Func _UDPStartup() $iResult = UDPStartup() Return SetError(@error, 0, $iResult) EndFunc ;==>_UDPStartup ; #FUNCTION# ==================================================================================================================== ; Name...........: _UDPBind ; Description ...: Creates and bind a socket to a local IP and a local port. ; Syntax.........: _UDPBind($sSourceAddr = "", $iSourcePort = 0) ; Parameters ....: $sSourceAddr - Source IP ; |Internet Protocol dotted address(IpV4) as "192.162.1.1". [Default = ""] ; $iSourcePort - Source port. ; |1 : 65534 - port on which the created socket will be bind (on the local PC). [Default = 0] ; Return values .: On success it returns the main socket identifier. ; |Any value > 0 ; On failure it returns -1 and sets @error to non zero: ; |-1 - internal error ; |-2 - missing DLL (Ws2_32.dll) ; |-3 - undefined error ; |-4 - invalid parameter ; |Any Windows Socket Error Code retrieved by WSAGetLastError ; Author ........: j0kky ; Modified ......: 1.0.0 ; Remarks .......: It could be used before both of _UDPSendTo (client app) and _UDPRecvFrom (server app) functions ; Links .........: bind: https://msdn.microsoft.com/en-us/library/windows/desktop/ms737550(v=vs.85).aspx ; error codes: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx ; =============================================================================================================================== Func _UDPBind($sSourceAddr = "", $iSourcePort = 0) If $sSourceAddr = Default Then $sSourceAddr = "" If $iSourcePort = Default Then $iSourcePort = 0 $sSourceAddr = String($sSourceAddr) $iSourcePort = Number($iSourcePort) If Not ($iSourcePort >= 0 And $iSourcePort < 65535) Then Return SetError(-4, 0, -1) ; invalid parameter If $sSourceAddr <> "" Then StringRegExp($sSourceAddr, "((?:\d{1,3}\.){3}\d{1,3})", 3) ;$STR_REGEXPARRAYGLOBALMATCH If @error Then Return SetError(-4, 0, -1) EndIf Local $hWs2 = DllOpen("Ws2_32.dll") If @error Then Return SetError(-2, 0, -1) ;missing DLL Local $bError = 0, $nCode = 0 Local $tagSockAddr = "short sin_family; ushort sin_port; " & _ "STRUCT; ulong S_addr; ENDSTRUCT; " & _ ;sin_addr "char sin_zero[8]" Local $hSock = DllCall($hWs2, "uint", "socket", "int", 2, "int", 2, "int", 17); AF_INET, SOCK_DGRAM, IPPROTO_UDP If @error Then $bError = -1 ElseIf ($hSock[0] = 4294967295) Or ($hSock[0] = -1) Then ;INVALID_SOCKET $bError = 1 Else $hSock = $hSock[0] EndIf If (Not $bError) And ($sSourceAddr <> "") Then $aRet = DllCall($hWs2, "ulong", "inet_addr", "str", $sSourceAddr) If @error Then $bError = -1 ElseIf ($aRet[0] = -1) Or ($aRet[0] = 4294967295) Or ($aRet[0] = 0) Then ;INADDR_NONE or INADDR_ANY $bError = 1 Else $sSourceAddr = $aRet[0] EndIf EndIf If (Not $bError) And $iSourcePort Then $aRet = DllCall($hWs2, "ushort", "htons", "ushort", $iSourcePort) If @error Then $bError = -1 Else $iSourcePort = $aRet[0] EndIf EndIf If Not $bError Then $tSockAddr = DllStructCreate($tagSockAddr) DllStructSetData($tSockAddr, "sin_family", 2) ;AF_INET If $iSourcePort Then DllStructSetData($tSockAddr, "sin_port", $iSourcePort) Else DllStructSetData($tSockAddr, "sin_port", 0) EndIf If $sSourceAddr Then DllStructSetData($tSockAddr, "S_addr", $sSourceAddr) Else DllStructSetData($tSockAddr, "S_addr", 0x00000000) ;INADDR_ANY EndIf $aRet = DllCall($hWs2, "int", "bind", "uint", $hSock, "ptr", DllStructGetPtr($tSockAddr), "int", DllStructGetSize($tSockAddr)) If @error Then $bError = -1 ElseIf $aRet[0] <> 0 Then ;SOCKET_ERROR $bError = 1 EndIf $tSockAddr = 0 EndIf If $bError < 0 Then $nCode = -1 ;internal error $nReturn = -1 ;failure If $hSock Then UDPCloseSocket($hSock) ElseIf $bError > 0 Then If Not $nCode Then $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $nCode = -1 Else $nCode = $aRet[0] EndIf If $nCode = 0 Then $nCode = -3 ;undefined error EndIf $nReturn = -1 If $hSock Then UDPCloseSocket($hSock) Else $nReturn = $hSock EndIf DllClose($hWs2) Return SetError($nCode, 0, $nReturn) EndFunc ;==>_UDPBind ; #FUNCTION# ==================================================================================================================== ; Name...........: _UDPSendTo ; Description ...: Sends data to an address/port, it uses a socket created by _UDPBind or it creates a socket itself ; Syntax.........: _UDPSendTo($sIPAddr, $iDestPort, $iData, $iMainsocket = 0) ; Parameters ....: $sIPAddr - Destination IP. ; |Internet Protocol dotted address(IpV4) as "192.162.1.1". ; $iDestPort - Destination port. ; |1 : 65534 - port which the created socket will connect on. ; $iData - Data sent. ; |Text or binary data ; $iMainsocket - Main socket identifier returned by _UDPBind. ; |Any value > 0 [Default = 0] ; Return values .: On success it returns an array: ; |[0] - The number of bytes sent. ; |[1] - The main socket identifier used. ; On failure it returns -1 and sets @error to non zero: ; |-1 - internal error ; |-2 - missing DLL (Ws2_32.dll) ; |-3 - undefined error ; |-4 - invalid parameter ; |Any Windows Socket Error Code retrieved by WSAGetLastError ; Author ........: j0kky ; Modified ......: 1.0.0 ; Links .........: sendto: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740148(v=vs.85).aspx ; error codes: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx ; =============================================================================================================================== Func _UDPSendTo($sIPAddr, $iDestPort, $iData, $iMainsocket = 0) If $iMainsocket = Default Then $iMainsocket = 0 $iMainsocket = Number($iMainsocket) $sIPAddr = String($sIPAddr) $iDestPort = Number($iDestPort) If Not IsBinary($iData) Then $iData = String($iData) If Not ($iDestPort > 0 And $iDestPort < 65535) Or _ $iMainsocket < 0 Then Return SetError(-4, 0, -1) ; invalid parameter StringRegExp($sIPAddr, "((?:\d{1,3}\.){3}\d{1,3})", 3) ;$STR_REGEXPARRAYGLOBALMATCH If @error Then Return SetError(-4, 0, -1) Local $hWs2 = DllOpen("Ws2_32.dll") If @error Then Return SetError(-2, 0, -1) ;missing DLL Local $bError = 0, $nCode = 0 Local $tagSockAddr = "short sin_family; ushort sin_port; " & _ "STRUCT; ulong S_addr; ENDSTRUCT; " & _ ;sin_addr "char sin_zero[8]" If Not $iMainsocket Then Local $aRet = DllCall($hWs2, "uint", "socket", "int", 2, "int", 2, "int", 17); AF_INET, SOCK_DGRAM, IPPROTO_UDP If @error Then $bError = -1 ElseIf ($aRet[0] = 4294967295) Or ($aRet[0] = -1) Then ;INVALID_SOCKET $bError = 1 Else $iMainsocket = $aRet[0] EndIf EndIf If Not $bError Then $aRet = DllCall($hWs2, "ulong", "inet_addr", "str", $sIPAddr) If @error Then $bError = -1 ElseIf ($aRet[0] = -1) Or ($aRet[0] = 4294967295) Or ($aRet[0] = 0) Then ;INADDR_NONE or INADDR_ANY $bError = 1 Else $sIPAddr = $aRet[0] EndIf EndIf If Not $bError Then $aRet = DllCall($hWs2, "ushort", "htons", "ushort", $iDestPort) If @error Then $bError = -1 Else $iDestPort = $aRet[0] EndIf EndIf If Not $bError Then $aRet = DllCall($hWs2, "int", "ioctlsocket", "uint", $iMainsocket, "long", 0x8004667e, "ulong*", 1) ;FIONBIO If @error Then $bError = -1 ElseIf $aRet[0] <> 0 Then ;SOCKET_ERROR $bError = 1 EndIf EndIf If Not $bError Then Local $tSockAddr = DllStructCreate($tagSockAddr) DllStructSetData($tSockAddr, "sin_family", 2) ;AF_INET DllStructSetData($tSockAddr, "sin_port", $iDestPort) DllStructSetData($tSockAddr, "S_addr", $sIPAddr) Local $nLenght, $tBuf If IsBinary($iData) Then $nLenght = BinaryLen($iData) $tBuf = DllStructCreate("byte[" & $nLenght & "]") DllStructSetData($tBuf, 1, $iData) Else $nLenght = StringLen($iData) $tBuf = DllStructCreate("char[" & $nLenght & "]") DllStructSetData($tBuf, 1, $iData) EndIf $aRet = DllCall($hWs2, "int", "sendto", _ "uint", $iMainsocket, "ptr", DllStructGetPtr($tBuf), "int", $nLenght, "int", 0, "ptr", DllStructGetPtr($tSockAddr), "int", DllStructGetSize($tSockAddr)) If @error Then $bError = -1 ElseIf ($aRet[0] = -1) Or ($aRet[0] = 4294967295) Then ;SOCKET_ERROR $bError = 1 Else Local $aReturn[2] = [$aRet[0], $iMainsocket] EndIf EndIf If $bError < 0 Then $nCode = -1 ;internal error $nReturn = -1 ;failure ElseIf $bError > 0 Then If Not $nCode Then $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $nCode = -1 Else $nCode = $aRet[0] EndIf If $nCode = 0 Then $nCode = -3 ;undefined error EndIf $nReturn = -1 Else $nReturn = $aReturn EndIf DllClose($hWs2) Return SetError($nCode, 0, $nReturn) EndFunc ;==>_UDPSendTo ; #FUNCTION# ==================================================================================================================== ; Name...........: _UDPRecvFrom ; Description ...: Receives data from a bound socket on the local PC. ; Syntax.........: _UDPRecvFrom($iMainsocket, $iMaxLen, $iFlag = 0) ; Parameters ....: $iMainsocket - Main socket identifier. ; |Any value > 0 ; $iMaxLen - Max # of characters to receive (usually 2048). ; $iFlag ; |0 - Text data. [Default] ; |1 - Binary data. ; Return values .: On success it returns an array: ; |[0] - The data received. ; |[1] - The IP address of the sender. ; |[2] - The port used by the sender for connection. ; On failure it returns -1 and sets @error to non zero: ; |-1 - internal error ; |-2 - missing DLL (Ws2_32.dll) ; |-3 - undefined error ; |-4 - invalid parameter ; |Any Windows Socket Error Code retrieved by WSAGetLastError ; Author ........: j0kky ; Modified ......: 1.0.0 ; Links .........: recvfrom: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740120(v=vs.85).aspx ; error codes: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx ; =============================================================================================================================== Func _UDPRecvFrom($iMainsocket, $iMaxLen, $iFlag = 0) If $iFlag = Default Then $iFlag = 0 $iMainsocket = Number($iMainsocket) $iMaxLen = Number($iMaxLen) $iFlag = Number($iFlag) If $iMainsocket < 0 Or _ $iMaxLen < 1 Or _ Not ($iFlag = 0 Or $iFlag = 1) Then Return SetError(-4, 0, -1) ; invalid parameter Local $hWs2 = DllOpen("Ws2_32.dll") If @error Then Return SetError(-2, 0, -1) ;missing DLL Local $bError = 0, $nCode = 0 Local $tagSockAddr = "short sin_family; ushort sin_port; " & _ "STRUCT; ulong S_addr; ENDSTRUCT; " & _ ;sin_addr "char sin_zero[8]" If Not $bError Then $aRet = DllCall($hWs2, "int", "ioctlsocket", "uint", $iMainsocket, "long", 0x8004667e, "ulong*", 1) ;FIONBIO If @error Then $bError = -1 ElseIf $aRet[0] <> 0 Then ;SOCKET_ERROR $bError = 1 EndIf EndIf Local $tSockAddr = DllStructCreate($tagSockAddr) Local $tBuf If $iFlag Then $tBuf = DllStructCreate("byte[" & $iMaxLen & "]") Else $tBuf = DllStructCreate("char[" & $iMaxLen & "]") EndIf $aRet = DllCall($hWs2, "int", "recvfrom", _ "uint", $iMainsocket, "ptr", DllStructGetPtr($tBuf), "int", $iMaxLen, "int", 0, "ptr", DllStructGetPtr($tSockAddr), "int*", DllStructGetSize($tSockAddr)) If @error Then $bError = -1 ElseIf ($aRet[0] = -1) Or ($aRet[0] = 4294967295) Then ;SOCKET_ERROR $bError = 1 $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $bError = -1 ElseIf $aRet[0] = 0 Or $aRet[0] = 10035 Then ;WSAEWOULDBLOCK $nCode = -10 ;internal function value, it means no error EndIf Else Local $aResult[3] = [DllStructGetData($tBuf, 1)] ;data $aRet = DllCall($hWs2, "ptr", "inet_ntoa", "ulong", DllStructGetData($tSockAddr, "S_addr")) If @error Then $bError = -1 ElseIf $aRet[0] = Null Then $bError = 1 Else $aResult[1] = DllStructGetData(DllStructCreate("char[15]", $aRet[0]), 1) ;IP address $aRet = DllCall($hWs2, "ushort", "ntohs", "ushort", DllStructGetData($tSockAddr, "sin_port")) If @error Then $bError = -1 Else $aResult[2] = $aRet[0] ;port EndIf EndIf EndIf If $bError < 0 Then $nCode = -1 ;internal error $nReturn = -1 ;failure ElseIf $bError > 0 Then If Not $nCode Then $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $nCode = -1 Else $nCode = $aRet[0] EndIf If $nCode = 0 Then $nCode = -3 ;undefined error EndIf If $nCode = -10 Then $nCode = 0 $nReturn = -1 Else $nReturn = $aResult EndIf DllClose($hWs2) Return SetError($nCode, 0, $nReturn) EndFunc ;==>_UDPRecvFrom ; #FUNCTION# ==================================================================================================================== ; Name...........: _UDPCloseSocket ; Description ...: Close a UDP socket. ; Syntax.........: _UDPCloseSocket($iMainsocket) ; Parameters ....: $iMainsocket - Main socket identifier returned by _UDPBind or the array returned by _UDPSendTo. ; |Any value > 0 ; Return values .: On success it returns 1. ; On failure it returns -1 and sets @error to non zero: ; |-1 - internal error ; |-2 - missing DLL (Ws2_32.dll) ; |-3 - undefined error ; |-4 - invalid parameter ; |Any Windows Socket Error Code retrieved by WSAGetLastError ; Author ........: j0kky ; Modified ......: 1.0.0 ; Links .........: closesocket: https://msdn.microsoft.com/en-us/library/windows/desktop/ms737582(v=vs.85).aspx ; error codes: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx ; =============================================================================================================================== Func _UDPCloseSocket($iMainsocket) If IsArray($iMainsocket) Then If Not ((UBound($iMainsocket, 0) = 1) And (UBound($iMainsocket) = 2)) Then Return SetError(-1, 0, -4) $iMainsocket = $iMainsocket[1] Else If $iMainsocket < 1 Then Return SetError(-1, 0, -4) EndIf Local $hWs2 = DllOpen("Ws2_32.dll") If @error Then Return SetError(-2, 0, -1) ;missing DLL Local $bError = 0, $nCode = 0 $aRet = DllCall($hWs2, "int", "closesocket", "uint", $iMainsocket) If @error Then $bError = -1 ElseIf $aRet[0] <> 0 Then ;SOCKET_ERROR $bError = 1 EndIf If $bError < 0 Then $nCode = -1 ;internal error $nReturn = -1 ;failure ElseIf $bError > 0 Then If Not $nCode Then $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $nCode = -1 Else $nCode = $aRet[0] EndIf If $nCode = 0 Then $nCode = -3 ;undefined error EndIf $nReturn = -1 Else $nReturn = 1 EndIf DllClose($hWs2) Return SetError($nCode, 0, $nReturn) EndFunc ;==>_UDPCloseSocket ; #WRAPPER# ===================================================================================================================== Func _UDPShutdown() $iResult = UDPShutdown() Return SetError(@error, 0, $iResult) EndFunc ;==>_UDPShutdown Obviously there can be a lot of errors, so please report here any problem\suggestion! Updated to: 11/01/16 winsock.zip
    1 point
  37. Hi everseeker, Yes, you can set the zoom level using execWB() #include <IE.au3> $OLECMDID_OPTICAL_ZOOM = 63 $OLECMDEXECOPT_DONTPROMPTUSER = 2 $oIE = _IECreate('www.google.com') $oIE.execWB($OLECMDID_OPTICAL_ZOOM, $OLECMDEXECOPT_DONTPROMPTUSER, 150)
    1 point
  38. I'm pretty sure that people who run into the same problem will still appreciate it. I would have done so if I could have found a solution to this problem.
    1 point
×
×
  • Create New...