
JiBe
-
Posts
30 -
Joined
-
Last visited
Reputation Activity
-
JiBe got a reaction from Trong in UDF SSH
Hi to all,
I only am accustomed pas has posted on the forum (coz, I'm french). But I use it a lot.
So first of all, thank you all to participate in the evolution of this wonderful product.
Today is not one day like any other, I myself am decide has posted a UDF that I myself create and developed (there may be some bug) for some months.
So here it is:
This UDF allows to use the SSH protocol very easily in your code.
It uses the syntax as the TCPxxx() function.
Your code will be easier to convert :-).
excused my English, I'm French.
Example:
#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.4.0 Author: Joseph Barone 2010-2015 Script Function: Modele pour l'utilisation de la fonction ssh (plink). #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include #include #include #include #include #include "SSH_udf.au3" _SSHStartup() Global $butt[6] $Gui = GUICreate("SSH Console",550,400) $label1 = GUICtrlCreateLabel("Adresse IP:",10,10,150,20) ; ip $input1 = GUICtrlCreateInput("",10,25,150,20) ; ip $label2 = GUICtrlCreateLabel("Tcp port:",170,10,150,20) ; port $input2 = GUICtrlCreateInput("",170,25,60,20) ; port $label6 = GUICtrlCreateLabel("Protocol:",240,10,40,20) ; port $input6 = GUICtrlCreateInput("ssh",240,25,60,20) ; port $butt[0] = GUICtrlCreateButton("Connect0",310,5,80,20,$BS_DEFPUSHBUTTON) $butt[1] = GUICtrlCreateButton("Connect1",390,5,80,20) $butt[2] = GUICtrlCreateButton("Connect2",470,5,80,20) $butt[3] = GUICtrlCreateButton("Connect3",310,25,80,20) $butt[4] = GUICtrlCreateButton("Connect4",390,25,80,20) $butt[5] = GUICtrlCreateButton("Connect5",470,25,80,20) $Checkbox = GUICtrlCreateCheckbox("RSA, Fingerprint, Alert AutoValidate", 330, 45, 205, 25) $label4 = GUICtrlCreateLabel("Login:",10,45,150,20) ; login $input4 = GUICtrlCreateInput("",10,60,150,20) ; login $label5 = GUICtrlCreateLabel("Mot de passe:",170,45,150,20) ; password $input5 = GUICtrlCreateInput("",170,60,150,20,$ES_PASSWORD) ; password $label3 = GUICtrlCreateLabel("Commande a envoyer:",10,85,150,20) ; send command $input3 = GUICtrlCreateInput("",10,100,310,20) ; send commande vers l'hote $butt2 = GUICtrlCreateButton("Send",330,100,80,20,$BS_DEFPUSHBUTTON) GUICtrlSetState($butt2,$GUI_DISABLE) $edit = GUICtrlCreateEdit("",10,130,530,260,$WS_VSCROLL);,$WS_DISABLED)) GUISetState() Global $ConnectedSocket[6] = [-1,-1,-1,-1,-1,-1] Global $msg, $recv, $ret ; GUI Message Loop ;============================================== While 1 $nmsg = GUIGetMsg() If $nmsg = $GUI_EVENT_CLOSE Then ExitLoop ;;; connect part: $b = 0 While 1 If $nMsg = $butt[$b] Then If GUICtrlRead($butt[$b]) = "Connect"&$b Then _SSHParametreSet("yesall",GUICtrlRead($Checkbox)) _SSHParametreSet("protocol",GUICtrlRead($input6)) _SSHParametreSet("login",GUICtrlRead($input4)) _SSHParametreSet("passwd",GUICtrlRead($input5)) $ConnectedSocket[$b] = _SSHConnect(GUICtrlRead($input1),GUICtrlRead($input2)) If $ConnectedSocket[$b] = 0 Then MsgBox(0,"Erreur", "Impossible de ce connecter!!") Else GUICtrlSetData($butt[$b],"Close"&$b GUICtrlSetState($butt2,$GUI_ENABLE) EndIf DisplayArray($_config) ConsoleWrite("nb config:"&$_nbconf&@CRLF) Else _SSHCloseSocket($ConnectedSocket[$b]) GUICtrlSetData($butt[$b],"Connect"&$b GUICtrlSetState($butt2,$GUI_DISABLE) DisplayArray($_config) ConsoleWrite("nb config:"&$_nbconf&@CRLF) EndIf EndIf ;;; send part: If $nMsg = $butt2 Then $ret = _SSHSend( $ConnectedSocket[$b] , GUICtrlRead($input3)&@crlf) GUICtrlSetData($input3,"") GUICtrlSetState($input3,$GUI_FOCUS) EndIf ;;; receive part: $recv = _SSHRecv( $ConnectedSocket[$b]) If $recv <> "" Then GUICtrlSetData($edit, GUICtrlRead($edit) & $recv ) EndIf GUICtrlSendMsg($edit, $EM_SCROLL, $SB_PAGEDOWN, 0) $b += 1 If $b = UBound($butt) Then ExitLoop WEnd WEnd _SSHCloseSocket($ConnectedSocket) _SSHShutdown() Exit Func DisplayArray($array) $i = 0 $j = 0 if UBound($array,1) = 0 Then Return While 1 ConsoleWrite("(["&UBound($array,1)&"]["&UBound($array,2)&"]) ") While 1 ConsoleWrite("["&$j&"]"&$array[$i][$j]&" ") $j += 1 if UBound($array,2)<=$j Then ExitLoop WEnd ConsoleWrite(@CRLF) $i += 1 $j = 0 if UBound($array,1)<=$i Then ExitLoop WEnd EndFunc
I join with UDF version of modified putty myself. 🙂 LoL
but, it is not used with the UDF, it is included in the UDF.
putty-04012015- 92453+lic.zip
ssh_udf.zip
New version (contains the latest version of plink (0.74) edited by http://jakub.kotrla.net/putty/)
ssh_udf-v2.zip
Same as the v2 but supports all putty/plink settings
ssh_udf-v2.1.zip
-
JiBe reacted to AZJIO in PureAutoIt machine code compiler small executable
IniWrite uses CreatePreferences. This is wrong, as CreatePreferences creates an empty file and will destroy all preferences, leaving only one.
MsgBox - you are using WinAPI, but you can use the original MessageRequester() function, then you get cross-platform code.
StringIsDigit uses PCRE for you, but I gave you a function without using PCRE. Using PCRE adds 150 KB to the size of the executable. In this case, your file size will be almost the same as that of AutoIt3.
FindPartialWindow() - why are you creating the t$=Space(999) variable inside the loop. This can be done 1 time outside the loop.
Run()
EnableExplicit Structure String2 key.s exec.s EndStructure ; modified function by reference to extract parameters and executable ; https://www.cyberforum.ru/pure-basic/thread3028721.html#post16492165 Procedure.s CmdLineRaw(*res.String2) Protected pos, Char.s pos = FindString(*res\exec, Chr(34), 1) If pos = 1 ; if you find a quote in the first character, then Char=quote, it means the path with spaces Char = Chr(34) Else Char = " " EndIf pos = FindString(*res\exec, Char, 2) ; looking for separator Char from the second character If pos > 0 pos + 1 If Mid(*res\exec, pos, 1) = " " pos + 1 EndIf ; found "pos" - the real position of the beginning of the com line *res\key = Right(*res\exec, Len(*res\exec) - pos + 1) ; options *res\exec = Left(*res\exec, pos - 1) ; executable EndIf EndProcedure Procedure Run(program.s, workdir.s = "", show_flag = 0, opt_flag = 0) Protected res.String2 res\exec = program res\key = "" CmdLineRaw(@res) show_flag & opt_flag ; I didn't check the flags ProcedureReturn RunProgram(res\exec, res\key, workdir, show_flag) EndProcedure ; Run(~"Explorer.exe /Select,\"C:\\Windows\\INF\"") Run("notepad.exe C:\Windows\system.ini") ; Run("cmd.exe /c (@Echo off & @Echo. & Color 1e & chkdsk.exe Z: /F /X& set /p Ok=^>^>)")
-
JiBe got a reaction from mLipok in UDF SSH
Hi to all,
I only am accustomed pas has posted on the forum (coz, I'm french). But I use it a lot.
So first of all, thank you all to participate in the evolution of this wonderful product.
Today is not one day like any other, I myself am decide has posted a UDF that I myself create and developed (there may be some bug) for some months.
So here it is:
This UDF allows to use the SSH protocol very easily in your code.
It uses the syntax as the TCPxxx() function.
Your code will be easier to convert :-).
excused my English, I'm French.
Example:
#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.4.0 Author: Joseph Barone 2010-2015 Script Function: Modele pour l'utilisation de la fonction ssh (plink). #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include #include #include #include #include #include "SSH_udf.au3" _SSHStartup() Global $butt[6] $Gui = GUICreate("SSH Console",550,400) $label1 = GUICtrlCreateLabel("Adresse IP:",10,10,150,20) ; ip $input1 = GUICtrlCreateInput("",10,25,150,20) ; ip $label2 = GUICtrlCreateLabel("Tcp port:",170,10,150,20) ; port $input2 = GUICtrlCreateInput("",170,25,60,20) ; port $label6 = GUICtrlCreateLabel("Protocol:",240,10,40,20) ; port $input6 = GUICtrlCreateInput("ssh",240,25,60,20) ; port $butt[0] = GUICtrlCreateButton("Connect0",310,5,80,20,$BS_DEFPUSHBUTTON) $butt[1] = GUICtrlCreateButton("Connect1",390,5,80,20) $butt[2] = GUICtrlCreateButton("Connect2",470,5,80,20) $butt[3] = GUICtrlCreateButton("Connect3",310,25,80,20) $butt[4] = GUICtrlCreateButton("Connect4",390,25,80,20) $butt[5] = GUICtrlCreateButton("Connect5",470,25,80,20) $Checkbox = GUICtrlCreateCheckbox("RSA, Fingerprint, Alert AutoValidate", 330, 45, 205, 25) $label4 = GUICtrlCreateLabel("Login:",10,45,150,20) ; login $input4 = GUICtrlCreateInput("",10,60,150,20) ; login $label5 = GUICtrlCreateLabel("Mot de passe:",170,45,150,20) ; password $input5 = GUICtrlCreateInput("",170,60,150,20,$ES_PASSWORD) ; password $label3 = GUICtrlCreateLabel("Commande a envoyer:",10,85,150,20) ; send command $input3 = GUICtrlCreateInput("",10,100,310,20) ; send commande vers l'hote $butt2 = GUICtrlCreateButton("Send",330,100,80,20,$BS_DEFPUSHBUTTON) GUICtrlSetState($butt2,$GUI_DISABLE) $edit = GUICtrlCreateEdit("",10,130,530,260,$WS_VSCROLL);,$WS_DISABLED)) GUISetState() Global $ConnectedSocket[6] = [-1,-1,-1,-1,-1,-1] Global $msg, $recv, $ret ; GUI Message Loop ;============================================== While 1 $nmsg = GUIGetMsg() If $nmsg = $GUI_EVENT_CLOSE Then ExitLoop ;;; connect part: $b = 0 While 1 If $nMsg = $butt[$b] Then If GUICtrlRead($butt[$b]) = "Connect"&$b Then _SSHParametreSet("yesall",GUICtrlRead($Checkbox)) _SSHParametreSet("protocol",GUICtrlRead($input6)) _SSHParametreSet("login",GUICtrlRead($input4)) _SSHParametreSet("passwd",GUICtrlRead($input5)) $ConnectedSocket[$b] = _SSHConnect(GUICtrlRead($input1),GUICtrlRead($input2)) If $ConnectedSocket[$b] = 0 Then MsgBox(0,"Erreur", "Impossible de ce connecter!!") Else GUICtrlSetData($butt[$b],"Close"&$b GUICtrlSetState($butt2,$GUI_ENABLE) EndIf DisplayArray($_config) ConsoleWrite("nb config:"&$_nbconf&@CRLF) Else _SSHCloseSocket($ConnectedSocket[$b]) GUICtrlSetData($butt[$b],"Connect"&$b GUICtrlSetState($butt2,$GUI_DISABLE) DisplayArray($_config) ConsoleWrite("nb config:"&$_nbconf&@CRLF) EndIf EndIf ;;; send part: If $nMsg = $butt2 Then $ret = _SSHSend( $ConnectedSocket[$b] , GUICtrlRead($input3)&@crlf) GUICtrlSetData($input3,"") GUICtrlSetState($input3,$GUI_FOCUS) EndIf ;;; receive part: $recv = _SSHRecv( $ConnectedSocket[$b]) If $recv <> "" Then GUICtrlSetData($edit, GUICtrlRead($edit) & $recv ) EndIf GUICtrlSendMsg($edit, $EM_SCROLL, $SB_PAGEDOWN, 0) $b += 1 If $b = UBound($butt) Then ExitLoop WEnd WEnd _SSHCloseSocket($ConnectedSocket) _SSHShutdown() Exit Func DisplayArray($array) $i = 0 $j = 0 if UBound($array,1) = 0 Then Return While 1 ConsoleWrite("(["&UBound($array,1)&"]["&UBound($array,2)&"]) ") While 1 ConsoleWrite("["&$j&"]"&$array[$i][$j]&" ") $j += 1 if UBound($array,2)<=$j Then ExitLoop WEnd ConsoleWrite(@CRLF) $i += 1 $j = 0 if UBound($array,1)<=$i Then ExitLoop WEnd EndFunc
I join with UDF version of modified putty myself. 🙂 LoL
but, it is not used with the UDF, it is included in the UDF.
putty-04012015- 92453+lic.zip
ssh_udf.zip
New version (contains the latest version of plink (0.74) edited by http://jakub.kotrla.net/putty/)
ssh_udf-v2.zip
Same as the v2 but supports all putty/plink settings
ssh_udf-v2.1.zip
-
JiBe reacted to faldo in RDP antihammer/blacklist generator
Hi,
I thought i'd share a small script that scans your Windows Eventlog and generates a blacklist/firewall block rule of IPs that tries to hammer your RDP connection with wrong credentials. Yes, i know it's not best practice to have RDP open to the internet but sometimes it's just more practical. I havn't had time to create a loop in the script itself but you can run it in windows scheduler with a 10 minute recurrence.
This is a quick and dirty solution and for those that like the idea, please feel free to improve/tidy the code.
#RequireAdmin #include <Date.au3> #include <array.au3> #include <File.au3> Global $IpListFile = @scriptdir &"\RdpBlockIP.txt" Global $LogFile = @scriptdir &"\RdpBlockLog.txt" Global $EventlogOutput = @scriptdir &"\EventlogOutput.xml" Global $FailedAttepts = IniRead(@scriptdir &"\RdpBlock.ini", "Settings", "FailedAttempts", "3") Global $WithinMinutes = IniRead(@scriptdir &"\RdpBlock.ini", "Settings", "WithinMinutes", "720") Global $Whitelist = IniRead(@scriptdir &"\RdpBlock.ini", "Settings", "Whitelist", "192.168.0") Global $LogArray[0][2] Global $BlacklistArray[0] RunWait(@ComSpec & " /c " & 'wevtutil qe "Microsoft-Windows-RemoteDesktopServices-RdpCoreTS/Operational" "/q:*[System [(EventID=140)]]" /c:2000 /rd:true /f:xml>'&$EventlogOutput , "", @SW_HIDE) $FileArray = FileReadToArray ( $EventlogOutput ) FileDelete($EventlogOutput) ;Fill $LogArray with last hours logs $FirstStamp = 0 For $i = 0 to UBound($FileArray) -1 $LineArray = StringSplit ( $FileArray[$i], ">" ) $IP = StringTrimRight($LineArray[29], 6) $StampArray = StringSplit($LineArray[16], "'") $StampArray = StringSplit($StampArray[2], "T") $Date = $StampArray[1] $TimeArray = StringSplit($StampArray[2], ".") $Time = $TimeArray[1] $sFill = $IP&"|"&$Date&" "&$Time If $FirstStamp = 0 then $FirstStamp = $Date&" "&$Time If _DateDiff('n', $Date&" "&$Time, $FirstStamp) = $WithinMinutes then ExitLoop _ArrayAdd($LogArray,$sFill) Next For $i = 0 to Ubound($LogArray)-1 $SarchIP = _ArrayFindAll ( $LogArray, $LogArray[$i][0]) If StringInStr($Whitelist, $LogArray[$i][0]) Then Else If Ubound($SarchIP) >= $FailedAttepts Then _ArrayAdd($BlacklistArray, $LogArray[$i][0]) EndIf Next ;Unless first run, include IPs from file If FileExists ($IpListFile) then ;Concatenate old with new array of IPs and delete duplicates $FileArray = FileReadToArray ( $IpListFile ) $FileIpCount = Ubound($FileArray) _ArrayConcatenate ( $FileArray, $BlacklistArray) $IpUniqueArray = _ArrayUnique ( $FileArray) If $IpUniqueArray[0] - $FileIpCount > 0 then _FileWriteLog($LogFile, 'Adding '& $IpUniqueArray[0] - $FileIpCount & ' addresses to current list ('&$FileIpCount&'), now '&$IpUniqueArray[0]&' in total.' ) ;Write IP list to file _ArraySort ($IpUniqueArray, 0, 1, $IpUniqueArray[0]) $IpList = _ArrayExtract ( $IpUniqueArray , 1 , $IpUniqueArray[0]) FileDelete($IpListFile) _FileWriteFromArray($IpListFile, $IpList) Else $IpUniqueArray = _ArrayUnique ($BlacklistArray) _ArraySort ($IpUniqueArray, 0, 1, $IpUniqueArray[0]) _FileWriteLog($LogFile, 'Adding '& $IpUniqueArray[0]& ' addresses to list of RDP blacklist.') $IpList = _ArrayExtract ( $IpUniqueArray , 1 , $IpUniqueArray[0]) _FileWriteFromArray($IpListFile, $IpList) EndIf ;Delete old FW rules RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall show rule status=enabled name=all | find "RdpBlacklist" > '&@ScriptDir&'\output.txt' , "", @SW_HIDE) $Output = FileRead ( @ScriptDir&'\output.txt') FileDelete(@ScriptDir&'\output.txt') $Output = StringReplace($Output, "Rule Name:", "") $Output = StringReplace($Output, " ", "") $RulesArray = StringSplit($Output, @LF) For $d = 1 to $RulesArray[0]-1 RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall delete rule name='&$RulesArray[$d] , "", @SW_HIDE) Next ;Create FW rules with max 100 IPs per rule (native limit) For $i = 1 to $IpUniqueArray[0] Step 100 If $i+99 > $IpUniqueArray[0] then $SplitIpArray = _ArrayExtract ( $IpUniqueArray , $i, $IpUniqueArray[0] ) $IpString = _ArrayToString($SplitIpArray, ",") If $IpString > "" then RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule name="RdpBlacklist'&StringFormat("%04d", $i)&'-'&StringFormat("%04d", $IpUniqueArray[0])&'" dir=in interface=any action=block remoteip='&$IpString, "", @SW_HIDE) Else $SplitIpArray = _ArrayExtract ( $IpUniqueArray , $i, $i+99) $IpString = _ArrayToString($SplitIpArray, ",") If $IpString > "" then RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule name="RdpBlacklist'&StringFormat("%04d", $i)&'-'&StringFormat("%04d", $i+99)&'" dir=in interface=any action=block remoteip='&$IpString, "", @SW_HIDE) EndIf Next The script operates with a simple ini file called RdpBlock.ini that you can create yourself or just download the attached one.
[Settings] FailedAttempts=5 WithinMinutes=10 Whitelist= RdpBlock.ini
-
JiBe reacted to PsaltyDS in Connect a AD from a computer of an other domain
I can't test this right now, but it should get a connection to LDAP using alternative credentials. It's just AutoIt conversion of some VBScript examples floating around on MSDN via Google:
Global Const $ADS_SECURE_AUTHENTICATION = 0x1 Global Const $ADS_SERVER_BIND = 0x200 Global $sLDAPServer = "MyServerName" Global $sLDAPPath = "LDAP://" & $sLDAPServer & "/DC=MySubDomain,DC=MyDomain,DC=com" Global $sUserName = "MyUser" Global $sPassword = "MyPa$$word" Global $iFlags = $ADS_SECURE_AUTHENTICATION + $ADS_SERVER_BIND Global $oDSO = ObjGet("LDAP:") Global $oLDAP = $oDSO.OpenDSObject($sLDAPPath, $sUserName, $sPassword, $iFlags)
Post the results if you get to try it.
-
JiBe reacted to rikho in Connect a AD from a computer of an other domain
i try this asap !
Thx alot to all !
-
JiBe got a reaction from ghost911 in PureAutoIt machine code compiler small executable
TimerInit() and TimerDiff()
Procedure.f TimerInit()
ProcedureReturn ElapsedMilliseconds()
EndProcedure
Procedure.f TimerDiff(StartTime.f)
ProcedureReturn (ElapsedMilliseconds() - StartTime)/1000
EndProcedure
-
JiBe reacted to ghost911 in PureAutoIt machine code compiler small executable
I create purebasic language functions similar to autolt I let the members of the furom improve the concept with a beginning of idea I included some functions it works very well for the moment I let you modify and give your ideas thank
add in your purebasic source code (IncludeFile "AutoitCoding.PB") and program as on autolt it remains full of function to program the concept is to improve the languages remain similar
AutoIt Code : 415 kb with UPX Interpreted Language
$Time=TimerInit() MsgBox (16,"Autoit",StringIsDigit ("123a")) MsgBox (16,"Autoit",StringIsDigit ("123")) $VarBin=StringToBinary("Hello") MsgBox (64,"Autoit",@Hour) MsgBox (64,"Autoit",@TempDir) MsgBox (64,"Autoit",$VarBin) MsgBox (64,"Autoit",BinaryToString($VarBin)) MsgBox (0,"Autoit",StringLen ("bonjour")) MsgBox (1,"Autoit",@DesktopCommonDir) MsgBox (2,"Autoit",@ProgramFilesDir) Sleep (1000) MsgBox (3,"Autoit",FileGetSize("test.pb")) MsgBox (4,"Autoit",Random (1,10,1)) $Variable=FileGetSize("test.pb") MsgBox (0,"Autoit",$Variable) ;InetGet ("https://jardinage.lemonde.fr/images/dossiers/2018-07/language-chat-170054.jpg","image.jpg") MsgBox (0,"Autoit",StringReplace ("Hella","a","o")) MsgBox (0,"Autoit",StringTrimLeft ("Hello",1)) MsgBox (0,"Autoit",StringTrimRight("Hello",1)) If FileExists ("test.pb") Then MsgBox(0,"Title","the file exist") Else MsgBox(0,"Title","the file does not exist") EndIf MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,1)) MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,1)) MsgBox(0,"Autoit",FileGetVersion("UPX.exe")) MsgBox(0,"Autoit",TimerDiff($Time)) If IsAdmin() Then MsgBox(0,"Autoit", "IsAdmin You are administrator !.") Else MsgBox(0,"Autoit", "IsAdmin You are not administrator !.") EndIf MsgBox(0,"Autoit",String (10)) MsgBox(0,"Autoit",Ping ("google.fr")) ;################## StringSplit $Split = StringSplit("ABC*DEFG*JKL","*") MsgBox(0,"Autoit",$Split[1]) MsgBox(0,"Autoit",$Split[2]) MsgBox(0,"Autoit",$Split[3]) ;################## StringSplit IniWrite("setup3.ini", "General", "Title", "AutoIt") $inivar= IniRead("setup3.ini", "General", "Title",Default) MsgBox (0,"Autoit",$inivar) PureBasic Code : Executable Size : 12 kb with UPX Real Compiler ( Your source code is secure )
IncludeFile "AutoitCoding.PB" ;MsgBox (16,"Autoit",StringIsDigit ("123a")) ;StringIs.PB be sure to activate it in AutoitCoding.PB this increases the size of the executable ;MsgBox (16,"Autoit",StringIsDigit ("123")) ;StringIs.PB be sure to activate it in AutoitCoding.PB this increases the size of the executable ;InetGet ("https://jardinage.lemonde.fr/images/dossiers/2018-07/language-chat-170054.jpg","image.jpg") ; InetFonctions be sure to activate it in AutoitCoding.PB this increases the size of the executable ;##################Mouse Dim xy (1) MouseGetPos (xy()) Debug "Pos : X : "+xy(0)+" Y : "+xy(1) Debug WinGetHandle ("Notepad") ;################## ProcessList Dim ProcessName.s(1) ; Create array Dim PID.s(1) ; Create array ProcessList (ProcessName (),PID ()) MsgBox(0,"Autoit","ProcessName: "+ProcessName(10)+" YourPID: "+PID (10)) ;################## ProcessList For i = 0 To ArraySize (ProcessName ()) Debug ProcessName (i)+" PID : "+ PID (i) Next MsgBox (0,"Autoit",ProcessorArch ()) Time$=TimerInit() VarBin$=StringToBinary("Hello") MsgBox (0,"Autoit",ComSpec ()) MsgBox (64,"Autoit",GetCPUName ()) MsgBox (64,"Autoit",CpuSerialNumber ()) MsgBox (64,"Autoit",AutoItVersion ()) MsgBox (64,"Autoit","Hello"+CRLF ()+"Hello") MsgBox (64,"Autoit",Hours ()) MsgBox (64,"Autoit",TempDir ()) MsgBox (64,"Autoit",VarBin$) MsgBox (64,"Autoit",BinaryToString(VarBin$)) MsgBox (48,"Autoit",StringLenS ("bonjour")) MsgBox (1,"Autoit",DesktopCommonDir ()) MsgBox (2,"Autoit",ProgramFilesDir ()) Sleep (1000) MsgBox (3,"Autoit",FileGetSize("test.pb")) MsgBox (4,"Autoit",Randoms (1,10)) Variable$=FileGetSize("test.pb") MsgBox (0,"Autoit",Variable$) MsgBox (0,"Autoit",StringReplace ("Hella","a","o")) MsgBox (0,"Autoit",StringTrimLeft ("Hello",1)) MsgBox (0,"Autoit",StringTrimRight("Hello",1)) If FileExists ("test.pb") MsgBox(0,"Autoit","the file exist") Else MsgBox(0,"Autoit","the file does not exist") EndIf MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,"%mm/%dd/%yyyy %hh:%ii:%ss")) MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,"%hh:%ii:%ss")) MsgBox(0,"Autoit",FileGetVersion("UPX.exe",#FV_FileVersion)) MsgBox(0,"Autoit",TimerDiff(Time$)) If IsAdmin() MsgBox(0,"Autoit", "IsAdmin You are administrator !.") Else MsgBox(0,"Autoit", "IsAdmin You are not administrator !.") EndIf MsgBox(0,"Autoit",String(10)) MsgBox(0,"Autoit",Ping ("google.fr")) iLife = 42 If IsNumber(iLife) MsgBox(0, "", "Is Number") Else MsgBox(0, "", "Is not Number") EndIf ;################## StringSplit Dim Split.s(1) ; Create array StringSplit (split(), "ABC*DEFG*JKL", "*") MsgBox(0,"Autoit",Split(0)) MsgBox(0,"Autoit",Split(1)) MsgBox(0,"Autoit",Split(2)) ;################## StringSplit IniWrite("setup3.ini", "General", "Title", "AutoIt") inivar$= IniRead("setup3.ini", "General", "Title") MsgBox (0,"Autoit",inivar$) ;Bonus Function MsgBox(0,"Autoit",HostNameToIp ("google.fr")) there is a slight difference but nothing important I am counting on you to improve the project and add functions !
( Disadvantage purebasic is paying you can not have all )
Functions compatible :
Msgbox
Sleep
FileGetSize
ClipPut
ClipGet
Randoms
DirCopy
DirCreate
DirRemove
StringReplace
StringLen
Add Fonctions : (11/03/2019)
StringTrimLeft
StringTrimRight
FileCopy
FileMove
StringUpper
StringLower
Add Fonctions : (12/03/2019)
StringIsFloat
StringIsAlpha
StringIsDigit
StringReverse
BinaryToString
StringToBinary
FileExists
Msgbox ADD :
MB_ICONERROR = 16
MB_ICONQUESTION = 32
MB_ICONWARNING = 48
MB_ICONINFORMATION=64
You can control the size of the executable
Division of executable size by 10 ( 119 kb to 12 kb)
( I separated the functions in several file activated if necessary )
;IncludeFile "FonctionsIncludes\StringIs.PB" I separated the functions into several activated files If necessary remove
;IncludeFile "FonctionsIncludes\InetFonctions.PB" ; I separated the functions into several activated files If necessary remove
Add Functions: (20/03/2019)
String
IsAdmin
TimerDiff (thank @JiBe)
TimerInit (thank @JiBe)
Ping
FileGetVersion
add :
#FV_FileVersion
#FV_FileDescription
#FV_LegalCopyright
#FV_InternalName
#FV_OriginalFilename
#FV_ProductName
#FV_ProductVersion
#FV_CompanyName
#FV_LegalTrademarks
#FV_SpecialBuild
#FV_PrivateBuild
#FV_Comments
#FV_Language
FileGetTime
Flag :
0 Last modified (default)
1 Created
2 Last accessed
Msgbox ADD :
MB_DEFBUTTON2 = 256 Flag
MB_DEFBUTTON3 = 512 Flag
MB_DEFBUTTON4 = 768 Flag
MB_SYSTEMMODAL = 4096 Flag
MB_TASKMODAL = 8192 Flag
MB_DEFAULT_DESKTOP_ONLY = 131072 Flag
MB_RIGHT = 524288 Flag
MB_RTLREADING = 1048576 Flag
MB_SETFOREGROUND = 65536 Flag
MB_TOPMOST = 262144 Flag
MB_SERVICE_NOTIFICATION = 2097152 Flag
Bonus Functions :
HostNameToIp
Add Functions: (22/03/2019)
-----------------------
ADD Macros : (thank @AZJIO)
DesktopCommonDir ()
MyDocumentsDir ()
ProgramFilesDir ()
ScriptFullPath ()
ScriptName ()
ScriptDir ()
-----------------------
OSVersions ()
Add Functions: (26/03/2019)
-----------------------
ADD Macros :
TempDir ()
Hours ()
Min ()
Sec ()
MDAY ()
MON ()
Years ()
LF ()
CR ()
CRLF ()
-----------------------
Functions:
Floor
Ceiling
Stringlen ( Update :Return Number)
StringlenS (Temporary function asks for reflection)
Add Functions: 06/04/2019
Macro :
AutoItVersion () ; it's for fun haha
SystemDir ()
UserProfileDir ()
AppDataDir ()
ComSpec () ; Bug fixed
UserName ()
LogonServer ()
HomeShare ()
HomeDrive ()
HomePath ()
HomeDrive ()
LocalAppDataDir ()
UserProfilDir ()
Bonus Macro :
ProcessorsThreadNumber ()
Functions :
Change of procedure in macro (optimization)
Optimization of msgbox
Fix a constant messagebox
Beep
StringSplit ( thank @AZJIO )
FileGetAttrib
Bonus features :
CpuSerialNumber()
GetCPUName()
Add Functions: 16/04/2019
Optimization UserName ()
Optimization CpuName () change of the name of the function GetCpuName ()
ProcessList () :
Return PID
Return ProcessName
ProcessClose (); PID or ProcessName
IniWrite ()
IniRead ()
Macro :
ProcessorArch ()
DesktopHeights ()
DesktopWidths ()
DesktopRefresh ()
DesktopDepths ()
AutoItX64 ()
Add Functions: 19/04/2019
Functions: ( THANK @AZJIO )
IniDelete ()
DriveGetType()
DriveGetLabel()
DriveGetSerial()
DriveSpaceFree()
DriveSpaceTotal()
DriveGetFileSystem()
Add Functions: 30/04/2019
Minor bug fixes :
DriveGetLabel() fixed function thank AZJIO
DriveGetFileSystem() fixed function thank AZJIO
ADD Functions :
BlockInput () thank AZJIO
FileGetShortName()
FileGetLongName()
MouseGetPos ()
WinGetHandle ()
Sqrt ()
Add Functions: 23/05/2019
ProcessExists ()
ClosePID ()
IniReadSectionNames()
WinWait ();2 in 1 finds the same handle with a title or a partial text
WinExists ();2 in 1 finds the same handle with a title or a partial text
WinWaitClose ();2 in 1 finds the same handle with a title or a partial text
WinWaitActive ();2 in 1 finds the same handle with a title or a partial text
WinGetProcess ();2 in 1 finds the same handle with a title or a partial text
HandleToHex ();x86 management Imitate autoit
HexToHandle ()
ADD Macro :
ScriptDir ()
Complete rewrite of functions with optimization :
ProcessList ()
ProcessClose ()
WinGetHandle ()
Delete function :
CountProcess ()
FileGetSize () ;Old function
All the old function are put in the OldFonctions.pb file
Add Fonctions : (18/07/2019)
WinMinimizeAll()
Winkill ();title or a partial text
SearchHandle ();Bonus function to simplify your life look for the handle of a window with a title or a text patiel
WinSetStade ();title or a partial text or Handle
#SW_HIDE = 0
#SW_SHOW = 5
#SW_MINIMIZE = 6
#SW_MAXIMIZE = 3
#SW_RESTORE = 9
#SW_DISABLE = 4
#SW_ENABLE = 1
WinActive () Title or Handle
WinList (); With the zero flag you can see the invisible windows and the flag 1 for visible windows more simplify than the original
Default option :
VisibleWindow = 1
WinSetTitle () Title or Handle
Update :
WinExists () Handle Management
WinGetProcess () Handle Management
Add Fonctions : (09/04/2020)
IsHWnd (Return 0 or 1)
PixelGetColor (x,y)
WinSetTrans ;title or a partial text 0 To 255
Optimization of the msgbox function smaller and faster code (old msgbox function put in oldfunction.pb)
Msgbox Fix minors bug
MouseMoveSpeed Function under construction
MouseClick Function under construction
HibernateAllowed()
Suspend()
ShutdownPrivilege()
Shutdown (Flag)
#SD_LOGOFF=0
#SD_SHUTDOWN=1
#SD_REBOOT=2
#SD_FORCE=4
#SD_POWERDOWN=8
#SD_FORCEHUNG=16
#SD_STANDBY=32
#SD_HIBERNATE=64
ProcessSetPriority (Process.s, priority)
#PROCESS_LOW =0
#PROCESS_BELOWNORMAL =1
#PROCESS_NORMAL =2
#PROCESS_ABOVENORMAL =3
#PROCESS_HIGH =4
#PROCESS_REALTIME =5
EnvSet ()
EnvGet ()
FileRecycleEmpty()
add file in GuiExampleAutoitCoding (Hybrid Code) example method for window
GuiExampleAutoitCoding (Hybrid Code) update files
start of code to convert autoit to pb in construction
Add Fonctions : (01/12/2022)
#PB_OS_Windows_11 code upgrade OSVersion()
WinActivate(hWnd) adding a new function thank @AZJIO
#MB_SERVICE_NOTIFICATION1 I changed the name not compatible with purebasic 6 I added a 1 (msgbox)
DriveGetLabel bugfix for version 6 of purebasic
DriveGetFileSystem bugfix for version 6 of purebasic
ProcessorArch () optimization of the function and addition of flag for Purebasic 6
ARM64
ARM
ProcessorArch () the old function is moved to the file Old Functions.pb
ProcessorArch () bug fixed stack has been corrupted
ProcessorArch () add to file Example.pb
InitNetwork remove Deprecated function
HostNameToIp optimization of the function and addition of flag 0
HostNameToIp the old function is moved to the file Old Functions.pb
Ping () optimization of the function and addition of flag and timeout
Ping () fix minor bug
flag 0 return ping
flag 1 return PingStatus also returns errors
1 = Host disconnected
2 = Host unreachable
3 = Wrong destination
4 = Other errors
flag 2 return DataSize
timeout = 4000 like the original the setting
support written web address and ip address (www.google.com or 127.0.0.1)
Ping () the old function is moved to the file Old Functions.pb
remove ExampleGui I moved the files in the same folder it is more manageable
Add Fonctions : (05/09/2024)
New Functions Added:
DllOpen Implemented a new function
DllCall Implemented a new function
DllClose Implemented a new function
iniWrite: Implemented a new function for writing to INI files.
iniRead: Introduced a revised version of the basic function for reading INI files.
CpuIdentifier() Combine some values to create a pseudo-unique identifier
Function Rewrite:
iniDelete: Updated the iniDelete function to enhance management of sections and keys.
Ping improve performance
Compatibility improved PureBasic 6.11 LTS
Legacy Code Management:
Moved obsolete functions to Oldfunctions.pb to streamline current codebase.
Moved Macro Username to Oldfunctions.pb
Moved Macro Blockinput to Oldfunctions.pb
Bug fix : (05/09/2024)
Bug fix : corrected IniRead procedure to return string instead of numeric value
Update : (05/12/2024)
FileGetVersion: bug fix pointer
IniReadSection:Implemented a new function
ExempleGui bug fix
FileRecycleEmptyDrive : rewriting the function with return of flag 1 or 0 like autoit
;Code size optimization
Reorganization and bug fix Example.pb
;added comment
;added example FileRecycleEmptyDrive
Update Fonctions : (10/12/2024)
WinGetClassList () ;thanks to @AZJIO I optimized and rewrote the function
;this remains an experience not yet stable and requires a lot of research because I remain an amateur developer
;added example WinGetClassList ()
;IniReadSection translation of comments
;thanks to @AZJIO
;StringIsDigit new function with identical return values (fully written);
;StringIsXDigit new function with identical return values (fully written);
;added example StringIsDigit
;added example StringIsXDigit
;added MyGUICreate.pb ;Imitation of experimental windows of autoit functions with Windows API
UPX official website to compress the executable :
https://upx.github.io/
PureAutoitInclude.7z
-
JiBe reacted to R0G in Digital Sign Tool
Digital Sign Tool V1.6
Features:
Digitally sign: (.exe) (.cab) (.cat) (.ocx) (.dll) (.stl) Metro style GUI thanks @BBs19 Error logging Multi file support Instructions:
You must have your (.pfx) certificate imported to the "Current User\Personal\Certificates" store Your certificate must be exportable Select your digital certificate from the drop down menu Click browse to add your files to sign Click sign For more information please visit:
https://www.autoitscript.com/forum/topic/149137-sign-your-exe-with-a-digital-signature-signtoolexe/#comment-1061738
https://msdn.microsoft.com/en-us/library/bfsktky3(vs.100).aspx?f=255&MSPPError=-2147217396
Changelog:
V1.6 1/8/2021 - Updated broken Signing URL - Added option to change signing URL in settings - Other Bug Fixes Download:
Digital Sign Tool V1.6.zip
Digital Sign Tool V0.5.zip
-
JiBe got a reaction from pintas in MultiPing
Hello to all,
I saw many people looking for a solution to Ping multiple devices and quickly.
that is why I propose a solution that I use.
the principle is simple:
-a list of IP address in a table.
-then execution of all Ping from array
-recovery of the return via a Windows message.
thats all.the recovery of the return via a SendMessage to not beforced to wait for a return.the return due it to an event.
I let you discover and make me your comment.
excused my English, I'm French! :-)
FastMultiPing.zip
-
JiBe reacted to Manimal in Input Masks "on-the-fly"
Motivation Hi guys. Coming from a more commercial environment, always seen with difficulty the fact of AutoIt (and other languages) do not accept masks during data entry. Of course, we have the EDIT fields (GUICtrlCreateInput), but normally are open fields that accept any kind of information. I noticed here and there some attempts to filter or restrict a few characters, allow others and so on. But always there was the need to customize the script for every situation, what I think is a waste of time and code. And especially the fact that prevent multiple programmers to present a more professional aspect to your work, because it required additional programming and knowledge. Understand that when we talk about business systems, data entry is very significant because the amount of data to be entered is too large. When we carry out this data entry, any interaction between keyboard and mouse delays the release of information. Think of how much time is lost between take your hand from the keyboard, get the mouse, find the cursor, click on the option (or options), click on the next field and finally back to the keyboard. It may seem silly, but this process repeated several times a day makes a huge difference. The solution is not to "eliminate" the mouse, but minimize his use, maximizing the keyboard as a whole, in the process of data entry! Another situation that bothers me is the fact that every control you need in addition to the initial and final coordinates, size and width of the field (that annoying thing be adjusting this). And not to mention that this "width" and "height" are still dependent on the font used. Sometimes, you adjust the size with a font, then decides to change (increase, decrease, put bold, etc) and there goes the entire service to the trash. At least when you create a label you can skip these steps, yet few know that. I spent a lot of time doing screens and stating the size and height of the label when not needed. As the Help is optional, but the examples and other codes always reported those numbers and I went along for the ride... Recently I had to change the font of a screen ever assembled and truncated all! I thought to myself that it couldn't be that hard and I was looking for, then I found out that the size and width of the label are optional, that is, it adjusts according to the font used at the time of opening the window. But if on the one hand eased enough to create the labels, the same cannot be said for the inputs. Theoretically (on the Help) you can leave blank these options too but the result is awful! Slowly was assembling a pattern in my head. Ideally, that formatting might follow some rules: be optional (use who wants and when it wants to) not in the way the other fields, including to allow retro-compatibility being optional, you can use only for fields that you need or require additional formatting need to adjust the size of the field to the chosen font (and its characteristics such as size, bold, height, etc) finally, allow creating a system of masks that were easily used (little training but highly flexible) format "on-the-fly", i.e. will formatting as you typing Challenge The biggest challenge was to assemble the mask system. Regular expressions (RegExp) were right, but not everyone is familiar enough to use. But it was a starting point. Then I created a second pattern that allowed both the use of RegExp and a facilitator for the most common cases. I got to the following pattern, which I called macros: 9 - only allows numbers fro 0 to 9. In RegExp \d A - only allows letters from A to Z. In RegExp [a-zA-Z] X - allows letters (from A to Z) and number (from 0 to 9). In RegExp [0-9a-zA-Z] H - allows hexadecimals (numbers from 0 to 9 and letters from A to F). In RegExp [0-9a-fA-F] @ - allows any character between ASC code 32 (space) until ASC code 126 [tilde]. In RegExp [\x20-\x7E]. Basically anything you can type (in Latin alphabet). With these settings (macros) to create a series of masks that can be easily adapted to various situations and fields. For example (using Brazilian common inputs): CPF: 11 digits with some markers = 999.999.999-99 CNPJ: 14 digits with markers = 99.999.999/9999-99 Vehicle ID: 3 letters and 4 numbers with markers = AAA-9999 Zip Code: 8 digits with markers = 99.999-999 Brazil cellphone: 11 digits (area code, prefix and number) = (99) 99999-9999 Internacional phone: 13 digits (country code, area code, prefix and number) = +99 (99) 99999-9999 MAC Address (MAC code from network card): hexa group by 2 = HH:HH:HH:HH:HH:HH and so on... In addition, any field can be described using RegExp too, which makes the system fully flexible and adaptable to any situation. For example: Vehicle ID (macro style) = AAA-999 RegExp style = [A-Z][A-Z][A-Z]-\d\d\d\d or just like this = [A-Z]3-[\d]4 But using macros is easier to understand and work right? By the way, still can not mix standard RegExp with macros. Maybe later... Let's complicate a bit? If you need a field which can only accept a character from B to J and then 2 numbers and ends with 3 more letters, looks like this: [B-J]\d\d[A-Z][A-Z][A-Z] It is harsh to read, but it works! Another point to be explored are the styles combined with masks. The styles are the last parameters of the GUICtrlCreateInput function and are very important to complement the subject. There are styles to align to the right and to the left, center it, or capitalize, accept only password fields or read-only. An ideal setting for the masks involves these two factors and the programmer know that! To make a field to accept only uppercase letters => GUICtrlCreateInput("", 10, 35, 300, 20, $ES_UPPERCASE) Only lowecase => GUICtrlCreateInput("", 10, 35, 300, 20, $ES_LOWERCASE) Center => GUICtrlCreateInput("", 10, 35, 300, 20, $ES_CENTER) If you want to mix can also using BitOr function => GUICtrlCreateInput("", 10, 35, 300, 20, (BitOr($ES_UPPERCASE, $ES_CENTER)) I know I'm raining in the wet here because all of this is on Help and you guys already know, but it never hurts to remember! Mainly because when mounting a mask makes a difference. Imagine setting a mask like [A-Z] and put $ES_ LOWERCASE in style? It's not going to work. Conclusion So it was set that there would be 3 (three) types of fields, all formatting "on-the-fly" as are typed: TEXT field: accepts masks NUMBER field: like a calculator, from right to left DATE field: accepts only numbers but that converts it to a format of "expanded date" (dd/MMM/yyyy) when leaving the field and with various options of format (DMY, MDY, etc). With automatic validation. The DMY format and its variants (MDY, YMD, etc) are to allow the entry of dates in other standards according to each country. In the USA the default is MDY, in Brazil and England is DMY. Military use YMD and so on. You can use the GUICtrlCreateDate command to create a data input "text plus calendar", but in this case, only the size calculation (font) will be made. So the function ended up like this: _GUICtrlSetMask(<ControlID>, <Input Type>, <Mask>[, <Extra Info>]) where: ControlID = control code to be formatted. You can use -1 if you want it to be the last created Input Type = 0 ($INPUT_DATE), 1 ($INPUT_NUMBER), 2 ($INPUT_TEXT) Mask = Mentioned masks. If you use macros (@, 9, A, X, H) need to put # at the beginning and end Extra Info = depends on the chosen format may contain additional information Examples of each type: Numbers ($INPUT_NUMBER): _GUICtrlSetMask($nCampo_Codigo, $INPUT_NUMBER, 6) ; Setting for number with 6 (six) digits WITHOUT decimals (999,999) _GUICtrlSetMask($nCampo_Preco, $INPUT_NUMBER, 9, 2) ; Setting for number with 9 (nine) digits PLUS 2 (two) decimals) (999,999,999.99) Date ($INPUT_DATE): _GUICtrlSetMask($nCampo_Aniversario, $INPUT_DATE, "DMY") ; Setting for date and format DAY, MONTH and YEAR, with standard marker / (stroke) _GUICtrlSetMask($nCampo_NF_Saida, $INPUT_DATE, "YMD", "-") ; Setting for date and format YEAR, MONTH and DAY with marker - (minus) Text ($INPUT_TEXT): _GUICtrlSetMask($nCampo_Nome, $INPUT_TEXT, "#[@]50#") ; Setting the text field for 50 (fifty) characters max _GUICtrlSetMask($nCampo_Nome, $INPUT_TEXT, "#[@]50#", 20) ; Setting the text field for 50 (fifty) characters max, but with max widht of 20 (twenty) characters and activating horizontal scroll _GUICtrlSetMask($nCampo_CNPJ, $INPUT_TEXT, "#99.999.999/9999-99#") ; Setting for text field with CNPJ mask (Brazilian corporation) _GUICtrlSetMask($nCampo_CEP, $INPUT_TEXT, "#99.999-999#") ; Setting for text field with Brazilian ZIP code mask Comments When to use text type, don't forget to put the mask between # (hashtag). When using date type, don't forget the date format, because it must be of the same input format. Usually, we use the _NowCalcDate() function to we initialize our date variables, but you have to remember that in this case the content is YMD format. In this case, we need to change the date format using a helper function _MUDA_FORMATO_DATA selecting the format you wish. Example.: $sData = _MUDA_FORMATO_DATA(_NowCalcDate(), "YMD", "DMY") => We initialize with _NowCalcDate (YMD format) and exchanged for Brazil (DMY format) To initialize the masks subsystem it is necessary to call the function INIT_MASCARAS which has 3 (three) parameters, all optional: _INIT_MASCARAS([BackgroundColor][, <PRE-Format>[, <POS-Format>]]) onde: BackgroundColor = color to highlight the field is being typed. Default 0xFFFF99 (light yellow) PRE-Format = True (default) or False. Is used for when you open the window, pre-format fields properly according to his content TRUE => CEP field, mask 99.999-999, content "90123789", when open the windows shows "90.123-789" FALSE => CEP field, mask 99.999-999, content "90123789", when open the windows shows "90123789" POS-Format = True or False (default). Is used for when you open the window, unformat the fields or eliminate the masks applied TRUE => CEP field, mask 99.999-999, content "90.123-789", when close the window keep the content as "90.123-789" FALSE => CEP field, mask 99.999-999, content "90.123-789", when close the window change the content to "90123789" These definitions are for when they are read with the command fields GUICtrlRead, come as the AutoIt (without formatting). Finally, after closing the window, release the subsystem via function _RELEASE_MASCARAS() Also when we talk about data entry, as far as possible to the ideal is that the ENTER key (in addition to the TAB) can be used as the terminator entry and move to the next field. Could do this internally, but I realized that it is very personal. Hence I prefer to let the position of each, but the template is quite simple and is in the example. You can also do "individual" validation of each field, which would complete the input formatting. For example, when you finish receiving a CNPJ or CPF, can validate that the code. Or if given date is allowed and so on. Of course, the function is not perfect nor is never complete, but I'm counting on the participation of colleagues to me indicate the errors, your suggestions and criticism. Thanks in advance! Sorry for my bad English, I'm just a Brazilian guy. PS. Check out our AutoIt Brazilian forum => http://forum.autoitbrasil.com/index.php Demonstration https://imgur.com/KsDSlGb Example #include "Mascaras.au3" PRINCIPAL() Exit Func PRINCIPAL() _INIT_MASCARAS() Local $nTamanho_Fonte_Input = 12 Local $nMsg, $nControle, $hJanela = GUICreate("Input Masks", 620, 460) GUISetFont(11, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $hJanela, $CLEARTYPE_QUALITY) Local $Codigo = 1234 Local $Valor = 12345.6 Local $Nome = "User Name" Local $CPF = "12345678901" Local $CNPJ = "12345678000901" Local $MAC = "7B891506F1C7" Local $CEP = "90040123" Local $sFormato_Data = "MDY" Local $Data = _MUDA_FORMATO_DATA(_NowCalcDate(), "YMD", $sFormato_Data) Local $Placa = "ABC1234" Local $Telefone = "11999706050" Local $Internacional = "1123456789" GUICtrlCreateLabel("Code:", 50, 50) Local $Campo_Codigo = GUICtrlCreateInput($Codigo, 100, 45) _GUICtrlSetMask(-1, $INPUT_NUMBER, 6, 0) GUICtrlSetFont(-1, $nTamanho_Fonte_Input, $FW_BOLD, $GUI_FONTNORMAL, "Tahoma", $CLEARTYPE_QUALITY) GUICtrlCreateLabel("Value:", 350, 50) Local $Campo_Valor = GUICtrlCreateInput($Valor, 400, 45) _GUICtrlSetMask(-1, $INPUT_NUMBER, 9, 2) GUICtrlSetFont(-1, $nTamanho_Fonte_Input, $FW_BOLD, $GUI_FONTNORMAL, "Tahoma", $CLEARTYPE_QUALITY) GUICtrlCreateLabel("Name:", 50, 100) Local $Campo_Nome = GUICtrlCreateInput($Nome, 100, 95, Default, Default, BitOR($ES_UPPERCASE, $ES_AUTOHSCROLL)) _GUICtrlSetMask(-1, $INPUT_TEXT, "#[@]60#", 40) GUICtrlSetFont(-1, $nTamanho_Fonte_Input, $FW_BOLD, $GUI_FONTNORMAL, "Tahoma", $CLEARTYPE_QUALITY) GUICtrlCreateLabel("Date1:", 50, 150) Local $Campo_Data1 = GUICtrlCreateInput($Data, 100, 145) _GUICtrlSetMask(-1, $INPUT_DATE, $sFormato_Data) GUICtrlSetFont(-1, $nTamanho_Fonte_Input, $FW_BOLD, $GUI_FONTNORMAL, "Tahoma", $CLEARTYPE_QUALITY) GUICtrlCreateLabel("Date2:", 350, 150) Local $Campo_Data2 = GUICtrlCreateDate(_NowCalcDate(), 400, 145) _GUICtrlSetMask(-1, $INPUT_DATE, "dd/MMM/yyyy") GUICtrlSetFont(-1, $nTamanho_Fonte_Input, $FW_BOLD, $GUI_FONTNORMAL, "Tahoma", $CLEARTYPE_QUALITY) GUICtrlCreateLabel("CNPJ:", 50, 200) Local $Campo_CNPJ = GUICtrlCreateInput($CNPJ, 100, 195) _GUICtrlSetMask(-1, $INPUT_TEXT, "#99.999.999/9999-99#") GUICtrlSetFont(-1, $nTamanho_Fonte_Input, $FW_BOLD, $GUI_FONTNORMAL, "Tahoma", $CLEARTYPE_QUALITY) GUICtrlCreateLabel("CPF:", 350, 200) Local $Campo_CPF = GUICtrlCreateInput($CPF, 400, 195) _GUICtrlSetMask(-1, $INPUT_TEXT, "#999.999.999-99#") GUICtrlSetFont(-1, $nTamanho_Fonte_Input, $FW_BOLD, $GUI_FONTNORMAL, "Tahoma", $CLEARTYPE_QUALITY) GUICtrlCreateLabel("MAC:", 50, 250) Local $Campo_MAC = GUICtrlCreateInput($MAC, 100, 245, Default, Default, $ES_UPPERCASE) _GUICtrlSetMask(-1, $INPUT_TEXT, "#HH:HH:HH:HH:HH:HH#") GUICtrlSetFont(-1, $nTamanho_Fonte_Input, $FW_BOLD, $GUI_FONTNORMAL, "Tahoma", $CLEARTYPE_QUALITY) GUICtrlCreateLabel("ZIP:", 350, 250) Local $Campo_CEP = GUICtrlCreateInput($CEP, 400, 245) _GUICtrlSetMask(-1, $INPUT_TEXT, "#99.999-999#") GUICtrlSetFont(-1, $nTamanho_Fonte_Input, $FW_BOLD, $GUI_FONTNORMAL, "Tahoma", $CLEARTYPE_QUALITY) GUICtrlCreateLabel("License:", 80, 300) Local $Campo_Placa = GUICtrlCreateInput($Placa, 100, 295, Default, Default, $ES_UPPERCASE) _GUICtrlSetMask(-1, $INPUT_TEXT, "#AAA-9999#") GUICtrlSetFont(-1, $nTamanho_Fonte_Input, $FW_BOLD, $GUI_FONTNORMAL, "Tahoma", $CLEARTYPE_QUALITY) GUICtrlCreateLabel("License:", 380, 300) Local $Campo_Placa1 = GUICtrlCreateInput($Placa, 400, 295) _GUICtrlSetMask(-1, $INPUT_TEXT, "[a-zA-Z]3-[0-9]4") GUICtrlSetFont(-1, $nTamanho_Fonte_Input, $FW_BOLD, $GUI_FONTNORMAL, "Tahoma", $CLEARTYPE_QUALITY) GUICtrlCreateLabel("Phone:", 60, 350) Local $Campo_Telefone = GUICtrlCreateInput($Telefone, 100, 345) _GUICtrlSetMask(-1, $INPUT_TEXT, "#(99) 99999-9999#") GUICtrlSetFont(-1, $nTamanho_Fonte_Input, $FW_BOLD, $GUI_FONTNORMAL, "Tahoma", $CLEARTYPE_QUALITY) GUICtrlCreateLabel("Phone:", 360, 350) Local $Campo_FoneIntl = GUICtrlCreateInput($Internacional, 400, 345) _GUICtrlSetMask(-1, $INPUT_TEXT, "#+55 (99) 9999-9999#") GUICtrlSetFont(-1, $nTamanho_Fonte_Input, $FW_BOLD, $GUI_FONTNORMAL, "Tahoma", $CLEARTYPE_QUALITY) Local $Ok = GUICtrlCreateButton("Ok", 145, 400, 75, 25, $WS_GROUP) Local $Cancelar = GUICtrlCreateButton("Cancel", 360, 400, 75, 25, $WS_GROUP) Local $nMyDummy = GUICtrlCreateDummy() Local $aHotkey = [ [ "{ENTER}", $nMyDummy ], [ "{TAB}", $nMyDummy ] ] GUISetAccelerators($aHotkey) GUISetState(@SW_SHOW, $hJanela) While True $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_CLOSE Then ExitLoop If $nMsg = $Ok or $nMsg = $Cancelar Then ExitLoop If $nMsg = $nMyDummy Then $nControle = _GuiCtrlGetFocus($hJanela) If $nControle = $Ok or $nControle = $Cancelar Then ExitLoop ElseIf $nControle = $Campo_Nome Then If GUICtrlRead($Campo_Nome) = "" Then ContinueLoop ; do not allow empty name ElseIf $nControle = $Campo_Data1 Then If GUICtrlRead($Campo_Data1) = "" Then ContinueLoop ; do not allow empty date ElseIf $nControle = $Campo_CPF Then ;~ If not VERIF_CPF(GUICtrlRead($Campo_CPF)) Then ContinueLoop ElseIf $nControle = $Campo_CNPJ Then ;~ If not VERIF_CNPJ(GUICtrlRead($Campo_CNPJ)) Then ContinueLoop EndIf GUISetAccelerators("") ControlSend($hJanela, "", $nControle, "{TAB}") GUISetAccelerators($aHotkey) EndIf WEnd GUISetState(@SW_HIDE, $hJanela) ConsoleWrite("[" & GUICtrlRead($Campo_Codigo) & "]" & @CRLF) ConsoleWrite("[" & GUICtrlRead($Campo_Valor) & "]" & @CRLF) ConsoleWrite("[" & GUICtrlRead($Campo_Nome) & "]" & @CRLF) ConsoleWrite("[" & GUICtrlRead($Campo_CPF) & "]" & @CRLF) ConsoleWrite("[" & GUICtrlRead($Campo_CNPJ) & "]" & @CRLF) ConsoleWrite("[" & GUICtrlRead($Campo_MAC) & "]" & @CRLF) ConsoleWrite("[" & GUICtrlRead($Campo_CEP) & "]" & @CRLF) ConsoleWrite("[" & GUICtrlRead($Campo_Data1) & "]" & @CRLF) ConsoleWrite("[" & GUICtrlRead($Campo_Data2) & "]" & @CRLF) ConsoleWrite("[" & GUICtrlRead($Campo_Placa) & "]" & @CRLF) ConsoleWrite("[" & GUICtrlRead($Campo_Placa1) & "]" & @CRLF) ConsoleWrite("[" & GUICtrlRead($Campo_Telefone) & "]" & @CRLF) ConsoleWrite("[" & GUICtrlRead($Campo_FoneIntl) & "]" & @CRLF) GUIDelete($hJanela) _RELEASE_MASCARAS() EndFunc ;==>PRINCIPAL Attention!!!
Due to changes between the versions 3.3.14.2 e 3.3.14.3 of AutoIt there are 2 versions of this function to download!
Check and download the correct version for your installation.
The sample program is the same for both versions.
The only difference between the two versions are the #includes at the beginning of the file.
In version 14.2 it's like that:
#include <Date.au3> #include <Array.au3> #include <String.au3> #include <WinAPILocale.au3> #include <EditConstants.au3> #include <FontConstants.au3> #include <MenuConstants.au3> #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> And in vesion 14.3 it's like that:
#include <Date.au3> #include <Array.au3> #include <String.au3> #include <WinAPIConv.au3> #include <WinAPIGdiDC.au3> #include <WinAPILocale.au3> #include <WinAPISysWin.au3> #include <EditConstants.au3> #include <FontConstants.au3> #include <MenuConstants.au3> #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Summarizing, the latest version has the following extra #includes:
#include <WinAPIConv.au3> #include <WinAPIGdiDC.au3> #include <WinAPISysWin.au3> Otherwise it's all the same.
Happy coding everyone.
To Do:
- remove all the errors (LOL - never happen)
- better coding
- validate function for every field (not allowing to go to another field without validation)
Mascaras v14.2.au3
Mascaras v14.3.au3
-
JiBe reacted to ripdad in Local Proxy Server v1.00
Updated to version 1.00
Stick foot in mouth. I said I would lose interest in this project -- and I did.
Until, I needed some way to heavily test the WSA_NBTCP.au3 UDF, which is included in this version.
Inspiration only comes to me every once in awhile. Gotta seize the moment! Right?
In any case, lots of improvements have been made. Changes are in the header of the script.
Please let me know if you have any problems with it.
-
JiBe got a reaction from Chamlien in UDF SSH
Hi to all,
I only am accustomed pas has posted on the forum (coz, I'm french). But I use it a lot.
So first of all, thank you all to participate in the evolution of this wonderful product.
Today is not one day like any other, I myself am decide has posted a UDF that I myself create and developed (there may be some bug) for some months.
So here it is:
This UDF allows to use the SSH protocol very easily in your code.
It uses the syntax as the TCPxxx() function.
Your code will be easier to convert :-).
excused my English, I'm French.
Example:
#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.4.0 Author: Joseph Barone 2010-2015 Script Function: Modele pour l'utilisation de la fonction ssh (plink). #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include #include #include #include #include #include "SSH_udf.au3" _SSHStartup() Global $butt[6] $Gui = GUICreate("SSH Console",550,400) $label1 = GUICtrlCreateLabel("Adresse IP:",10,10,150,20) ; ip $input1 = GUICtrlCreateInput("",10,25,150,20) ; ip $label2 = GUICtrlCreateLabel("Tcp port:",170,10,150,20) ; port $input2 = GUICtrlCreateInput("",170,25,60,20) ; port $label6 = GUICtrlCreateLabel("Protocol:",240,10,40,20) ; port $input6 = GUICtrlCreateInput("ssh",240,25,60,20) ; port $butt[0] = GUICtrlCreateButton("Connect0",310,5,80,20,$BS_DEFPUSHBUTTON) $butt[1] = GUICtrlCreateButton("Connect1",390,5,80,20) $butt[2] = GUICtrlCreateButton("Connect2",470,5,80,20) $butt[3] = GUICtrlCreateButton("Connect3",310,25,80,20) $butt[4] = GUICtrlCreateButton("Connect4",390,25,80,20) $butt[5] = GUICtrlCreateButton("Connect5",470,25,80,20) $Checkbox = GUICtrlCreateCheckbox("RSA, Fingerprint, Alert AutoValidate", 330, 45, 205, 25) $label4 = GUICtrlCreateLabel("Login:",10,45,150,20) ; login $input4 = GUICtrlCreateInput("",10,60,150,20) ; login $label5 = GUICtrlCreateLabel("Mot de passe:",170,45,150,20) ; password $input5 = GUICtrlCreateInput("",170,60,150,20,$ES_PASSWORD) ; password $label3 = GUICtrlCreateLabel("Commande a envoyer:",10,85,150,20) ; send command $input3 = GUICtrlCreateInput("",10,100,310,20) ; send commande vers l'hote $butt2 = GUICtrlCreateButton("Send",330,100,80,20,$BS_DEFPUSHBUTTON) GUICtrlSetState($butt2,$GUI_DISABLE) $edit = GUICtrlCreateEdit("",10,130,530,260,$WS_VSCROLL);,$WS_DISABLED)) GUISetState() Global $ConnectedSocket[6] = [-1,-1,-1,-1,-1,-1] Global $msg, $recv, $ret ; GUI Message Loop ;============================================== While 1 $nmsg = GUIGetMsg() If $nmsg = $GUI_EVENT_CLOSE Then ExitLoop ;;; connect part: $b = 0 While 1 If $nMsg = $butt[$b] Then If GUICtrlRead($butt[$b]) = "Connect"&$b Then _SSHParametreSet("yesall",GUICtrlRead($Checkbox)) _SSHParametreSet("protocol",GUICtrlRead($input6)) _SSHParametreSet("login",GUICtrlRead($input4)) _SSHParametreSet("passwd",GUICtrlRead($input5)) $ConnectedSocket[$b] = _SSHConnect(GUICtrlRead($input1),GUICtrlRead($input2)) If $ConnectedSocket[$b] = 0 Then MsgBox(0,"Erreur", "Impossible de ce connecter!!") Else GUICtrlSetData($butt[$b],"Close"&$b GUICtrlSetState($butt2,$GUI_ENABLE) EndIf DisplayArray($_config) ConsoleWrite("nb config:"&$_nbconf&@CRLF) Else _SSHCloseSocket($ConnectedSocket[$b]) GUICtrlSetData($butt[$b],"Connect"&$b GUICtrlSetState($butt2,$GUI_DISABLE) DisplayArray($_config) ConsoleWrite("nb config:"&$_nbconf&@CRLF) EndIf EndIf ;;; send part: If $nMsg = $butt2 Then $ret = _SSHSend( $ConnectedSocket[$b] , GUICtrlRead($input3)&@crlf) GUICtrlSetData($input3,"") GUICtrlSetState($input3,$GUI_FOCUS) EndIf ;;; receive part: $recv = _SSHRecv( $ConnectedSocket[$b]) If $recv <> "" Then GUICtrlSetData($edit, GUICtrlRead($edit) & $recv ) EndIf GUICtrlSendMsg($edit, $EM_SCROLL, $SB_PAGEDOWN, 0) $b += 1 If $b = UBound($butt) Then ExitLoop WEnd WEnd _SSHCloseSocket($ConnectedSocket) _SSHShutdown() Exit Func DisplayArray($array) $i = 0 $j = 0 if UBound($array,1) = 0 Then Return While 1 ConsoleWrite("(["&UBound($array,1)&"]["&UBound($array,2)&"]) ") While 1 ConsoleWrite("["&$j&"]"&$array[$i][$j]&" ") $j += 1 if UBound($array,2)<=$j Then ExitLoop WEnd ConsoleWrite(@CRLF) $i += 1 $j = 0 if UBound($array,1)<=$i Then ExitLoop WEnd EndFunc
I join with UDF version of modified putty myself. 🙂 LoL
but, it is not used with the UDF, it is included in the UDF.
putty-04012015- 92453+lic.zip
ssh_udf.zip
New version (contains the latest version of plink (0.74) edited by http://jakub.kotrla.net/putty/)
ssh_udf-v2.zip
Same as the v2 but supports all putty/plink settings
ssh_udf-v2.1.zip
-
JiBe reacted to Irios in SyslogSend UDF - send messages to a syslog server
Note: my first UDF.
This allows sending (BSD) messages to a syslog server using UDP. It has been tested with SnmpSoft Syslog Watcher, Synology DSM 4.2 and DSM 6.0, Kiwi Syslog Server.
Uses the BSD syslog protocol (https://tools.ietf.org/html/rfc3164), except for Facility and Severity levels, which incorporates the extended (newer) values as well. To the best of my knowledge, this is how most basic syslog senders do it today anyway.
Target IP, Facility, Severity level, Tag, Hostname, Port can be specified.
Also includes a ping feature to give an error if server doesn't respond.
Feedback appreciated.
#include-once Global $__SyslogSendPing ; this allows global access to the ping result (in ms) Global $__SyslogSendPacket ; this allows global access to the entire syslog packet: PRI, HEADER and MSG. ; #FUNCTION# ==================================================================================================================== ; Name ..........: SyslogSend v1.0.3 ; Modified ......: 2018.10.09 ; Changelog......: v1.0.2 fixed $MDAY formatting, leading zero would not be correctly replaced by a space ; v1.0.3 added debug console output when packet is sent. Set global variable $_D=True to show debug output. ; Description ...: Sends syslog messages to a syslog server using UDP ; Syntax ........: SyslogSend($_Message, $_Target, $_Port, $_Facility, $_Severity, $_Tag, $_HostName) ; Parameters ....: $_Message - Text message to send. https://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6.4 ; $_Target - [optional] Target IP or host (IPv4 address or hostname). Default is "127.0.0.1". ; $_Facility - [optional] Facility value (integer 0..23). Default is 1. https://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6.2.1 ; $_Severity - [optional] Severity level (integer 0..7). Default is 7. https://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6.2.1 ; $_Tag - [optional] Name of program or process (a-zA-Z0-9). https://tools.ietf.org/html/rfc3164#section-4.1.3 ; $_HostName - [optional] Originator hostname. Default is @ComputerName. https://tools.ietf.org/html/rfc3164#section-4.1.2 ; $_Port - [optional] UDP port number (integer 0..65535). Default is 514. ; $_Ping - [optional] Ping the host before sending, with value as timeout. Function will exit and return an ; error message if host did not respond. Default is 0 (no ping). ; Return values .: 0 = Success ; Non-zero = error text message ; Author ........: Irios ; Remarks .......: Uses UDP only, and sticks to the BSD syslog protocol (https://tools.ietf.org/html/rfc3164), except for Facility ; and Severity levels, which incorporates the extended (newer) values as well. To the best of my knowledge, this ; is how most basic syslog senders do it today anyway. The syslog protocol does not provide acknowledgement of message ; delivery, the ping feature is for convenience only. Most syslog servers will use the first word in the MSG field as ; TAG if you do not specify a tag yourself. This is by design, and not a bug. ; Example .......: SyslogSend("A test message", "192.168.0.1", 514, 3, 5, "SyslogSend", "fooServer", 1000) ; This would send the text string "<29> Oct 1 00:36:23 fooServer SyslogSend: A test message" to host 192.168.0.1:514 (including a ping, 1000ms timeout). ; ; =============================================================================================================================== Func SyslogSend($_Message, $_Target = "127.0.0.1", $_Facility = 1, $_Severity = 7, $_Tag = "", $_HostName = @ComputerName, $_Port = 514, $_Ping = 0) Local $_UDPStartup = False If (StringStripWS($_Message, 8) = "") Then Return "Error. Nothing to send (no message content)." If ($_Target = "") Or (Int($_Port) < 0) Or (Int($_Port) > 65535) Or (Int($_Facility) < 0) Or (Int($_Facility) > 23) Or (Int($_Severity) < 0) Or (Int($_Severity) > 7) Then Return "Argument(s) error." ; quick check to make sure most of the parameters have valid values ; Strip accidental spaces from target IP, HOSTNAME, and TAG. Adding a colon and space to the TAG field (https://tools.ietf.org/html/rfc3164#section-4.1.3) $_Target = StringStripWS($_Target, 8) $_HostName = StringStripWS($_HostName, 8) If ($_Tag <> "") Then $_Tag = StringStripWS($_Tag, 8) & ": " ; Ping the target host, and return an error if not responding If (Int($_Ping) <> 0) Then $__SyslogSendPing = Ping($_Target, $_Ping) Switch @error Case 1 $__SyslogSendPing = "" Return "Ping error. Host is offline." Case 2 $__SyslogSendPing = "" Return "Ping error. Host is unreachable." Case 3 $__SyslogSendPing = "" Return "Ping error. Bad destination." Case 4 $__SyslogSendPing = "" Return "Ping error. Other error." EndSwitch EndIf ; Format the TIMESTAMP field. Month number converted to Mmm format (https://tools.ietf.org/html/rfc3164#section-4.1.2). Replace leading zero in day with a space. Switch @MON Case 1 $MON = "Jan" Case 2 $MON = "Feb" Case 3 $MON = "Mar" Case 4 $MON = "Apr" Case 5 $MON = "May" Case 6 $MON = "Jun" Case 7 $MON = "Jul" Case 8 $MON = "Aug" Case 9 $MON = "Sep" Case 10 $MON = "Oct" Case 11 $MON = "Nov" Case 12 $MON = "Dec" EndSwitch $MDAY = " " & @MDAY ; we add a leading space for easier processing/formatting... $MDAY = StringReplace($MDAY, " 0", " ", 1) ; ...here we make sure the MDAY variable always has the same length (incl. a trailing space). Value such as "03" is illegal, and must be formatted as " 3". Local $_TimeStampNow = $MON & $MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC ; the complete TIMESTAMP field (https://tools.ietf.org/html/rfc3339) Local $_Prival = Int(($_Facility * 8) + $_Severity) ; generating the <PRIVAL> for the PRI field. Multiply the Facility number by 8 and add the numerical value of the Severity (https://tools.ietf.org/html/rfc5424#section-6.2.1) $__SyslogSendPacket = "<" & $_Prival & "> " & $_TimeStampNow & " " & $_HostName & " " & $_Tag & $_Message ; the complete syslog packet (https://tools.ietf.org/html/rfc3164#section-4.1.3) If (Eval("_D")=True) Then ConsoleWrite('DEBUG SyslogSend(): "'& $__SyslogSendPacket & '"' & @CRLF) ; debug output, uses $_D as trigger UDPStartup() ; starting the UDP service If @error Then Return "Could not start UDP service. Error " & @error Else $_UDPStartup = True EndIf Local $_Socket = UDPOpen($_Target, $_Port) ; the socket for the UDP connection If @error Then If $_UDPStartup Then UDPShutdown() Return "Could not connect. Error " & @error EndIf UDPSend($_Socket, $__SyslogSendPacket) ; sending the packet If @error Then If $_UDPStartup Then UDPShutdown() Return "Could not send the data. Error " & @error EndIf UDPCloseSocket($_Socket) ; closing the socket If @error Then If $_UDPStartup Then UDPShutdown() Return "Could not close socket. Error " & @error EndIf If $_UDPStartup Then UDPShutdown() ; Close the UDP service. EndFunc ;==>SyslogSend Changelog:
v1.0.1 added #include-once
v1.0.2 fixed $MDAY formatting, leading zero would not be correctly replaced by a space
v1.0.3 added $_D option for debug output, see source comment for usage
SyslogSend_udf.au3
-
JiBe reacted to Wooltown in Outlook UDF
This UDF will be superseeded by a new UDF: OutlookEX.UDF, updated by: Water
Check it out and write comments if we have designed it an a good and easy way.
Updated: 2010-01-13 - All With ... EndWith removed.
Updated: 2009-10-29 - _OutlookModifyAppointment() If run 2 times in a row, error: "Outlook.au3 (1534) : ==> Nested "With" statements are not allowed.:"
Updated: 2009-04-17 - OutlookGetMail & OutlookSaveMail, see below
Updated: 2009-03-25 - OutlokGetAppointments, returning more values
Updated: 2009-03-23 - Get rid of Security Warnings when reading/modifying - http://www.mapilab.com/outlook/security/
2009-03-12 - 5 new functions, better DemoFiles grouped in different files.
A draft to an Outlook UDF, tested on Windows 2000 and Outlook 2003
**************************************************************
***** Syntax for the functions, look in Outlook.au3 on each function *****
**************************************************************
24 Functions so far:
_OutlookSendMail - Updated 2009-02-24 - Several attachments didn't work, fixed
_OutlookCreateNote
_OutlookCreateTask
_OutlookCreateAppointment - New 2009-02-11
_OutlookCreateContact - New 2009-02-12 ***** On the General Tab I have failed to find how to set Contacts and Private *****
_OutlookCreateDistList - New 2009-02-17
_OutlookModifyAppointment - Updated 2009-10-29
_OutlookGetAppointments - New 2009-02-24 - Get an Array of all appointments
_OutlookGetMail - Updated 2009-04-17, Change read Status, access root folder, Updated 2009-03-12, Added OnlyReturnUnread, New 2009-02-26 - Get an array of all mail
_OutlookSaveMail - Updated 2009-04-17, Change read Status, access root folder, New 2009-02-27 - Save a mail and it's attachments to the hard disk, The characters \/:*?"<>| which is not allowed in filenames is replaced by _
_OutlookDeleteMail - New 2009-03-02 - Delete one or more mail from a folder
_OutlookGetTasks - New 2009-03-04 - Get an array of all Tasks
_OutlookGetNotes - New 2009-03-04 - Get an array of all Notes
_OutlookGetContacts - New 2009-03-04 - Get an array of all Contacts
_OutlookDeleteNote - New 2009-03-05 - Delete a note
_OutlookDeleteTask - New 2009-03-05 - Delete a task
_OutlookGetDistLists - New 2009-03-05 - Get the contents of one or more distribution lists
_OutlookDeleteTask - New 2009-03-06 - Delete a task
_OutlookModifyTask - New 2009-03-06 - Modify a Task
_OutlookDeleteDistListMember() - New 2009-03-09 - Delete a member in a distribution list
_OutlookDeleteDistList() - New 2009-03-09 - Delete a distribution list
_OutlookFolderExist - New 2009-03-12 - Test if a folder exist
_OutlookFolderAdd - New 2009-03-12 - Add a folder
_OutlookFolderDelete - New 2009-03-12 - Remove a folder
_OutlookDeleteXXXX, _OutlookModifyXXXX - Functions to develop
OutlookWarning.exe renamed to OutlookWarning1.exe
OutlookWarningAddress.exe renamed to OutlookWarning2.exe
In _OutlookSendMail there is a parameter for the entire path for OutlookWarning1.exe, it is necessary because of a security feature in Outlook so a program shouldn't be able to send a mail unnoticed. OutlookWarning1.exe automatically press the Yes-button.
Compile OutlookWarning1.au3 and put it where you would like to have it.
In _OutlookCreateDistList there is a parameter for the entire path for OutlookWarning2.exe, it is necessary because of a security feature in Outlook so a program shouldn't be able to modify addresses unnoticed. OutlookWarning2.exe automatically press the Yes-button.
Compile OutlookWarning2.au3 and put it where you would like to have it.
More features to come if the community is interested.
Attached file: Outlook.zip - 7 Demo files and 3 UDF files
1557 downloads until 2010-01-13
Outlook.zip
-
-
JiBe reacted to Jefrey in multi threading
Hi, @jaberwacky! It looks like Andreik and TheDcoder have answered to your question. I've done no tests so far with _WinAPI_SetProcessAffinityMask, tho.
----------------------
Hi, JiBe!
Actually, the AdlibRegister is not the true way it runs the "threads". Truly it really creates new processes and uses Adlib just to check for new messages (from the UDF _AuThread_SendMessage()) or closing signal.
Also, it's really not the true multi threading. It's just an emulation. It's "forking"
----------------------
Hi, argumentum!
Yes, this is the right name hehe. It came out of my mind at the time of the creation of this topic. I've added it to the topic title (I chose to keep "multi thread emulation" for helping users who are using the search engine, as some might not know what's forking). Thanks for poiting out
---------------
Guys, I've started another project that, according to what my latest tests are poiting, might provide some kind of true multithreading for AutoIt without external processes. It's not fully working yet (so far it works just with basic tasks). This is an example:
#include 'thread.au3' CreateThread("helloworld") Func helloworld($h) MsgBox(0, "", "Hello from the sub thread") EndFunc MsgBox(0, "", "Hello from the main thread") Exit If you want to help, here's the repo: https://github.com/jesobreira/thread.au3
-
JiBe reacted to Jefrey in multi threading
Hi all!
I've made this small UDF to emulate multithreading for AutoIt3.
As we know, AU3 is singlethread and multithreading is only possible through direct ASM. This UDF provides a multithreading emulation through running multiple instances of your script. It also provides an easy way for sending and receiving messages between threads (temporary files are used).
Example:
Example 2:
Docs:
Download:
Github ZIP
Fork me on Github
-
JiBe reacted to faldo in Meet Remmanaut, the autoit remote administration tool
"The why"
I've been working over 15 years in the IT industry and have realised that the best way of streamlining operations and support is by combining the concept of selling services (instead of hours) along with a tool built for managing those services.
For the past 10 years i've been working with some of the leading providers of MSP-tools. The prize set on these comercial tools is quite high and there are usually few licence models to choose from. A smaller it-company will find the cost hard to motivate and in turn have dificulties converting its busines model in order to make more money, classic catch 22
"The how"
During the years, i've gathered the pros and cons of these tools, dissected their core and realised there is no magic or rocket science going on. There is however a whole lot of scripting used and that's why i feel AutoIT would be a great foundation for a new project.
So, i've decided to compile my years of experiance and create a tool for remote management and monitoring of machines over WAN. Instead of monetizing it and try to compete with the big companies i felt it more efficiant to make it open source and hope for community interest and development.
"The what"
The following features are under development, some arn't started, some are finished. Check the changelog for more info.
Base components
- Agent running as service
- Central server with MySQL (hub engine)
- Management client (AutoitGUI/WebGUI)
Main features
- Remote execution of shell commands as system or specific user
- File transfer from/to agent
- Live monitoring of system resources
Consequential features (based on main features)
- Hardware/software inventory
- Software deployment/updating
- Patch management
- Antivirus management
- OS deployment
- Disaster recovery
- Hardware/software/network monitoring
- Wake on LAN
- Reporting
- Remote registry, event viewer, task manager
- Scripting (obviously)
Additional features (stand-alone modules)
- Remote control
- Servicedesk (based on ITIL)
- AD-integration
Security
- Secure communication with SSL and rotating key for every session.
- SHA256 encryption.
Remmanaut network overview
My knowledge of AutoIT is average but i'm novice when it comes to programing structure for collaboration, so if you're willing to help me out in making the project easy to share, i'd be very thankfull. Unfortunatly i'm no php-guru so i'll be concentrating on the AutoitGUI until the agent and hub engine reaches an adequate version.
If you feel that this tool could benefit you in any way or just want to join the project for the fun of development, don't hesitate to post constructive feedback or hit me a PM.
Code optimisation to do:
Download:
-
JiBe reacted to NerdFencer in Valentines Day Surprise
This is a program that I wrote to surprise my girlfriend Victoria on Valentines day.
Feel free to adapt it for your own significant other!
Suggestions welcome
http://autoclean.computersitter.com/Vday.zip
It comes with a pre-compiled executable and batch files to install, uninstall, and force execution (it wont do anything unless its valentines day). The batch files just execute the program with command line options.
The source is in the zip and below.
#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=VDay.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/SO #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.2.0 Author: Matthew McMullan Script Function: Valentines Day Script. #ce ---------------------------------------------------------------------------- #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> ; =============================================================================================================================== ; Globals ; =============================================================================================================================== Global Const $AC_SRC_ALPHA = 1 Global $Himg[3] Global $minihearts[2][10] Global $ll, $lr ; =============================================================================================================================== ; Command Line Interpretation ; =============================================================================================================================== If $CmdLine[0] = 0 Then If @MON=="02" And @MDAY="14" Or Not(@Compiled) Then Main() EndIf ElseIf $CmdLine[1]=="/install" Then DirCreate(@ProgramFilesDir&"\Valentines Day\") FileCopy(@ScriptDir&"\valentine-heart-small.png",@ProgramFilesDir&"\Valentines Day\") FileCopy(@ScriptDir&"\valentine-heart-small-left.png",@ProgramFilesDir&"\Valentines Day\") FileCopy(@ScriptDir&"\valentine-heart-small-right.png",@ProgramFilesDir&"\Valentines Day\") FileCopy(@ScriptDir&"\VDgui.png",@ProgramFilesDir&"\Valentines Day\") FileCopy(@ScriptDir&"\Bryan Adams - When You Love Someone.mp3",@ProgramFilesDir&"\Valentines Day\") FileCopy(@ScriptFullPath,@ProgramFilesDir&"\Valentines Day\") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run","Valentines Day","REG_SZ",@ProgramFilesDir&"\Valentines Day\"&@ScriptName) ElseIf $CmdLine[1]=="/uninstall" Then RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run","Valentines Day") DirRemove(@ProgramFilesDir&"\Valentines Day\",1) DirRemove(@ProgramFilesDir&"\Valentines Day\",0) ElseIf $CmdLine[1]=="/force" Then Main() EndIf ; =============================================================================================================================== ; Here lies the romantic magic ; =============================================================================================================================== Func main() Init() SoundSetWaveVolume(100) SoundPlay(@ScriptDir&"\Bryan Adams - When You Love Someone.mp3") Local $gui = GUICreate("Valentines Day",811,750,-1,-1,-1,BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST)) Local $guiimg = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\VDgui.png") SetBitMap($gui, $guiimg, 255) PopulateMiniHearts($gui) GUISetState(@SW_SHOW,$gui) Local $msg While 1 $msg = GUIGetMsg() Switch $msg Case -3 Exit EndSwitch Sleep(15) UpdateMiniHearts() WEnd Denit() EndFunc ; =============================================================================================================================== ; Determines the placement for a heart ; =============================================================================================================================== Func PlaceHeart(ByRef $last, $left, $right) Local $place = $last While $last-40<$place And $last+40>$place $place = Random($left,$right,1) WEnd $last = $place Return $place EndFunc ; =============================================================================================================================== ; Initialize the screen full of romantic hearts ; =============================================================================================================================== Func PopulateMiniHearts($gui) $ll = -300 $lr = -300 Local $left = (@DesktopWidth-811)/2 Local $right = (@DesktopWidth+811)/2-49 For $i=0 To 9 $minihearts[0][$i]=CreateOverlayGui(PlaceHeart($ll,0,$left),$i*((@DesktopHeight+63)/10),Random(0,2,1),$gui,"0"&$i) $minihearts[1][$i]=CreateOverlayGui(PlaceHeart($lr,$right,@DesktopWidth-49),$i*((@DesktopHeight+63)/10),Random(0,2,1),$gui,"1"&$i) Next EndFunc ; =============================================================================================================================== ; Make them bubble! ; =============================================================================================================================== Func UpdateMiniHearts() Local $pos For $i=0 To 9 For $j=0 To 1 $pos = WinGetPos($minihearts[$j][$i]) $pos[1]-=1 If $pos[1]<-63 Then $pos[1] = @DesktopHeight If $j=0 Then $pos[0]=PlaceHeart($ll,0,(@DesktopWidth-811)/2) Else $pos[0]=PlaceHeart($lr,(@DesktopWidth+811)/2,@DesktopWidth-49) EndIf EndIf WinMove($minihearts[$j][$i],"",$pos[0],$pos[1]) Next Next EndFunc ; =============================================================================================================================== ; Create overlay gui ; =============================================================================================================================== Func CreateOverlayGUI($x,$y,$img=-1,$master=-1,$title="OLgui") Local $retgui = GUICreate("OLgui",49,63,$x,$y,$WS_POPUP,$WS_EX_LAYERED,$master) If $img==-1 Then SetBitMap($retgui, $Himg[Random(0,2,1)], 128) Else SetBitMap($retgui, $Himg[$img], 128) EndIf GUISetState(@SW_SHOW,$retgui) Return $retgui EndFunc ; =============================================================================================================================== ; Initialize ; =============================================================================================================================== Func Init() ; Load layered image _GDIPlus_Startup() $Himg[0] = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\valentine-heart-small.png") $Himg[1] = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\valentine-heart-small-left.png") $Himg[2] = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\valentine-heart-small-right.png") EndFunc ; =============================================================================================================================== ; denit ; =============================================================================================================================== Func denit() ; Release resources _GDIPlus_ImageDispose($Himg[0]) _GDIPlus_ImageDispose($Himg[1]) _GDIPlus_ImageDispose($Himg[2]) _GDIPlus_Shutdown() EndFunc ; =============================================================================================================================== ; SetBitMap ; =============================================================================================================================== Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize ) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth ($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha" , $iOpacity ) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC (0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC ($hMemDC) EndFunc
It displays an image in the middle (semi-transparent) and has random hearts scrolling up the left and right sides.
Update: Made the center text generic (Happy Valentines Day! I Love You!), fixed a display bug found by rogue5099, added a base heart image with no text (for easier customization), and merged the code into one source file.
-
JiBe reacted to legend in AutoitC - compile autoit to c++
I didn't create this, I found it here: http://sourceforge.net/projects/autoitc/
i tested it with simple things like a msgbox, and it works fine,
but it's very limited how many commands it supports. i though I share it, would be great if it were able to compile any script to c++
==========================================================================
AutoItC 0.1.0 (alpha)
==========================================================================
WARNING: This is an Alpha Version. Several features may be missing or incomplete.
Content of this file:
1. Directory Structure Overview
2. How To Start
3. AutoItC-Converter
4. License
==========================================================================
1. Directory Structure Overview
==========================================================================
/include The header files for the runtime library of AutoItC
/intern The source files for the runtime library of AutoItC - This folder might not exist in the binary-only version of AutoItC
/AutoItC-Converter The source files of AutoItC-Converter.exe - This folder might not exist in the binary-only version of AutoItC
/AutoItC-Converter.exe Command line tool which converts the AutoIt-script to C++-files
/Compiler.au3 AutoIt-script which automates the compiling process
/Compiler.exe Compiled version of Compiler.au3
/libAutoItC.a Runtime library
==========================================================================
2. How to start
==========================================================================
AutoItC is Windows only.
You need at least gcc 4.7 for compiling C++ to executables..
Before using AutoItC add the path of gcc to the environment variable PATH or modify Compiler.ini.
Run Compiler.exe or Compiler.au3 and select the input and output file and do the compiling automatically.
You can also do the code generation with AutoItC-Converter and then compile and link manually with the command line.
See 2. AutoItC-Converter for more details about the options.
==========================================================================
3. AutoItC-Converter
==========================================================================
AutoItC-Converter is a command line tool which converts the AutoIt script to C++.
Options:
-iPATH path to include files (e.g. -i..\include)
if not set, no includes-directory exists
-fFILE process FILE
-fFILE must be set or the compiler will break with an error message
-oFILE write the output into FILE
default is out.cpp
-l print a short version of the license (GPL)
AutoItC.zip
-
JiBe reacted to trancexx in CheckSumVerify - verify integrity of the compiled exe
There was a thread in general support forum the other day about possibility of compiled executable to verify binary integrity of itself when run. I can't find the topic now to link it, but meh never mind.
Logical solution is to calculate checksum of the exe and save it somewhere. Later when the executable is run the checksum is calculated again and compared to the saved value. If they match, all is ok, and if they don't the exe was altered and verification fails.
The obvious problem is how and where to store the hash value. Alternate data stream seems the simplest solution. That way the hash is bound to the exe only and the risks of unwanted manipulations are relatively low. The problem could be if the exe is saved and run from non-NTFS file systems. Another problem is that any read/write action on exe file usually ends up with ADS being deleted.
The other solution is registry writing, but that bounds exe and hash to the system. For another system (or even user) the checking wouldn't be valid.
Third solution is using some sort of ini file. But that means ini has to go everywhere exe goes, otherwise again the check wouldn't make sense. And it would be too simple for someone to manipulate data, to the level the check wouldn't make sense.
So, this is kind of fourth option. CheckSumVerify2.a3x script below is include file that will calculate the hash of the executable on the first run, save it directly inside that executable using special technique and recheck the hash on every new run. If the new hash wouldn't match the saved one, the script will show message box saying that and further execution will be aborted.
CheckSumVerify2.a3x
Just to say that I haven't done any complicated tests to see if it would work in outer space, or even on all supported systems. However my guess is it should work.
Don't UPX the compiled executables, because I'm calculating checksum of the image on disk and not the one in memory.
Here's small example of usage:
#include "CheckSumVerify2.a3x" If @Compiled Then MsgBox(64 + 262144, "Aha!", "This is an example exe that does nothing except showing this message." & @CRLF & @CRLF & _ "But if you change the binary of me I will show error message and won't allow further execution." & @CRLF & _ $cmdlineraw) Else MsgBox(64 + 262144, "Hey", "This is an example script that does nothing except showing this message." & @CRLF & @CRLF & _ "But if you compile me I will check binary integrity of the compiled executable every time its run.") EndIf If something wouldn't work, or if you have any questions - simply post here. I'll do my best to answer.
-
JiBe reacted to Gianni in Snowfall
it's snowing....
#include <WindowsConstants.au3> #include <WINAPI.au3> Local $isnowflakes = 500 ; number of snowflakes Local $iMinR = 5 ; minimum length of the snowflake's side Local $iMaxR = 8 ; max length Local $aSnow[$isnowflakes][5] Local $AlphaKey = 0xABABAB, $hBackground = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUPWINDOW, $WS_EX_LAYERED + $WS_EX_TOPMOST) GUISetBkColor($AlphaKey, $hBackground) _WinAPI_SetLayeredWindowAttributes($hBackground, $AlphaKey, 0, $LWA_COLORKEY) GUISetState(@SW_SHOW, $hBackground) For $i = 0 To UBound($aSnow) - 1 _Randomize($aSnow, $i, $iMinR, $iMaxR) $aSnow[$i][3] = GUICtrlCreateLabel("", $aSnow[$i][1], $aSnow[$i][2], $aSnow[$i][0], $aSnow[$i][0]) GUICtrlSetBkColor(-1, 16777215) ; snow white Next While 1 For $i = 0 To UBound($aSnow) - 1 $aSnow[$i][2] += $aSnow[$i][4] ; increment y pos GUICtrlSetPos($aSnow[$i][3], $aSnow[$i][1], $aSnow[$i][2]) If $aSnow[$i][2] > @DesktopHeight Then _Randomize($aSnow, $i, $iMinR, $iMaxR) GUICtrlSetPos($aSnow[$i][3], $aSnow[$i][1], $aSnow[$i][2], $aSnow[$i][0], $aSnow[$i][0]) EndIf Next WEnd Func _Randomize(ByRef $aSnow, $i, $iMinR, $iMaxR) $aSnow[$i][0] = Random($iMinR, $iMaxR, 0) ; dimension of snow $aSnow[$i][1] = Random(0 - $iMaxR, @DesktopWidth + $iMaxR, 0) ; x position $aSnow[$i][2] = 0 - $iMaxR ; y position (out of screen at startup) $aSnow[$i][4] = Random(0.1, $iMaxR * 3) EndFunc ;==>_Randomize
-
JiBe reacted to Jefrey in TCPClient UDF (multi client, event-based, able to bind console app to socket)
Hi!
If you liked my TCPServer UDF, you'll also like this one.
Following the same principles, this TCPClient UDF helps you on handling multiple connections to different servers, and set actions depending on two events: OnReceive and OnDisconnect.
It is also multi server (you can connect to many servers at once) and you can also bind a Console-based executable to the socket (similar to -e parameter in NetCat). This feature is useful if you want to use some Console UDF to create a TCP application and don't want to deal with the TCP* functions. Also, it runs on background just firing events, it won't pause your script while waiting/receiving data, so you can do anything else (close and open connections, allow the user to click buttons or just wait on an infinite loop) that your callbacks will be called once the event is fired
It is also very easy to use. See this examples:
Example #1: Connecting to a basic server
By running this (as soon as you open a basic server with Netcat) you will receive a message box telling you when the server closes the connection (the socket ID and his IP address are passed as parameter to your callback function) and also when the server sends something over the TCP socket (the data sent is passed as parameter).
#cs Download netcat at https://eternallybored.org/misc/netcat/ Execute this script Run in CMD: nc -vv -l -p 8081 #ce #include "TCPClient.au3" ; First we set the callback functions for the two events (none of them is mandatory) _TCPClient_OnDisconnect("disconnect") _TCPClient_OnReceive("received") ; And a parameter _TCPClient_DebugMode(True) ; Finally we connect to the server at port 8081 at any interface _TCPClient_Connect('127.0.0.1', 8081) Func disconnect($iSocket, $sIP) MsgBox(0, "Server disconnected", "Server " & $sIP & " disconnected from socket " & $iSocket) EndFunc ;==>disconnect Func received($iSocket, $sIP, $sData, $sPar) MsgBox(0, "Data received from " & $sIP, $sData & @CRLF & "Parameter: " & $sPar) _TCPClient_Send($iSocket, "You wrote: " & $sData) _TCPClient_SetParam($iSocket, 'will write again') EndFunc ;==>received While 1 Sleep(100) WEndExample #2: Requesting a page from a HTTP server
In this example, we run this code and it will get the response from a HTTP server. Of course, as we are requesting google.com index, it may just show a redirect page to a local (with country top-level domain) Google page or with some stuff on the URL.
#include "TCPClient.au3" _TCPClient_OnReceive("received") _TCPClient_DebugMode(True) $iSocket = _TCPClient_Connect(TCPNameToIP('google.com'), 80) If @error Then Exit _TCPClient_Send($iSocket, "GET / HTTP/1.0" & @CRLF & @CRLF) Func received($iSocket, $sIP, $sData, $sParam) MsgBox(0, "Data received", $sData) _TCPClient_Disconnect($iSocket) EndFunc ;==>received While 1 Sleep(100) WEndExample #3: Command prompt bound to the socket after password requesting
By running this example, we will be asked for a password, which is 123456 as we set on the script. If the password is correct, we will see the Command Prompt live-updated (try running a ping to some server, for example).
#include "TCPClient.au3" #cs To test this example, execute a netcat server, running this commands: nc -vv -l -p 31337 #ce Global $Password = "123456" _TCPClient_OnReceive("receive") _TCPClient_OnDisconnect("disconnect") _TCPClient_DebugMode() Func receive($iSocket, $sIP, $sData, $mPar) If $mPar = "login" Then If $sData = $Password Then ; right password, let's change the parameter _TCPClient_SetParam($iSocket, "logged") ; and now bind _TCPClient_BindAppToSocket($iSocket, "cmd.exe") Else _TCPClient_Send($iSocket, "Wrong password. Try again: ") EndIf Else If $sData = "exit" Then ; unbinds _TCPClient_UnBindAppToSocket($iSocket) ; says bye _TCPClient_Send($iSocket, "See you") ; closes connection _TCPClient_Disconnect($iSocket) Else ; sends command directly to the process _TCPClient_SendToBound($iSocket, $sData) EndIf EndIf EndFunc Func disconnect($iSocket, $sIP) MsgBox(0, $iSocket, $sIP) EndFunc $iSocket = _TCPClient_Connect('127.0.0.1', '31337') If @error Then MsgBox(0, "", "could not connect. Error: " & @error) Exit EndIf ; Sets parameter to login, so we know what the server is doing _TCPClient_SetParam($iSocket, "login") _TCPClient_Send($iSocket, "Please enter password: ") While True Sleep(100) WEndThe limit is your imagination? Well, maybe.
Functions list:
_TCPClient_Connect($sSvr, $iPort)
_TCPClient_Disconnect($iSocket)
_TCPClient_SetParam($iSocket, $sPar)
_TCPClient_Send($iSocket, $sData)
_TCPClient_Broadcast($sData [, $iExceptSocket = 0 ])
_TCPClient_ListConnections()
_TCPClient_BindAppToSocket($iSocket, $sCommand [, $sWorkingDir = @WorkingDir ])
_TCPClient_SendToBound($iSocket, $sData)
_TCPClient_UnBindAppToSocket($iSocket)
_TCPClient_OnReceive($sCallback)
_TCPClient_OnDisconnect($sCallback)
_TCPClient_DebugMode([ $bMOde = "toggle" ])
_TCPClient_AutoTrim([ $bMode = "toggle" ])
_TCPClient_SocketToConnID($iSocket)
_TCPClient_ConnIDToSocket($iConn)
_TCPClient_SocketToIP($iSocket) Help file and more examples included!
Latest version: 1.0.0
Download: https://www.autoitscript.com/forum/files/file/377-tcpclient-udf/
Changelog
1.0.0 - First release - 03/12/2015 If you can't open the help file, please uncompress it, go to properties and click Unlock.
Fork me on Github: http://github.com/jesobreira/tcpclient-udf
-
JiBe reacted to spudw2k in VMWare ESX Cluster Builder
This is a tool I put together to size an ESX cluster based on the VM resource requirements. it's far from perfect and probably bug ridden, but I just wanted to share.
Credits to @guiness for his _GUICtrlListView_CreateArray UDF and to @Melba and associated crew for the GUIListViewEx UDF.
edit: v0.7
ESX Builder.zip