Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/01/2018 in all areas

  1. @Earthshine, you are right, I checked the zip file and it was infected. I checked this on my mac with Bitdefender. I appreciate from moderators or owners here to delete the zip file as soon as possible @Jon . Meanwhile, I checked the exe file from XDA and it's not infected. Maybe the machine that adelbak is using is infected.. @adelbak, I thought you wrote this file ... I opened the GitHUB and XDA and I saw it was developed by someone else as per the attachment. I'm an XDA developer named as Jowy007 there, I appreciate from your side, whenever you publish a code that's not yours, at least, mention the developers and web links. Developers are heavy-duty workers and we should mention and respect them and their work. Thanks for understanding, Jowy
    2 points
  2. Gianni

    versatile multi ping

    I needed a function to ping many computers, and get the results of the pings in an array so to manage it easily in a script. Searching in the forum I found some interesting sw with a nice graphical interface, but not a generic function that simply return an array. a very powerful pinger I found is >nPing by Manadar, but it is designed as a command line tool, so I decided to use the entire engine of nPing adapting it a bit, so that it can be used as an udf. This code is a first attempt (beta) and it can be used to: Ping all computers (IP addresses) belonging to the (local) LAN just call the _nPing() without any parameter Ping a predefined list of IP just pass the list of host (IP or hastnames) to the function in an 1D zero based array or in a 2D array indicating the column containing the addresses Ping all computers (IP addresses) of a remote LAN just pass an IP of that lan and his subnet mask Ping range of computers (IP addresses) just pass a string rappresenting the range of IP to ping (as accepted by the nPing program by Manadar), for example: 192.168.0.0-1 will ping these addresses: 192.168.0.0 and 192.168.0.1 192.168.20.* will ping everything in the range from 192.168.20.1 to 192.168.20.255 192.168.0-1.1-254 will ping everything in the range from 192.168.0.1 to 192.168.1.254 I have not done extensive testing on it, so I would be grateful if someone that tries it, can report any error thanks EDIT: After some testing, I have seen that sometime some IP are reported as dead, while are alive instead. This occurs when a device is not so fast to answer to the ping, and so it's marked as dead while instead is only too slow to answer to the ping. I came to the conclusion that for a more accurate result about the not responding devices, is better to use a $timeout parameter of 4000 ms as default value in the _MSPing() function (the same default timeout value as in the standard ping command) So I have "calibrated" the multiping.au3 by modifying the line 349 and incrementing the value of the $Timeout variable from 100 ms to 4000 ms. This should be a better choice for a general purpose utilization that gives more stable and accurate results about the not responding devices. This should not slow down the overall performances, but will only give some more time to respond to the slower devices. MultiPing.au3 #include <iNet.au3> ; #INDEX# ======================================================================================================================= ; Title .........: _nPing ; AutoIt Version : ; Language ......: English ; Description ...: Function to perform multi Ping. ; Author(s) .....: core engine is Manadar's "nping" retrieved at the following post ; http://www.autoitscript.com/forum/topic/108060-nping-console-network-pinger-network-sweeper-network-scanner ; adapted to this UDF by PincoPanco ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _nPing multi IP pinger ; =============================================================================================================================== ; #INTERNAL_USE ================================================================================================================= ; _LanParameters given IP and mask generate [and display] various lan parameters ; _CIDR_To_Mask transform a CIDR number (1 - 32) to the corresponding 4 digit mask ; _Mask_To_CIDR transform a 4 digit mask to the corresponding CIDR number (1 - 32) ; _GetSubnetMask given the local IP returns the related subnet mask (thanks to dragan) ; _Convert_To_Binary from decimal to binary ; _Bin_To_Dec from binary to decimal ; _FileReadToArray_mod read a file of IP in a 1D array, if is a csv and a separator is passed a 2D array is returned ; _GetIpAddressList Generate the IP list to Ping ; _Make_Range Given an IP and his mask, this function return the full LAN "range" for _nPing ; _GetLanParameters calculate all IP/subnet related parameters ; _isIPaddr check if passed IP is a plausible IP ; _isSNmask check if passed mask is a plausible mask ; _Progress shows a progress bar for the current scan ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _nPing ; Description ...: returns an array containing: clients responding to ping or clients not responding or both. See $ReturnFlag ; Syntax.........: _nPing([[$IP]|[$IPArray]|[$IPrange]],[[$NetMask]|[$column]], [$ReturnFlag], [$Resolve], [$MyFunction]) ; Parameters ....: [[$IP]|[$IPArray]|[$IPrange]] - An IP address or an 1D or 2D array (0 based) or an IPrange(*) ; $NetMask - An 4 digit Net Mask or a CIDR notation value (numbers of bit from 1 to 32) ; if previous parameter is an 2D array then this parameter contains the ; nr. of the column that contains the addresses to be pinged ; $ReturnFlag - 0|1|2, what to return: 0=all cliensts; 1=responding clients; 2= not responding clients(**) ; $Resolve - O or 1, if IP lookup name resolution must be performed; 1 = yes, 0 = no ; $MyFunction - an User Defined Function to be called each time a PING complete (default is progress bar) ; the called function receives 1 parameter that is an array containing the following 6 parameters: ; [0] nr. of total addresses under process ; [1] nr. of ping already finished ; [2] IP just processed ; [3] resolved Host name or -1 if IP is down ; [4] roundtrip of this ping or -1 if IP is down ; [5] Index of this IP within the caller's passed array ; by default is called the _Progress() function that will display the progress bar ; Return values .: Success - an 2D array containing: ; first row ($array[0][x]) contains: [0][0]= nr. of returned host; [0][1]= total roundtrip ; other rows: [n][0]=Address; [n][1]=lookup name; [n][2]=roundtrip; [n][3]=index in the passed array*** ; Failure - -1, sets @error ; |1 - too many IP, max 16777216 ($MAX_HOSTS) ; |2 - wrong array dimensions or wrong column number ; |3 - wrong IP ; |4 - wrong subnet mask ; |5 - bad "range" or wrong IP error ; |6 - Windows Sockets Error ; |7 - (not used) ; |8 - DLL call error (reading local subnet mask) ; ; (*) IPrange is a string as below ; "192.168.0.0-1" will ping these addresses: 192.168.0.0 and 192.168.0.1 ; "192.168.20.*" will ping everything in the range from 192.168.20.1 to 192.168.20.255 ; "192.168.0-1.1-254" will ping everything in the range from 192.168.0.1 to 192.168.1.254 ; ; (**) returnead 2D array has the following 4 columns: ; first row contains: [0][0]= nr. of returned host; [0][1]= total roundtrip ; following rows contains fields as below ; +-------------------------+-------------------------+ ; | nr of elements in array | total roundtrip | ; +-------------------------+-------------------------+-------------------------+-------------------------+ ; | IP address | [hostname] ( -1) | roundtrip (or -1) | index *** | ; +-------------------------+-------------------------+-------------------------+-------------------------+ ; ; (***) since the returned array has not the same nr. of rows and also has not the same order of the array in input, ; this index is a reference to "bind" both arrays. ; It is more useful if the input array is a 2D array and you have to bind the rows containing results ; with related fields (array elements) in the "source" array ; Author ........: ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _nPing($networkRange = "", $MyMask = "", $ReturnFlag = 1, $Resolve = 0, $MyFunction = "_Progress") Static $TCP = TCPStartup() ; this should be used at the beginning of the main program instead of inside the Func() Static $dig = FileExists(".\dig\dig.exe") ; this is for IP to hostname resolution. if dig.exe exists will be used. (faster than _TCPIpToName) Local $MAX_PROCESS = 20 ; A maximum number of processes (25) ; Global $MAX_HOSTS = 16777216 ; A maximum number of hosts to ping due to AutoIt's array limit size Local $_IPup[1][4] ; will contain results of PINGs [IP][roundrip or -1] ; check what has been required from caller If $networkRange = "" Then ; no parameters passed, so scan local network ; ConsoleWrite("debug: no IP/range provided, I will scan the local LAN" & @CRLF) $networkRange = _Make_Range(TCPNameToIP(@ComputerName), _GetSubnetMask(TCPNameToIP(@ComputerName))) ; retrieve local LAN and Subnet Mask values If @error Then Return SetError(@error, @extended, -1) ; ConsoleWrite("debug: network range=" & $networkRange & @CRLF) ElseIf IsArray($networkRange) Then ; ----- is an array -----------------------------+ ; if is an 2D array then $MyMask contains the column else is ignored | If UBound($networkRange) > 16777216 Then Return SetError(1, 0, -1) ; | too many IP > $MAX_HOSTS ; If UBound($networkRange, 0) <> 1 Then Return SetError(2, 0, -1) ; | If UBound($networkRange, 0) > 2 Then Return SetError(2, 0, -1) ; | max 2D array If UBound($networkRange, 0) = 1 Then ; | $aArray = $networkRange ; $aArray = all IP to scan | Else ; ----- it is a 2D array ----- | ; the number of the column with addresses is in $MyMask parameter | If $MyMask > UBound($networkRange, 2) - 1 Then Return SetError(2, 0, -1) ; | wrong column Local $aArray[UBound($networkRange)] ; | For $i = 0 To UBound($networkRange) - 1 ; | $aArray[$i] = $networkRange[$i][$MyMask] ; | Next ; | EndIf ; | ; ------------------------------------------------------------------------------+ ElseIf _isIPaddr($networkRange) Then ; single IP ; ConsoleWrite("debug: single IP value received" & @CRLF) If $MyMask <> "" Then ; is there a subnet? If Not _isSNmask($MyMask) Then ; wrong 4 digit mask If $MyMask > 0 And $MyMask < 33 Then ; is it a CIDR notation number? (nr. of bits of mask (1 to 32)) $MyMask = _CIDR_To_Mask($MyMask) Else Return SetError(4, 0, -1) ; wrong mask provided EndIf EndIf $networkRange = _Make_Range($networkRange, $MyMask) ; generate the "range" of all IP belonging to that subnet mask EndIf EndIf If Not IsArray($networkRange) Then ; ConsoleWrite("debug: Is not an Array" & @CRLF) ; if $networkRange is NOT an array then it is a "range" ; either passed as parameter by caller or generated by above checks $aArray = _GetIpAddressList($networkRange) ; Generate the list of IP to be pinged If @error Then Return SetError(5, 0, -1) ; IP range error EndIf ; ; _ArrayDisplay($aArray,"debug") ; $aArray should contain the IP to be pinged by _nPing ; ; *********************************************************************************************************** ; here start of nping core by Manadar (slightly modified) ; http://www.autoitscript.com/forum/topic/108060-nping-console-network-pinger-network-sweeper-network-scanner ; *********************************************************************************************************** If $ReturnFlag = 0 Then ; make room for all clients ReDim $_IPup[UBound($aArray) + 1][4] ; $_IPup will contain results EndIf Local $aProcess[$MAX_PROCESS] ; An array to keep a reference to spawned processes, in the next loop we fill it with value 0 for reference For $i = 0 To UBound($aProcess) - 1 $aProcess[$i] = 0 Next Local $i = 0 ; which IP are we currently trying to ping ( based on array ) Local $iFinished = 0 ; how many processes have finished pinging Local $iUp = 0 ; Total hosts that are UP Local $iDown = 0 ; Total hosts that are DOWN Local $iTotalRoundTrip = 0 ; Total roundtrip (all the +ms added together) While 1 ; We check all the currently running processes For $n = 0 To UBound($aProcess) - 1 ; Check if we need a spot, and there is an existing spot here If ($i <> UBound($aArray) And $aProcess[$n] == 0) Then $aProcess[$n] = _MSPing($i, $aArray[$i]) ; Start a new Ping process $i += 1 ; Increment $i so we can do the next process the next time around Else ; Check if this process has been spawned and the process is ready If ($aProcess[$n] <> 0 And _MSPingIsReady($aProcess[$n])) Then ; has finished to ping ; results of endings pings. (Get results from the various Pimg commands) $sHostname = _MSPingGetHostname($aProcess[$n]) $sResult = _MSPingGetResult($aProcess[$n]) $sIndex = ___MSPingGetIndex($aProcess[$n]) ; new, added by me (zero based) ; ConsoleWrite("debug: " & $sIndex & " : " & $sHostname & " : " & $sResult & @CRLF) ; -------------------------------------------------------------------------------------------------------------------------------------------------------------- If ($sResult <> -1) Then ; current IP is UP ; ConsoleWrite("debug: " & $sHostname & " has a roundtrip of " & $sResult & " ms" & @CRLF) $iUp += 1 If $ReturnFlag < 2 Then ; if return all(0) or responding only(1) If $ReturnFlag = 1 Then ; 1 = return back only responding IP ReDim $_IPup[$iUp + 1][4] $_IPup[$iUp][3] = $sIndex ; the index of the passed array that contains this IP $sIndex = $iUp Else ; $ReturnFlag = 0 Then keep all clients $sIndex += 1 $_IPup[$sIndex][3] = $sIndex - 1 EndIf $_IPup[$sIndex][0] = $sHostname If $Resolve Then ; ------------ resolve IP to hostname ------------ If _isIPaddr($_IPup[$sIndex][0]) Then ; is it an IP ? (or an hostname) If $dig Then ; resolve with dig if is present (much faster especially on passive devices without a host name) Local $digID = Run(".\dig\dig.exe -x " & $_IPup[$sIndex][0] & " +short", "", @SW_HIDE, 0x2) Do $_IPup[$sIndex][1] &= StdoutRead($digID) ; resolved IP to name (if resolvable else empty) Until @error Else ; _TCPIpToName is very slow to return if the remote IP do not belongs to a windows client (example a printer or a router) $_IPup[$sIndex][1] = _TCPIpToName($_IPup[$sIndex][0]) EndIf Else $_IPup[$sIndex][1] = $_IPup[$sIndex][0] EndIf EndIf ; End of name resolution ------------------------------------- $_IPup[$sIndex][2] = $sResult ; roundtrip of the ping $iTotalRoundTrip += $sResult EndIf Else ; current IP is down ---------------------------------------------------------------------------------------------------------------------------------------- $iDown += 1 If $ReturnFlag = 0 Then ; 0 return back all IP, responding and not responding $sIndex += 1 $_IPup[$sIndex][0] = $sHostname $_IPup[$sIndex][1] = -1 ; loockup name $_IPup[$sIndex][2] = -1 ; roundtrip $_IPup[$sIndex][3] = $sIndex - 1 ; ElseIf $ReturnFlag = 1 Then ; $ReturnFlag = 1 return only responding ; nothing to store ElseIf $ReturnFlag = 2 Then ; $ReturnFlag = 2 return only not responding ReDim $_IPup[$iDown + 1][4] $_IPup[$iDown][0] = $sHostname $_IPup[$iDown][1] = -1 $_IPup[$iDown][2] = -1 $_IPup[$iDown][3] = $sIndex $sIndex = $iDown EndIf EndIf ; *************************************************** ; Free up an empty space for the next address to Ping $aProcess[$n] = 0 ; Increment the total of processes that have finished $iFinished += 1 If ($sResult <> -1 And $ReturnFlag <> 2) Or ($sResult = -1 And $ReturnFlag <> 1) Then ; call an UDF to track and manage what's going on during the scan; ; an array is passed to the called function with the following 6 parameters: ; 0) nr. of total addresses under process ; 1) nr. of ping already finished ; 2) IP just processed ; 3) resolved Host name or -1 if IP is down ; 4) roundtrip of this ping or -1 if IP is down ; 5) Index of this IP within the caller's passed array ; by default is called the _Progress() function that will display the progress bar Local $aPass_Args[6] = [UBound($aArray), $iFinished, $_IPup[$sIndex][0], $_IPup[$sIndex][1], $_IPup[$sIndex][2], $_IPup[$sIndex][3]] Local $aArgs[2] = ["CallArgArray", $aPass_Args] Call($MyFunction, $aArgs) Else Local $aPass_Args[6] = [UBound($aArray), $iFinished, $sHostname, -1, -1, $sIndex] Local $aArgs[2] = ["CallArgArray", $aPass_Args] Call($MyFunction, $aArgs) EndIf ; If the total number of finished processes If ($iFinished == UBound($aArray)) Then ExitLoop 2 ; Exit -----+ EndIf ; | EndIf ; | Next ; | Sleep(50) ; Give existing ping commands some time to process the request | WEnd ; | ; <-------------------+ ; fill record [0] If $ReturnFlag = 0 Then ; return all $_IPup[0][0] = $iUp + $iDown $_IPup[0][1] = $iUp ; $iTotalRoundTrip ; $_IPup[0][2] = $iDown ElseIf $ReturnFlag = 1 Then ; return only up $_IPup[0][0] = $iUp $_IPup[0][1] = $iTotalRoundTrip ; $_IPup[0][2] = $iDown ElseIf $ReturnFlag = 2 Then ; return only down $_IPup[0][0] = $iDown $_IPup[0][1] = -1 ; $_IPup[0][2] = $iUp EndIf Return $_IPup ; - - - The end of scan - - - EndFunc ;==>_nPing Func _GetIpAddressList($ipFormat) ; Generate the IP list to Ping If $ipFormat = "" Then Return SetError(5, 0, -1) ; no IP to ping EndIf $ipFormat = StringReplace($ipFormat, "*", "1-255") ; change * with "1-255" $ipSplit = StringSplit($ipFormat, ".") If $ipSplit[0] <> 4 Then ; if it is not an IP address then check if it is an hostname Static $TCP = TCPStartup() Local $ret[1] = [TCPNameToIP($ipFormat)] ; from hostname to IP If @error Then Return SetError(6, @error, -1) ; windows API WSAGetError Windows Sockets Error in @extended Return $ret ; -----> return EndIf For $i = 1 To 4 ; controls once again If Not StringRegExp($ipSplit[$i], "[0-9\-]*") Then ; are 4 octets numbers Static $TCP = TCPStartup() Local $ret[1] = [TCPNameToIP($ipFormat)] ; if not number try to decode from host to IP If @error Then Return SetError(6, @error, -1) ; windows API WSAGetError. Windows Sockets Error in @extended Return $ret ; -----> return EndIf Next ; $ipFormat is not an hostname Local $ipRange[4][2], $totalPermu = 1 For $i = 0 To 3 If StringInStr($ipSplit[$i + 1], "-") Then ; control the presence of the "-" sign $m = StringSplit($ipSplit[$i + 1], "-") $ipRange[$i][0] = $m[1] $ipRange[$i][1] = $m[2] Else $n = Number($ipSplit[$i + 1]) $ipRange[$i][0] = $n $ipRange[$i][1] = $n EndIf $totalPermu *= $ipRange[$i][1] - $ipRange[$i][0] + 1 ; total number of IP to check If ($ipRange[$i][0] < 0 Or $ipRange[$i][0] > 255) Or ($ipRange[$i][1] < 0 Or $ipRange[$i][1] > 255) Then Return SetError(3, 0, -1) ; wrong IP Next If $totalPermu > 16777216 Then ; > $MAX_HOSTS Return SetError(1, String($totalPermu), -1) ; too many IP EndIf Local $result[$totalPermu], $i = 0 For $a = $ipRange[0][0] To $ipRange[0][1] For $b = $ipRange[1][0] To $ipRange[1][1] For $c = $ipRange[2][0] To $ipRange[2][1] For $d = $ipRange[3][0] To $ipRange[3][1] $result[$i] = $a & "." & $b & "." & $c & "." & $d ; $result contains the IP addresses to ping $i += 1 Next Next Next Next Return $result EndFunc ;==>_GetIpAddressList Func _Exit() Exit EndFunc ;==>_Exit Func _MSPing($Array_ndx, $sHostname, $timeout = 4000) ;$timeout = 50) ; start a new Ping Local $return_struc[5] ; [0] = Result (in ms) ; [1] = The hostname originally used ; [2] = Process handle (for internal use only) ; [3] = Buffer (for internal use only) ; [4] = Index of IP in source array **new** $return_struc[1] = $sHostname $return_struc[2] = Run("ping " & $sHostname & " -n 1 -w " & $timeout, "", @SW_HIDE, 0x2) ; 0x2 -> $STDOUT_CHILD) $return_struc[4] = $Array_ndx Return $return_struc EndFunc ;==>_MSPing Func _MSPingIsReady(ByRef $return_struc) ; check if Ping has finished Return ___MSPingReadOutput($return_struc) EndFunc ;==>_MSPingIsReady Func _MSPingGetResult($return_struc) Return $return_struc[0]; [0] = Result (in ms) EndFunc ;==>_MSPingGetResult Func _MSPingGetHostname($return_struc) ; returns the hostname Return $return_struc[1]; [1] = The hostname originally used EndFunc ;==>_MSPingGetHostname ; Internal use only Func ___MSPingReadOutput(ByRef $return_struc) ; peek result of DOS Ping command $data = StdoutRead($return_struc[2]) ; [2] = Process handle (for internal use only) If (@error) Then ; if ping has finished ___MSPingParseResult($return_struc) ; extract time taken by ping Return 1 ; 1 = finished Else $return_struc[3] &= $data ; [3] = Buffer (for internal use only) ; contains DOS output Return 0 ; 0 = not yet finished EndIf EndFunc ;==>___MSPingReadOutput ; Internal use only Func ___MSPingParseResult(ByRef $return_struc) ; extract from Ping command the millisecond value $result = StringRegExp($return_struc[3], "([0-9]*)ms", 3); [3] = DOS command output is here If @error Then $return_struc[0] = -1 ; [0] = Result (in ms) -1 if error Else $return_struc[0] = $result[0] ; returns the first millisecond value retrieved from Ping EndIf EndFunc ;==>___MSPingParseResult ; Internal use only - new (added by me) Func ___MSPingGetIndex(ByRef $return_struc) ; Index of the current IP in passed array Return $return_struc[4] EndFunc ;==>___MSPingGetIndex ; = = = = = net related functions = = = = = Func _Make_Range($ipLan, $sMask) ; Given an IP and his mask, this function return the full LAN "range" for _nPing Local $aLan = _GetLanParameters($ipLan, $sMask) If @error Then Return SetError(@error, @extended, -1) Return $aLan[7][0] EndFunc ;==>_Make_Range Func _GetLanParameters($theIP1, $sSubNet) ; ------------------------------------------ ; calculate all IP/subnet related parameters ; ------------------------------------------ If Not _isIPaddr($theIP1) Then Return SetError(3, 0, -1) ; wrong IP address ;check on subnet If Not _isSNmask($sSubNet) Then ; it is not a valid 4 digit subnet If $sSubNet > 0 And $sSubNet < 33 Then ; is it a CIDR notation number? nr. of bits 1 to 32 $sSubNet = _CIDR_To_Mask($sSubNet) Else Return SetError(4, 0, -1) ; wrong Mask provided EndIf EndIf Local $aLan[8][5] ; net parameters container Local $sDot[2] = ['', '.'] ; used as IP octets separator Local $aIP = StringSplit($theIP1, '.'), $aSubNet = StringSplit($sSubNet, '.') ; split IP address in single octets and calculate related parameters For $i = 1 To 4 $aLan[0][$i] = $aIP[$i] ; IP $aLan[1][$i] = $aSubNet[$i] ; NetMask $aLan[2][$i] = BitNOT($aLan[1][$i] - 256) ; Wildcard, is the inverse of subnet: BitNot($NetMask - 256) $aLan[3][$i] = BitAND($aLan[0][$i], $aLan[1][$i]) ; LanAddress BitAnd(IP, netmask) $aLan[4][$i] = BitOR($aLan[0][$i], $aLan[2][$i]) ; Broadcast address $aLan[5][$i] = $aLan[3][$i] ; preset First host ; will be $NetAddress + 1 $aLan[6][$i] = $aLan[4][$i] ; preset Last host ; will be $Broadcast -1 Next If $sSubNet <> "255.255.255.255" Then $aLan[5][4] = BitOR($aLan[5][4], 1) ; First host $NetAddress + 1 (Turn last bit ON) $aLan[6][4] = BitAND($aLan[6][4], 254) ; Last host $Broadcast -1 (Turn last bit OFF) EndIf For $i = 1 To 4 $aLan[0][0] &= $aLan[0][$i] & $sDot[$i < 4] ; [0] IP $aLan[1][0] &= $aLan[1][$i] & $sDot[$i < 4] ; [1] NetMask $aLan[2][0] &= $aLan[2][$i] & $sDot[$i < 4] ; [2] Wildcard $aLan[3][0] &= $aLan[3][$i] & $sDot[$i < 4] ; [3] Network $aLan[4][0] &= $aLan[4][$i] & $sDot[$i < 4] ; [4] Broadcast $aLan[5][0] &= $aLan[5][$i] & $sDot[$i < 4] ; [5] First host $aLan[6][0] &= $aLan[6][$i] & $sDot[$i < 4] ; [6] Last host ; [7][0] Range for _nPing If $aLan[5][$i] = $aLan[6][$i] Then $aLan[7][0] &= $aLan[5][$i] & $sDot[$i < 4] Else $aLan[7][0] &= $aLan[5][$i] & "-" & $aLan[6][$i] & $sDot[$i < 4] EndIf Next ; MsgBox(0, "net", "IP address: " & @TAB & $aLan[0][0] & @CRLF & "Subnet: " & @TAB & $aLan[1][0] & @CRLF & "Wildcard: " & @TAB & $aLan[2][0] & @CRLF & "Network: " & @TAB & $aLan[3][0] & @CRLF & "Broadcast: " & @TAB & $aLan[4][0] & @CRLF & "First host: " & @TAB & $aLan[5][0] & @CRLF & "Last host: " & @TAB & $aLan[6][0]) ; _ArrayDisplay($aLan, "IP/subnet related parameters") Return $aLan EndFunc ;==>_GetLanParameters ; #FUNCTION# ==================================================================================================================== ; Name...........: _LanParameters ; Description ...: given an IP and his subnet returns [and displays] the following values in dec and binary format: ; |IP Address ; |Netmask ; |Wildcard ; |Network Address ; |Broadcast Address ; |First host ; |Last host ; Syntax.........: _LanParameters([$IP, $Subnet]) ; Parameters ....: ; ; Return values .: ; Author ........: ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _LanParameters($theIP1 = "", $sSubNet = "255.255.255.255", $Msg = 0) Static $TCP = TCPStartup() If $theIP1 = "" Then $theIP1 = TCPNameToIP(@ComputerName) $sSubNet = _GetSubnetMask($theIP1) ElseIf $sSubNet = "" Then $sSubNet = "255.255.255.255" EndIf If Not _isSNmask($sSubNet) Then ; it is not a 4 digit subnet If $sSubNet > 0 And $sSubNet < 33 Then ; is it a CIDR notation number? nr. of bits 1 to 32 $sSubNet = _CIDR_To_Mask($sSubNet) Else Return SetError(4, 0, False) ; wrong mask EndIf EndIf Local $aLan = _GetLanParameters($theIP1, $sSubNet) Local $LanID[7][3] $LanID[0][0] = "IP Address " $LanID[1][0] = "Netmask " $LanID[2][0] = "Wildcard " $LanID[3][0] = "Network Address " $LanID[4][0] = "Broadcast Address" $LanID[5][0] = "First host " $LanID[6][0] = "Last host " For $i = 0 To 6 $LanID[$i][1] = $aLan[$i][0] $LanID[$i][2] = _Convert_To_Binary($aLan[$i][1]) & "." & _Convert_To_Binary($aLan[$i][2]) & "." & _Convert_To_Binary($aLan[$i][3]) & "." & _Convert_To_Binary($aLan[$i][4]) Next If $Msg Then MsgBox(0, "Lan IDs", $LanID[0][0] & @TAB & $LanID[0][2] & @TAB & $LanID[0][1] & @CRLF & _ $LanID[1][0] & "( " & _Mask_To_CIDR($LanID[1][1]) & " ) " & @TAB & $LanID[1][2] & @TAB & $LanID[1][1] & @CRLF & _ $LanID[2][0] & @TAB & $LanID[2][2] & @TAB & $LanID[2][1] & @CRLF & _ $LanID[3][0] & @TAB & $LanID[3][2] & @TAB & $LanID[3][1] & @CRLF & _ $LanID[4][0] & @TAB & $LanID[4][2] & @TAB & $LanID[4][1] & @CRLF & _ $LanID[5][0] & @TAB & $LanID[5][2] & @TAB & $LanID[5][1] & @CRLF & _ $LanID[6][0] & @TAB & $LanID[6][2] & @TAB & $LanID[6][1] & @CRLF) Return $LanID EndFunc ;==>_LanParameters ; #FUNCTION# ==================================================================================================================== ; Name...........: _CIDR_To_Mask ; Description ...: transform a CIDR number (1 - 32) to the corresponding 4 digit mask ; Syntax.........: _CIDR_To_Mask($CIDR) ; Parameters ....: $CIDR a number from 1 to 32 ; Return values .: a 4 bite corresponding subnet mask ; =============================================================================================================================== Func _CIDR_To_Mask($sSubNet) ; From nr. of bit to 4 digit mask $sSubNet = StringLeft(StringLeft("11111111111111111111111111111111", $sSubNet) & "0000000000000000000000000000000", 32) $sSubNet = _Bin_To_Dec(StringLeft($sSubNet, 8)) & "." & _Bin_To_Dec(StringMid($sSubNet, 9, 8)) & "." & _Bin_To_Dec(StringMid($sSubNet, 17, 8)) & "." & _Bin_To_Dec(StringRight($sSubNet, 8)) Return $sSubNet EndFunc ;==>_CIDR_To_Mask ; #FUNCTION# ==================================================================================================================== ; Name...........: _Mask_To_CIDR ; Description ...: transform a 4 digit mask to the corresponding CIDR number (1 - 32) ; Syntax.........: _Mask_To_CIDR($SubnetMask) ; Parameters ....: $SubnetMask a 4 bite subnet mask ; Return values .: the corresponding CIDR ; =============================================================================================================================== Func _Mask_To_CIDR($sSubNet) ; from 4 digit mask to nr. of bits If _isSNmask($sSubNet) Then Local $Digit = StringSplit($sSubNet, ".", 2) Return StringInStr(_Convert_To_Binary($Digit[0]) & _Convert_To_Binary($Digit[1]) & _Convert_To_Binary($Digit[2]) & _Convert_To_Binary($Digit[3]), "1", 0, -1) Else Return SetError(4, 0, False) ; wrong mask EndIf EndFunc ;==>_Mask_To_CIDR ; _GetSubnetMask ; #FUNCTION# ==================================================================================================================== ; Name...........: _GetSubnetMask ; Description ...: given the local IP returns the related subnet mask (thanks to dragan) ; http://www.autoitscript.com/forum/topic/155078-how-to-easily-get-the-subnet-mask/?p=1120929 ; Syntax.........: _GetSubnetMask($LocalIP) ; Parameters ....: $LocalIP IP of the local computer ; Return values .: the corresponding subnet mask ; =============================================================================================================================== Func _GetSubnetMask($theIP) ; given the local IP returns the related subnet mask Local Const $tagIP_ADDRESS_STRING = "char IPAddress[16];" Local Const $tagIP_MASK_STRING = "char IPMask[16];" Local Const $tagIP_ADDR_STRING = "ptr Next;" & $tagIP_ADDRESS_STRING & $tagIP_MASK_STRING & "DWORD Context;" Local Const $tagIP_ADAPTER_INFO = "ptr Next; DWORD ComboIndex; char AdapterName[260];char Description[132]; UINT AddressLength; BYTE Address[8]; dword Index; UINT Type;" & _ " UINT DhcpEnabled; ptr CurrentIpAddress; ptr IpAddressListNext; char IpAddressListADDRESS[16]; char IpAddressListMASK[16]; DWORD IpAddressListContext; " & _ "ptr GatewayListNext; char GatewayListADDRESS[16]; char GatewayListMASK[16]; DWORD GatewayListContext; " & _ "ptr DhcpServerNext; char DhcpServerADDRESS[16]; char DhcpServerMASK[16]; DWORD DhcpServerContext; " & _ "int HaveWins; " & _ "ptr PrimaryWinsServerNext; char PrimaryWinsServerADDRESS[16]; char PrimaryWinsServerMASK[16]; DWORD PrimaryWinsServerContext; " & _ "ptr SecondaryWinsServerNext; char SecondaryWinsServerADDRESS[16]; char SecondaryWinsServerMASK[16]; DWORD SecondaryWinsServerContext; " & _ "DWORD LeaseObtained; DWORD LeaseExpires;" Local $dll = DllOpen("Iphlpapi.dll") If @error Then Return SetError(8, @error, 0); <----------- error 'dll open: Iphlpapi.dll' Local $ret = DllCall($dll, "dword", "GetAdaptersInfo", "ptr", 0, "dword*", 0) If @error Then DllClose($dll) Return SetError(8, @error, 0); <----------- error 'dll call function: GetAdaptersInfo' EndIf Local $adapterBuffer = DllStructCreate("byte[" & $ret[2] & "]") Local $adapterBuffer_pointer = DllStructGetPtr($adapterBuffer) DllCall($dll, "dword", "GetAdaptersInfo", "ptr", $adapterBuffer_pointer, "dword*", $ret[2]) If @error Then $adapterBuffer = "" $adapterBuffer_pointer = "" DllClose($dll) Return SetError(8, @error, 0); <----------- error 'dll call function: GetAdaptersInfo with adapter buffer pointer' EndIf Local $adapter = DllStructCreate($tagIP_ADAPTER_INFO, $adapterBuffer_pointer) Local $IPType = -1 Local $FoundIt = False Local $retVal = "" Do ; -------------------- IP search -------------------- $Ptr = DllStructGetPtr($adapter, "IpAddressListNext") Local $IPStruct, $Index = 0 Local $allArray[1][3] Do ReDim $allArray[$Index + 1][3] $IPStruct = DllStructCreate($tagIP_ADDR_STRING, $Ptr) $allArray[$Index][0] = DllStructGetData($IPStruct, "IPAddress") $allArray[$Index][1] = DllStructGetData($IPStruct, "IPMask") $allArray[$Index][2] = DllStructGetData($IPStruct, "Context") $Ptr = DllStructGetData($IPStruct, "Next") $Index += 1 Until $Ptr = 0 For $i = 0 To UBound($allArray) - 1 If $allArray[$i][0] <> $theIP Then ContinueLoop ; >-+ $retVal = $allArray[$i][1] ; | $IPType = 0 ; | $FoundIt = True ; | ExitLoop ; if found do not search over | Next ; <-------+ If $FoundIt Then ExitLoop ; >---------------------------+ $Ptr = DllStructGetData($adapter, "Next") ; | $adapter = DllStructCreate($tagIP_ADAPTER_INFO, $Ptr); | Until @error ; | ; <---------------------------+ $adapterBuffer = "" $adapterBuffer_pointer = "" DllClose($dll) If Not $FoundIt Then Return SetError(3, 0, 0) ; IP not found <----------- error Return SetError(0, $IPType, $retVal) ; OK Return mask EndFunc ;==>_GetSubnetMask Func _isIPaddr($sIPAddr) ; returns true if argument is a plausible IP address If Not StringRegExp($sIPAddr, "^((25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(25[0-5]|2[0-4]\d|[01]?\d?\d)$") Then Return SetError(1, 0, False) Return True EndFunc ;==>_isIPaddr Func _isSNmask($sSNmask) ; returns true if argument is a correct 4 digit network mask If Not StringRegExp($sSNmask, "^(((255\.){3}(255|254|252|248|240|224|192|128|0+))|((255\.){2}(255|254|252|248|240|224|192|128|0+)\.0)|((255\.)(255|254|252|248|240|224|192|128|0+)(\.0+){2})|((255|254|252|248|240|224|192|128|0+)(\.0+){3}))$") Then Return SetError(1, 0, False) Return True EndFunc ;==>_isSNmask Func _Progress($aArgs) ; Func _Progress($ToDo, $Done, $Dummy1, $Dummy2, $Dummy3, $Dummy4) ; this will show the progress bar while scanning ; $_Percent = Int($Done / $ToDo * 100) $_Percent = Int($aArgs[1] / $aArgs[0] * 100) Static $_Progress = 0 If Not $_Progress Then ProgressOn("Progress Meter", "Pinged address ", $aArgs[1] & "/" & $aArgs[0] & " ( 0 %)", -1, -1, 16) $_Progress = 1 EndIf ProgressSet($_Percent, $aArgs[1] & "/" & $aArgs[0] & " ( " & $_Percent & " %)", "Pinged address " & $aArgs[2]) If $_Percent = 100 Then ProgressSet(100, "Done", "Complete") Sleep(500) ProgressOff() $_Progress = 0 EndIf EndFunc ;==>_Progress Func _Convert_To_Binary($iNumber) ; from decimal to binary ; http://www.autoitscript.com/forum/topic/90056-decimal-to-binary-number-converter/?p=647505 Local $sBinString = "" While $iNumber $sBinString = BitAND($iNumber, 1) & $sBinString $iNumber = BitShift($iNumber, 1) WEnd ; limit returned value to 8 bit 0 - 255 Return StringRight("00000000" & $sBinString, 8) EndFunc ;==>_Convert_To_Binary Func _Bin_To_Dec($BinNum) ; from binary to decimal Local $dec = 0 For $i = 0 To StringLen($BinNum) - 1 $dec += 2 ^ $i * StringMid($BinNum, StringLen($BinNum) - $i, 1) Next Return $dec EndFunc ;==>_Bin_To_Dec ; #FUNCTION# ==================================================================================================================== ; Name...........: _FileReadToArray_mod ; Description ...: read a file to an array and if is passed a separator and a column number extract only that column (from a csv) ; Syntax.........: _FileReadToArray_mod($sFilePath, $delim = ";") ; Parameters ....: |$sFilePath - path and filename of the file to read ; |$delim - the character separator of the values in the csv ; Remarks .......: if the file is not a csv and contains only one IP per line then $delim is ignored ; Return values .: an 1D array containing the "IP" extracted from the $col column. First column is nr.0 ; =============================================================================================================================== ; Func _FileReadColumnToArray($sFilePath, $delim = ";", $col = 0) Func _FileReadToArray_mod($sFilePath, $delim = ";") ; this function is extracted, adapted and slightly modified from the _FileReadToArray() function in file.au3 Local $aArray Local $hFile = FileOpen($sFilePath, 0); $FO_READ) If $hFile = -1 Then Return SetError(1, 0, 0);; unable to open the file ;; Read the file and remove any trailing white spaces Local $aFile = FileRead($hFile, FileGetSize($sFilePath)) FileClose($hFile) ;~ $aFile = StringStripWS($aFile, 2) ; remove last line separator if any at the end of the file If StringRight($aFile, 1) = @LF Then $aFile = StringTrimRight($aFile, 1) If StringRight($aFile, 1) = @CR Then $aFile = StringTrimRight($aFile, 1) If StringInStr($aFile, @LF) Then $aArray = StringSplit(StringStripCR($aFile), @LF) ElseIf StringInStr($aFile, @CR) Then ;; @LF does not exist so split on the @CR $aArray = StringSplit($aFile, @CR) Else ;; unable to split the file If StringLen($aFile) Then Dim $aArray[2] = [1, $aFile] ; returns the whole file in one element Else Return SetError(2, 0, 0) ; File is empty EndIf EndIf ; now split 1D $aArray to 2D $aColumns according to delimiter Local $aColumns[$aArray[0]][1] ; create a new [2D] array with same nr. of lines of $aArray For $i = 1 To $aArray[0] ; scan all lines of the array $TempRow = StringSplit($aArray[$i], $delim, 2) ; split the line If UBound($TempRow) > UBound($aColumns, 2) Then ReDim $aColumns[$aArray[0]][UBound($TempRow)] For $ii = 0 To UBound($TempRow) - 1 $aColumns[$i - 1][$ii] = $TempRow[$ii] Next Next Return $aColumns EndFunc ;==>_FileReadToArray_mod Func _ExtractColumnFromArray($aArray, $col = 0) If 1 = UBound($aArray, 0) Then If $col = 0 Then Return $aArray ; already a single column array, send it back as is Else Return SetError(2, 0, -1) ; wrong column number EndIf EndIf If $col >= UBound($aArray, 2) Then Return SetError(2, 0, -1) ; wrong column number Local $aColumn[UBound($aArray)] ; create a new [1D] array For $i = 0 To UBound($aArray) - 1 ; scan all lines of the array $aColumn[$i] = $aArray[$i][$col] Next Return $aColumn EndFunc ;==>_ExtractColumnFromArray Basic Example of use: #include 'MultiPing.au3' #include <array.au3> MsgBox(0, "Hello", "The _nPing() function will ping ranges of IP addresses" & @CRLF & @CRLF & _ "if called without arguments, it will try to detect your LAN parameters" & @CRLF & _ "and then will ping all your LAN addresses, returninig a list of responding IP." & @CRLF & @CRLF & _ "First a detection of the LAN is performed and result displayed" & @CRLF & @CRLF & _ "Press OK to detect:") $lan = _LanParameters("", "", 1) ; with the first 2 argument blank, will detect local LAN ; the third parameter 1 means show results MsgBox(0, "Hello", "OK, now the full IP range will be pinged." & @CRLF & "In this example only the addresses of responding devices" & @CRLF & _ "will be returned in the array (default)," & @CRLF & _ "but the function can also return:" & @CRLF & _ " 0 the whole list of IPs" & @CRLF & _ " 1 only responding IPs" & @CRLF & _ " 2 only not responding IPs" & @CRLF & @CRLF & _ "Press OK to ping from IP " & $lan[5][1] & " to IP " & $lan[6][1]) ; simplest way to use: without parameters ; will scan all your local LAN ; and display only responding IP Local $Result = _nPing() If @error Then MsgBox(0, "", "@error " & @error) _ArrayDisplay($Result) MsgBox(0, "", "Another way to use is to read a list of IP from a file (csv or single column)" & @CRLF & _ "into an array and pass the array to the function" & @CRLF & _ "if the array is 1D then is passed as is" & @CRLF & _ "if the array is 2D (because a csv was read) the first column is passed," & @CRLF & _ "but if you want to pass another column of the 2D array then" & @CRLF & _ "just pass the column number (zero based) as second parameter (first column is 0)" & @CRLF & _ "In this example the IP are in column 1" & @CRLF & @CRLF & _ "Press OK to read the file") ; read the file in an array ; use the ";" as fields separator $IPlist = _FileReadToArray_mod(".\IP_List.txt", ";") If Not @error Then _ArrayDisplay($IPlist, "Data read from file") ; show array content $Result = _nPing($IPlist, 1); pass the second column to the function If @error Then MsgBox(0, "", "@error " & @error) _ArrayDisplay($Result) ; display the result of the pings Else MsgBox(0, "", "@error " & @error) EndIf IP_List.txt Google;173.194.36.50 AutoIT;87.106.181.57 YouTube;74.125.228.65 Google.com;74.125.224.72 Gmail.com;74.125.224.181 Bing.com;131.253.13.32 Hotmail.com;65.55.72.135 Yahoo.com;98.139.183.24 Amazon.com;72.21.211.176 Facebook.com;69.171.234.21 Facebook.com;69.63.176.13 Facebook.com;69.63.181.15 Facebook.com;69.63.184.142 Facebook.com;69.63.187.17 Facebook.com;69.63.187.18 Facebook.com;69.63.187.19 Facebook.com;69.63.181.11 Facebook.com;69.63.181.12 Twitter.com;199.59.148.10 Twitter.com;199.59.149.230 LinkedIn.com;216.52.242.86 WordPress.com;76.74.254.126 WordPress.org;72.233.56.138 Tumblr.com;174.121.194.34 Livejournal.com;209.200.154.225 Reddit.com;64.208.126.67 Imgur.com;173.231.140.219 Pinterest.com;23.21.142.179 Instagram.com;23.23.130.59 Stickam.com;67.201.54.151 Blogtv.com;84.22.170.149 Justin.tv;199.9.249.21 ChatRoulette.com;184.173.141.231 Newegg.com;216.52.208.187 ThePirateBay.org;194.71.107.50 Movie2k.com;109.163.226.240 PayPal.com;173.0.84.3 Botcrawl.com;174.132.77.244
    1 point
  3. This is a simple and practical way to start and manage many processes. I use it to quickly query many remote clients for varyous informations. For processes I mean external programs that can run autonomously and that allows I/O redirection. Here the advantage is that when you start a process, you can also determine which function in your main program should receive results when the external process finishes executing. So you can have different processes and different "callback" functions. The whole works nearly autonomously and asynchronously. While spawned processes works, you can perform other tasks in the main script and leave the worry of receiving and managing the results, to the pre-established functions. As I sayd, everything is almost completely automatic and the processes do their work asynchronously and independently of the flow of the main script. To check and manage processes status, you have only to call as often as possible the _TasksCheckStatus() function that will quickly handle the running processes. AdlibRegister() could be used for this ripetitive "polling". In short: 1) setup single commandlines that will "generate" your wanted result 2) establish wich function of your main script should receive the above result 3) an optional Timeout in seconds is allowed (task from point 1 will be killed at timeout) see function header for details. The provided example of use, needs to be executed in a network environment with preferably many clients, and you have to be administrator. Populate the $aIPList[] array with ClientNames (or ip addresses), and this example script will query all the clients about some informations by running many processes asincronously. Then it will collect results from the processes as soon as "answers" are available and will populate the ListView with that data. I used a ListView so that you can see that all the cells will fill (quite quickly) in an asynchronous way. If you are not in a network with many clients, then this example is nearly useless... (sorry) Hope it can be of use... (suggestions, bug reports and emrovements are welcome) MultiTask.udf #include-once ; #include "Array.au3" ; #INDEX# ======================================================================================================================= ; Title .........: Multi Task Management (tasks spawned by the user via the _TaskRun function of this udf) ; AutoIt Version : ; Language ......: ; Description ...: Functions that assists to execute and manage user's spawned tasks. ; Author(s) .....: Chimp ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _TaskRun Run a new task and stacks its references for later use ; _TasksCheckStatus Check the status of all running tasks and call the CallBack function when a task completed ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; __TaskRemove frees task's stacked references ; __NOP No OPeration function ; =============================================================================================================================== Global $aTasks[1][7] = [[0]] ; Create and initialize the task reference stack to 0 ; #FUNCTION# ==================================================================================================================== ; Name ..........: _TaskRun ; Description ...: Runs a new task as specified in $sCommand ; Syntax ........: _TaskRun($vIndex, $sCommand[, $sParser = "__NOP"[, $vTimeout = False]]) ; Parameters ....: $vIndex - A variant value passed by the caller as a reference to this task. ; this value will be returned to the callback function along with results. ; ; $sCommand - A string value containing the full command to be executed ; ; $sParser - [optional] The name of the function to be called at the end of this task. ; Default is __NOP that is a "do nothing" function. ; P.S. ; the $aParser function will be called by the _TasksCheckStatus() function when ; this task will finish to run: ; an 1D array with 4 elements will be passed to the called function: ; element [0] the caller's index reference of this task ; element [1] the StdOut result of this task ; element [2] the StdErr result of this task ; element [3] the time spent by this task ; ; $vTimeout - [optional] A variant value. Default is False. ; if specified is the number of seconds for the Timeout. ; After this amount of seconds, if this task is still running, it is killed ; ; Return values .: the total number of stacked tasks ; Author ........: Chimp ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _TaskRun($vIndex, $sCommand, $sParser = "__NOP", $vTimeout = False) ; ; Stack structure: ; ; +-----+ ; 0 | nr. | <-- [0][0] number of running tasks ; +-----+-----+-----+-----+-----+-----+-----+ ; 1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | ; +-----+-----+-----+-----+-----+-----+-----+ ; n | * | * | * | * | * | * | * | ; | | | | | | | ; | | | | | | [n][6] setted with the TimerInit() value at the start of this task. ; | | | | | | ; | | | | | [n][5] contains the required Timeout in seconds (Default is set to False = no timeout) ; | | | | | ; | | | | [n][4] The CallBack function name that will receive the results of this task ; | | | | ; | | | [n][3] the error message returned by the StdErr stream of this task ; | | | ; | | [n][2] the result of the command returned by the StdOut stream of this task ; | | ; | [n][1] the reference of this task passed by the user (will be passed back to the caller along with results) ; | ; [n][0] the PID of this running task ; ReDim $aTasks[$aTasks[0][0] + 2][7] ; add a new element to the stack $aTasks[0][0] += 1 ; add 1 to the number of running tasks ; Run the passed command with the I/O streams redirected $aTasks[$aTasks[0][0]][0] = Run($sCommand, "", @SW_HIDE, 6) ; 6 -> $STDOUT_CHILD (0x2) + $STDERR_CHILD (0x4) ; store references of this task to the stack $aTasks[$aTasks[0][0]][1] = $vIndex $aTasks[$aTasks[0][0]][4] = $sParser $aTasks[$aTasks[0][0]][5] = $vTimeout ; can be False or the number of seconds for the timeout of this task $aTasks[$aTasks[0][0]][6] = TimerInit() ; store the TimerInit() value for this task Return $aTasks[0][0] ; return the total number of running tasks EndFunc ;==>_TaskRun ; #FUNCTION# ==================================================================================================================== ; Name ..........: _TasksCheckStatus ; Description ...: Scans the status of all active tasks and checks if some task has finished its job ; This function should be called as aften as possible ; Syntax ........: _TaskCheckStatus() ; Parameters ....: None ; Return values .: number of still running tasks; * see remarks ; Author ........: Chimp ; Modified ......: ; Remarks .......: When a task finish, it is removed from the stack and results are passed to the callback function. ; An 1D array with 4 elements will be passed to the called function: ; element [0] the caller's index reference of this task ; element [1] the StdOut result of this task ; element [2] the StdErr result of this task ; element [3] the time spent by this task (approximative time) ; is an approximate datum because it also includes the delay ; added by the main loop before calling _TasksCheckStatus() ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _TasksCheckStatus() If $aTasks[0][0] = 0 Then Return 0 ; if no tasks then return Local $bEndTask ; will be setted to True if the checked task has finished or is killed by timeout Local $iPointer = 1 ; start checking from first task in the stack Local $aResults[4] ; this Array will be loaded with the results of the task Local $sCallBack ; the name of the function to call when a task ends its job Local $aArgs[2] = ["CallArgArray", ""] ; "special" array will be loaded with parameters for the CallBack function While $iPointer <= $aTasks[0][0] $bEndTask = False $aTasks[$iPointer][2] &= StdoutRead($aTasks[$iPointer][0]) ; read and store the StdOut stream $aTasks[$iPointer][3] &= StderrRead($aTasks[$iPointer][0]) ; read and store the StdErr stream ; If @error Then ; if there is an @error is because this task has finished its job If Not ProcessExists($aTasks[$iPointer][0]) Then ; if this task has finished its job $bEndTask = True ; flag the end of the work ElseIf $aTasks[$iPointer][5] <> False Then ; if task is still running see if a Timeout check was rquired and if so if is been reached If Int(TimerDiff($aTasks[$iPointer][6]) / 1000) >= $aTasks[$iPointer][5] Then ; timeout reached or exceeded!! $aTasks[$iPointer][3] = "@error Timeout " & $aTasks[$iPointer][3] ; insert an error message at the beginning of the StdErr stream StdioClose($aTasks[$iPointer][0]) ; close I/O streams ProcessClose($aTasks[$iPointer][0]) ; kill this process $bEndTask = True ; flag the end of this task EndIf EndIf If $bEndTask Then ; if this task has finished, get its results and send to the CallBack function $aResults[0] = $aTasks[$iPointer][1] ; ............. Index (the caller reference) $aResults[1] = $aTasks[$iPointer][2] ; ............. the StdOut generated by this task $aResults[2] = $aTasks[$iPointer][3] ; ............. the StdErr generated by this task $aResults[3] = TimerDiff($aTasks[$iPointer][6]) ; .. time spent by this task $sCallBack = $aTasks[$iPointer][4] ; the name of the function to be called $aArgs[1] = $aResults ; second element of the "CallArgArray" special array contains the $aResults array ; loaded with the parameters to be send to the CallBack function. (array in array) ; (the CallBack function will receive only the 1D 4 elements array $aResults) __TaskRemove($iPointer) ; remove references of this task from the stack ; call the CallBack function and pass the results of this task. ; (CallBack function should return as soon as possible because it stops the CheckStatus for the other tasks) ; Call($sCallBack, $aArgs) ; Call CallBack function --->---+ ; | ; <--- and return here ---------------------------------+ EndIf $iPointer += 1 ; check next task WEnd Return $aTasks[0][0] EndFunc ;==>_TasksCheckStatus ; Internal use. Remove the task references from the stack Func __TaskRemove($iElement) #cs If $iElement > $aTasks[0][0] Or $iElement < 1 Then Return StdioClose($aTasks[$iElement][0]) _ArrayDelete($aTasks, $iElement) #ce ; - new -------------------------------------------------- ; remove element without the _Array* udf If $iElement > 0 And $iElement <= $aTasks[0][0] Then StdioClose($aTasks[$iElement][0]) If $aTasks[0][0] > 1 Then For $i = 0 To UBound($aTasks, 2) - 1 $aTasks[$iElement][$i] = $aTasks[$aTasks[0][0]][$i] Next EndIf Else Return ; queue is empty or the required element is out of bound EndIf $aTasks[0][0] -= 1 ReDim $aTasks[$aTasks[0][0] + 1][UBound($aTasks, 2)] Return $aTasks[0][0] ; returns the number of tasks still running EndFunc ;==>__TaskRemove ; Internal use. An empty function Func __NOP($aDummy) ; NOP (No OPeration) EndFunc ;==>__NOP Example of use ; #RequireAdmin #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include '.\MultiTask.au3' ; ; IMPORTANT following array should be populated with many real HostNames ; here are just nonsense items used as placeholders Global $aIPList[] = [@ComputerName, @IPAddress1, @ComputerName, @ComputerName, 'InexistentClient', @ComputerName] Global $hGrid ; The ListView Handle Global $ahGrid[1] ; An array to keep handles of any listview row Example() MsgBox(0, "Debug:", "Done" & @CRLF & "Hit OK to exit") Func Example() Local $Form1 = GUICreate("Clients status", 760, 400) ; ; Create the ListView $hGrid = GUICtrlCreateListView("HostName|IP|Info|Last reboot|CPU|Last logon|Current logon", 0, 0, 760, 400) _GUICtrlListView_SetColumnWidth($hGrid, 0, 140) ; HostName _GUICtrlListView_SetColumnWidth($hGrid, 1, 100) ; IP _GUICtrlListView_SetColumnWidth($hGrid, 2, 80) ; Ping info ms or Off or Unknown or Timeout) _GUICtrlListView_SetColumnWidth($hGrid, 3, 120) ; Last Reboot _GUICtrlListView_SetColumnWidth($hGrid, 4, 40) ; cpu load ; last 2 columns a mutually exclusive. If there is a user logged it's shown on the last column ; if there is not a user logged then the last user that was logged is shown on column 4 instead _GUICtrlListView_SetColumnWidth($hGrid, 5, 140) ; Last logged UserId (if nobody is logged now) _GUICtrlListView_SetColumnWidth($hGrid, 6, 140) ; Currently logged UserId _GUICtrlListView_SetExtendedListViewStyle($hGrid, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) ; show grid; select whole row ; GUISetState(@SW_SHOW) ; following line is needed if you have to refill the listview ; _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hGrid)) ; empty the listview ReDim $ahGrid[UBound($aIPList)] ; this loop will run all needed tasks at once. ; The results of the tasks will be managed by the callback functions (nearly) autonomously and asynchronously For $i = 0 To UBound($aIPList) - 1 $ahGrid[$i] = _GUICtrlListView_AddItem($hGrid, "") ; create a listview row ; ; ... for each client ... ; ; spawn ping commands. result will be send to the _PingParse() function _TaskRun($i, "Ping -a -n 1 -4 " & $aIPList[$i], "_PingParse") ; spawn commands to recall LoggedOn User. Result will be send to the _LoggedOn() function _TaskRun($i, "wmic /node:" & $aIPList[$i] & " computersystem get username /value", "_LoggedOn", 5) ; 5 = timeout in 5 seconds ; spawn commands to recall Last reboot time. result will be send to the _LastReboot() function _TaskRun($i, "wmic /node:" & $aIPList[$i] & " os get lastbootuptime /value", "_LastReboot", 5) ; spawn commands to recall % of CPU load. result will be send to the _CPU_load() function _TaskRun($i, "wmic /node:" & $aIPList[$i] & " cpu get loadpercentage /value", "_CPU_load", 7) Next ; now, while all tasks are running ; we could perform other activities in the meantime ; or we can wait the end of all the tasks Do Sleep(250) ; you could perform other jobs here while waiting for the tasks to finish Until Not _TasksCheckStatus() ; <-- this function performs management of running tasks ; and should be called as often as possible EndFunc ;==>Example ; below are CallBack functions ; #FUNCTION# ==================================================================================================================== ; Name ..........: _PingParse (a callback function) ; Description ...: this function analize the output of a ping command and "extract" needed infos ; it fills columns 0 1 and 2 of the list view ($aTarget[0] is the line number of the listview to be filled) ; Syntax ........: _PingParse($aTarget[, $bDomain = True]) ; Parameters ....: $sTarget - An array with Ping results passed by the MultiTasks as soon as any ping task ends ; the passed array contains following data: ; $aTarget[0] Index for this task ; $aTarget[1] StdOut from ping (the whole output of the ping) ; $aTarget[2] StdErr from ping ; $aTarget[3] Time spent by this task to complete (is NOT the ping roundtrip time) ; $bDomain - [optional] A binary value. Default is True. (keep domain info in host name) ; ; Return values .: None. It Fills Listview columns 0, 1 and 2 ; column 0 : resolved HostName or "" ; column 1 : IP address or "" (this can contain last known IP even if now is offline) ; column 2 : roundtrip time or "Unknown" or "timeout" or "Off" ; ; Author ........: Chimp ; =============================================================================================================================== Func _PingParse($aTarget, $bDomain = True) ; $aTarget contains 4 elements: [0] Index, [1] StdOut, [2] StdErr, [3] time spent by this task Local $sOutput = $aTarget[1] ; stdout Local $0, $1, $2, $3, $aMs ; Local $iAnswer = -1, $iName = -1 Local $aResult[3] = ["", "", ""] ; [0]ms, [1]HostName, [2]IP $aMs = StringRegExp($sOutput, "([0-9]*)ms", 3) If Not @error Then ; Ping replayed $aResult[0] = $aMs[UBound($aMs) - 1] ; average ms Else ; $aResult[0] = "off" EndIf $0 = StringInStr($sOutput, "Ping") $1 = StringInStr($sOutput, "[") ; HostName decoded? If $1 Then ; HostName decoded $2 = StringInStr($sOutput, "]") $3 = StringInStr($sOutput, " ", 0, -2, $1) $aResult[1] = StringMid($sOutput, $3 + 1, $1 - $3 - 1) ; HostName $aResult[2] = StringMid($sOutput, $1 + 1, $2 - $1 - 1) ; IP Else If $0 Then ; pinging an IP address? ; $aResult[1] = "" ; no HostName Local $aFindIP = StringRegExp($sOutput, "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b", 3) If Not @error Then $aResult[2] = $aFindIP[0] Else ; unknown HostName $aResult[0] = "Unknown" $aResult[1] = $aIPList[$aTarget[0]] ; retrieve HostName from the $aIPList array EndIf EndIf If $bDomain = False Then Local $aSplit = StringSplit($aResult[1], ".", 2) ; 2 = $STR_NOCOUNT $aResult[1] = $aSplit[0] ; romove .domain part from the HostName EndIf If StringLeft($aTarget[2], 14) = "@error Timeout" Then $aResult[0] = "Timeout" ; Now that we have the infos, we compile related cells in ListView ; grid row-handle data column _GUICtrlListView_SetItemText($hGrid, $ahGrid[$aTarget[0]], $aResult[1], 0) ; first column "HostName" _GUICtrlListView_SetItemText($hGrid, $ahGrid[$aTarget[0]], $aResult[2], 1) ; second column "IP address" _GUICtrlListView_SetItemText($hGrid, $ahGrid[$aTarget[0]], $aResult[0], 2) ; third column "Infos about the ping" ; ConsoleWrite("Debug: " & "-> " & $aResult[0] & @TAB & $aResult[1] & @TAB & $aResult[2] & @CRLF) EndFunc ;==>_PingParse Func _LastReboot($aParameters) ; Last reboot DateTime $aParameters[1] = StringStripWS($aParameters[1], 8) Local $equal = StringInStr($aParameters[1], "=") If $equal Then _GUICtrlListView_AddSubItem($hGrid, $ahGrid[$aParameters[0]], WMIDateStringToDate(StringMid($aParameters[1], $equal + 1)), 3) ; column 3 EndIf EndFunc ;==>_LastReboot Func _CPU_load($aParameters) ; % of CPU load $aParameters[1] = StringStripWS($aParameters[1], 8) Local $equal = StringInStr($aParameters[1], "=") If $equal Then _GUICtrlListView_AddSubItem($hGrid, $ahGrid[$aParameters[0]], StringMid($aParameters[1], $equal + 1), 4) ; column 4 EndIf EndFunc ;==>_CPU_load Func _LoggedOn($aParameters) ; User now logged $aParameters[1] = StringStripWS($aParameters[1], 8) ; if none is logged, then find the user that was last logged (also using _TaskRun) If $aParameters[1] = "" Or $aParameters[1] = "UserName=" Then ; following syntax is by @iamtheky (thanks) ; https://www.autoitscript.com/forum/topic/189845-regexp-pattern-in-findstr-dos-command/?do=findComment&comment=1363106 Local $sCmd = 'cmd /c FOR /F "usebackq skip=2 tokens=1-3" %A IN (`REG QUERY ' & '"\\' & $aIPList[$aParameters[0]] & _ '\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI" /REG:64 /v LastLoggedOnUser 2^>nul`) Do @echo %C' _TaskRun($aParameters[0], $sCmd, "_LastLogged", 5) ; find last logged user and, when ready, send result to _LastLogged() Else ; if someone is logged then write username to column 6 Local $aUser = StringSplit($aParameters[1], "=", 2) ; 2 = $STR_NOCOUNT _GUICtrlListView_AddSubItem($hGrid, $ahGrid[$aParameters[0]], $aUser[UBound($aUser) - 1], 6) ; column 6 EndIf EndFunc ;==>_LoggedOn Func _LastLogged($aParameters) _GUICtrlListView_AddSubItem($hGrid, $ahGrid[$aParameters[0]], $aParameters[1], 5) ; column 5 EndFunc ;==>_LastLogged Func WMIDateStringToDate($dtmDate) ; thanks to @kylomas ; https://www.autoitscript.com/forum/topic/169252-wmi-password-age-issue/?do=findComment&comment=1236082 ; reformat date to mm/dd/yyyy hh:mm:ss and zero fill single digit values Return StringRegExpReplace(StringRegExpReplace($dtmDate, '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2}).*', '$2/$3/$1 $4:$5:$6'), '(?<!\d)(\d/)', '0$1') EndFunc ;==>WMIDateStringToDate
    1 point
  4. Well, _ArrayDisplay can display 65525 elements only. So good luck to display millions of lines (as said the OP in post #16) - and BTW with _Array* funcs too
    1 point
  5. check here: and here: https://support.microsoft.com/en-us/help/2689447/how-to-set-the-zoom-level-in-internet-explorer-9 btw. Cześć.
    1 point
  6. so far : #include <file.au3> $file = FileOpen("C:\AutomationDevelopers\temp.txt", 0) While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $line= StringRegExpReplace($line, '(?m)(?|^.*?a.*?e.*$|^.*?e.*?a.*$)\R?', "") MsgBox(0,'',$line) WEnd FileClose($file) at least it show correcly line by line the right word, that encouraging. but how to actually delete the line in the file ?
    1 point
  7. mikell

    Regex with Variable

    Nice ! And what does the $a1 variable contain precisely ?
    1 point
  8. Try to use _IEPropertyGet to retrieve width and height of the page.
    1 point
  9. FIrstly I suck at RegEx so take the following with a grain of salt. #include <Array.au3> Local $aSample[4] = ["aeuio", "euia", "nike", "nujik"] _ArrayDisplay($aSample, "Sample Before") For $i = UBound($aSample) - 1 To 0 Step - 1 If StringRegExp($aSample[$i], "a.*e|e.*a") = 1 Then _ArrayDelete($aSample, $i) Next _ArrayDisplay($aSample, "Sample After")
    1 point
  10. Just want to inform you guys that a new hotfix update is online now! It fixes the errors gcriaco reported. Note: If you do have problems installing the plugins from my website, please download them again. (permissions are fixed in the new packages)
    1 point
  11. Bilgus

    Controlling VLC

    As for intercepting the command line you could capture the file names there and decide to move based on that info.. etc.
    1 point
  12. Bilgus

    Controlling VLC

    Ok so I got what probably the hardest part worked out Sleep(1000) ; Just to give us some time to get hand off mouse/kb Global Const $aFileTypes = ["mp4", "avi", "mkv"] Global $sFileTypes = Build_File_Types($aFileTypes) Global $g_MatchVLC_Win_Name = "VLC media player" Global $g_MatchVLC_Win = "[REGEXPTITLE:(?i)(" & $sFileTypes & ")(.*" & $g_MatchVLC_Win_Name & ")]" ; "[REGEXPCLASS:(?i)(.*VLC video.*)" ; Global $g_MatchVLC_Win_Fb = "[REGEXPTITLE:(?i)(.*" & $g_MatchVLC_Win_Name & ")]" ;Fallback Matching Global $g_MatchVLC_Win_Fb_TEXT = "VLC (Direct3D output)" Opt("SendKeyDelay", 10) Opt("SendKeyDownDelay", 50) Global $g_KeystoSend = "#+{left}f" ;(#Win)(+SHIFT){left}f If _IsCompiled() Then ;Skip for now Local $Path = @ScriptDir & "\Vlc_Orig.exe" Local $Switches = $CmdLineRaw ; Run Run(Chr(34) & $Path & Chr(34) & " " & $Switches, @ScriptDir) EndIf ConsoleWrite("Begin" & @CRLF) ActivateVLC_Win() Send($g_KeystoSend) Sleep(1000) ConsoleWrite("End" & @CRLF) Func _IsCompiled() ;wakillon Return @Compiled EndFunc Func ActivateVLC_Win() Do WinActivate($g_MatchVLC_Win, "") WinWaitActive($g_MatchVLC_Win, "", 5) ; Wait for active window for number of seconds $bIsAct = WinActive($g_MatchVLC_Win) If Not $bIsAct Then ;Fallback WinActivate($g_MatchVLC_Win_Fb, $g_MatchVLC_Win_Fb_TEXT) WinWaitActive($g_MatchVLC_Win_Fb, $g_MatchVLC_Win_Fb_TEXT, 5) $bIsAct = WinActive($g_MatchVLC_Win_Fb, $g_MatchVLC_Win_Fb_TEXT) EndIf ConsoleWrite("VLC is " & ($bIsAct ? "" : "not ") & "active" & @CRLF) Until ($bIsAct) EndFunc Func Build_File_Types($aExtensions) Local $sRet = "" For $i = 0 To UBound($aExtensions) - 1 $sRet &= ".*\." & $aExtensions[$i] & "|" Next $sRet = StringTrimRight($sRet, 1) ;Remove the trailing '|' ConsoleWrite("FileTypes: " & $sRet & @CRLF) Return $sRet EndFunc I first did just file extension matching but I noticed it wasn't always working with really long file names since they get cut off so I also implemented a fallback mechanism it looks for 'VLC (Direct3D output)' as the window text your video output text might be different...
    1 point
  13. iamtheky

    RegEx help

    closer....maybe. $string = "1711848-002A 300.1_W NO3/NO2 J-FLAG" & @CRLF & _ "1711855-001C 300.1_W NO3/NO2/CL/ " & @CRLF & _ ;<--- Note there is a space after the slash "1711849-001B 300.1_W NO3/NO2/ J-FLAG" MsgBox(0, 0, "before: " & @CRLF & $string) $string = StringRegExpReplace($string, "(?m)(.*)/(\s.*$)", "$1$2") MsgBox(0, 0, "after: " & @CRLF & $string)
    1 point
  14. This time I want to share this utility I developed to speed-up the helpdesk activity in our windows domain, used every day by my collegues. Our windows machines have no simple to remember name, and when a user calls it's good to quick find a set of informations about the user, the machine, the account and so on. In our domain every user and machine has a well made description, and many fields are completed. So, based on the fantastic UDF AD.au3 for active directory, I have this script that can: search both on user name - machine description, retrieving account name, name/surname, phone number , and for the machine the machine name, the description, the operating system. You can check if an account is locked, the domain group membership of an user, the expiration date of the password, you can connect via VNC (tightvnc 64bit please), you can even call the user (but this is based on a particular setup in our environment, we have another script to send commands to the desktop IPphone). The code: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Icone\glaze\kcontrol.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;UMD User.Machine.Domain ; (c) NSC 2017-2018 ; V.0.3 december 2017 ; V.0.4 english translated and phone fiel added ; V.0.6 autodeploy and update ; V.0.61 support for old vnc 32bit ; V.0.65 search on machine name with radio button ; V.0.66 search on machine name added to default search, removed radio buttons ; V.0.67 radio buttons restored ; V.0.70 VNC connect with no checkbox if only 1 machine found, VNC called with vnconf file, added call functionality via DTdial key combo, user password info ; V.0.71 bugfix ; V.0.75 added ip retrieval, ping if online, reverse host lookup, added tips on every command. ; V.0.76 code cleaned ;#RequireAdmin #include <WinAPISys.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include "GUIListViewEx.au3" #include <Array.au3> #include <File.au3> #include <AD.au3> #include <_zip.au3> #include <Inet.au3> #Cs ------- notes ------------------ https://social.technet.microsoft.com/wiki/contents/articles/12037.active-directory-get-aduser-default-and-extended-properties.aspx https://social.technet.microsoft.com/wiki/contents/articles/12056.active-directory-get-adcomputer-default-and-extended-properties.aspx #CE Global $idListview, $id2Listview, $Icercato, $search1, $search2, $List_lines_Index, $List2_lines_Index, $trovati1, $trovatiPHONE1, $trovati2, $umdver = "V.0.76" Global $gollogcount = 0, $lastlog = "sicrlf", $cachelog = "", $guititle = "UMD - Users-Machines-Domain " & $umdver & " NSC 2017-2018", $Gollogedit, $logfile = @ScriptDir & "\UMD_", $months2NOTzip = 1 Global $geleft = 590, $getop = 15, $gewidth = 400, $geheight = 550 Global $prgname = "umd.exe", $umddir = "c:\autoit\UMD\", $sourceexepath = "\\yourpath", $toping = ("your ip to ping") ; environment related: $sourceexepath is for autodeploy/autoupdate, these operations depend on pinging $toping Global $OU1 = "OU=Users,OU=IT,DC=??,DC=???,DC=local", $OU2 = "OU=Clients,OU=IT,DC=??,DC=???,DC=local" ;domain related, the first is the domain OU (organizational unit) where to search for users, the second the OU for machines Global $only1machine = 0, $lastmachinefound = "", $only1user = 0, $lastphonefound = "" Global $idchkbox1, $idchkbox2, $idchkbox3 GuiGO() Func GuiGO() Local $guiheight = 620 ; gui height GUICreate($guititle, 1000, $guiheight, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x6FA8DC) GUICtrlCreateLabel("Search on Users", 5, 1, 150, 15) CLVW() GUICtrlCreateLabel("Search on Machines", 5, 286, 150, 15) $idradio1 = GUICtrlCreateRadio("on user name / machine description", 180, 286, 200, 15) GUICtrlSetState(-1, $gui_checked) GUICtrlSetTip(-1, "search in both user name - machine description, populate both lists") $idradio2 = GUICtrlCreateRadio("only on machine name", 400, 286, 150, 15) GUICtrlSetState(-1, $gui_unchecked) GUICtrlSetTip(-1, "search only in the machine name field, populates only the list below") CLVW2() $Bcerca = GUICtrlCreateButton("Search (or enter)", 5, 570, 90, 30) GUICtrlSetTip(-1, "search the string in the yellow input box") $Block = GUICtrlCreateButton("User locked? ", 95, 570, 90, 30) GUICtrlSetTip(-1, "check if selected user account is locked, only an admin can unlock it") $Busergroups = GUICtrlCreateButton("User Groups", 185, 570, 90, 30) GUICtrlSetTip(-1, "list the domain groups for the selected user") $Buserpsw = GUICtrlCreateButton("User Password", 275, 570, 90, 30) GUICtrlSetTip(-1, "retrieve password expiration") $idchkbox2 = GUICtrlCreateCheckbox("psw extra info", 275, 600, 150, 15) GUICtrlSetFont(-1, 8, 400, 0, "consolas") GUICtrlSetState(-1, $gui_unchecked) GUICtrlSetTip(-1, "all the domain info about password") $Bcall = GUICtrlCreateButton("CALL", 495, 570, 40, 30) GUICtrlSetTip(-1, "phone CALL number") $Bvnc = GUICtrlCreateButton("VNC", 535, 570, 40, 30) GUICtrlSetFont(-1, 12, 800, 0, "consolas") GUICtrlSetTip(-1, "launch VNC, if one machine no need to check it") $idchkbox1 = GUICtrlCreateCheckbox("VNC readOnly", 495, 600, 90, 15) GUICtrlSetFont(-1, 8, 400, 0, "consolas") GUICtrlSetState(-1, $gui_unchecked) GUICtrlSetTip(-1, "launch VNC in read only mode") $Icercato = GUICtrlCreateInput("", 590, 570, 400, 30, BitOR($GUI_SS_DEFAULT_INPUT, $WS_BORDER)) GUICtrlSetBkColor(-1, 0xffff4d) GUICtrlSetFont(-1, 12, 800, 0, "consolas") GUICtrlSetColor(-1, 0x000099) GUICtrlSetTip(-1, "insert here a string to search...") $idchkbox3 = GUICtrlCreateCheckbox("ip check / nslookup", 590, 600, 150, 15) GUICtrlSetFont(-1, 8, 400, 0, "consolas") GUICtrlSetState(-1, $gui_unchecked) GUICtrlSetTip(-1, "retrieve IP, check online and performs a reverse check 'nslookup', warning can slow down operations !") GUICtrlCreateLabel("Operation LOG", 590, 1) $Gollogedit = GUICtrlCreateEdit("", $geleft, $getop, $gewidth, $geheight, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_BORDER, $WS_VSCROLL)) GUICtrlSetBkColor(-1, 0x3333ff) GUICtrlSetData(-1, "" & @CRLF) GUICtrlSetFont(-1, 9, 800, 0, "consolas") GUICtrlSetColor(-1, 0xffff4d) GUISetState(@SW_SHOW) GOLLOG("UMD " & $umdver & " STARTED") autodeploy() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GOLLOG("<<<< STOP <<<<") Exit Case $Bcerca If BitAND(GUICtrlRead($idradio1), $GUI_CHECKED) = $GUI_CHECKED Then Multisearch("username-machinedescription") If BitAND(GUICtrlRead($idradio2), $GUI_CHECKED) = $GUI_CHECKED Then Multisearch("machinename-username") Case $Block lock() Case $Busergroups usergroups() Case $Buserpsw userpsw() Case $Bcall DTdialCALL() Case $Bvnc VNC() Case $Icercato If BitAND(GUICtrlRead($idradio1), $GUI_CHECKED) = $GUI_CHECKED Then Multisearch("username-machinedescription") If BitAND(GUICtrlRead($idradio2), $GUI_CHECKED) = $GUI_CHECKED Then Multisearch("machinename-username") EndSwitch WEnd EndFunc ;==>GuiGO Func userpsw() _AD_Open() Local $checked_List = _GUIListViewEx_ReturnArray($List_lines_Index, 1) If Not @error Then For $i = 0 To UBound($checked_List) - 1 If $checked_List[$i] = "true" Then GOLLOG("PSW info for " & $trovati1[$i + 1]) Local $arrayuserpsw = _AD_GetPasswordInfo($trovati1[$i + 1]) If BitAND(GUICtrlRead($idchkbox2), $GUI_CHECKED) = $GUI_CHECKED Then Local $arraydesk[13] = [" ", "max psw age:", "min psw age:", "n° enforced psw:", "min lenght:", "lock duration:", "lock attempts:", "lock reset", "psw last changed:", "psw expires on:", "UTC last changed:", "UTC expires on:", "psw properties:"] For $i = 1 To UBound($arrayuserpsw) - 1 GOLLOG($arraydesk[$i] & " " & $arrayuserpsw[$i]) Next Else GOLLOG("Password expires on: " & $arrayuserpsw[9]) EndIf EndIf Next Else MsgBox(0, "nothing selected", "Empty Check Array") EndIf _AD_Close() EndFunc ;==>userpsw Func usergroups() _AD_Open() Local $checked_List = _GUIListViewEx_ReturnArray($List_lines_Index, 1) If Not @error Then For $i = 0 To UBound($checked_List) - 1 If $checked_List[$i] = "true" Then GOLLOG("Query groups of " & $trovati1[$i + 1]) Local $arrayusergroups = _AD_GetUserGroups($trovati1[$i + 1], False) _ArrayDisplay($arrayusergroups) EndIf Next Else MsgBox(0, "nothing selected", "Empty Check Array") EndIf _AD_Close() EndFunc ;==>usergroups Func VNCcall($machine) IniWrite("C:\autoit\UMD\vncconf.vnc", "connection", "host", $machine) If BitAND(GUICtrlRead($idchkbox1), $GUI_CHECKED) = $GUI_CHECKED Then IniWrite("C:\autoit\UMD\vncconf.vnc", "options", "viewonly", "1") Else IniWrite("C:\autoit\UMD\vncconf.vnc", "options", "viewonly", "0") EndIf Run("c:\program files\tightvnc\tvnviewer.exe -optionsfile=C:\autoit\UMD\vncconf.vnc -password=apollo") EndFunc ;==>VNCcall Func VNC() If $only1machine = 1 Then GOLLOG("VNC to :" & $lastmachinefound) VNCcall($lastmachinefound) Else Local $checked_List = _GUIListViewEx_ReturnArray($List2_lines_Index, 1) If Not @error Then For $i = 0 To UBound($checked_List) - 1 If $checked_List[$i] = "true" Then GOLLOG("connecting to :" & $trovati2[$i + 1]) VNCcall($trovati2[$i + 1]) EndIf Next Else MsgBox(0, "multiple machines and nothing selected", "Empty Check Array") EndIf EndIf EndFunc ;==>VNC Func CALLnow($number2call) ; Create a subGUI Local $callGUI = GUICreate("calling", 200, 40) Local $callinput = GUICtrlCreateInput($number2call, 10, 5, 180, 20) GUISetState(@SW_SHOW, $callGUI) GUICtrlSetState($callinput, $GUI_FOCUS) Sleep(500) Send("+{END}") Sleep(200) If @OSVersion = "WIN_8" Or @OSVersion = "WIN_81" Or @OSVersion = "WIN_10" Then Send("{LWINdown}<") Else Send("{LWINdown}z") EndIf Sleep(100) Send("{LWINup}") Sleep(1000) ; Delete the previous subGUI GUIDelete($callGUI) EndFunc ;==>CALLnow Func DTdialCALL() If ProcessExists("dtdial.exe") Then If $only1user = 1 Then GOLLOG("to call :" & $lastphonefound) Local $number2call = InputBox("UMD calling", "modify the number", $lastphonefound) CALLnow($number2call) Else Local $checked_List = _GUIListViewEx_ReturnArray($List_lines_Index, 1) If Not @error Then For $i = 0 To UBound($checked_List) - 1 If $checked_List[$i] = "true" Then GOLLOG("call selected :" & $trovatiPHONE1[$i + 1]) Local $number2call = InputBox("UMD calling", "modify the number", $trovatiPHONE1[$i + 1]) If $number2call = "" Then GOLLOG("nothing to call") Else CALLnow($number2call) EndIf EndIf Next Else MsgBox(0, "multiple machines and nothing selected", "Empty Check Array") EndIf EndIf Else GOLLOG("*** call function") GOLLOG("*** not available") GOLLOG("*** outside DT phone system") EndIf EndFunc ;==>DTdialCALL Func lock() _AD_Open() Local $checked_List = _GUIListViewEx_ReturnArray($List_lines_Index, 1) If Not @error Then For $i = 0 To UBound($checked_List) - 1 If $checked_List[$i] = "true" Then If _AD_IsObjectLocked($trovati1[$i + 1]) = 1 Then GOLLOG($trovati1[$i + 1]) GOLLOG("account is LOCKED !") If MsgBox(36, "Unlock ?", "Do you want to unlock account " & $trovati1[$i + 1] & " ?") = $idyes Then If _AD_UnlockObject($trovati1[$i + 1]) = 0 Then GOLLOG("error " & @error) Else GOLLOG("Unlock DONE !") EndIf Else GOLLOG("not unlocked...") EndIf Else GOLLOG($trovati1[$i + 1]) GOLLOG("account is UNlocked.") EndIf EndIf Next Else MsgBox(0, "nothing selected", "Empty Check Array") EndIf _AD_Close() EndFunc ;==>lock Func Multisearch($searchtype) GOLLOG("_____Load domain data_____") renewlistview() Local $cercato = GUICtrlRead($Icercato) Local $List_lines = '', $List2_lines = '', $string2search = '' $trovatiPHONE1 = 0 Dim $trovati1[1] = ["zero"] Dim $trovatiPHONE1[1] Dim $trovati2[1] = ["zero"] _AD_Open() GOLLOG("Searched for " & $cercato) If $searchtype = "username-machinedescription" Then $search1 = _AD_GetObjectsInOu($OU1, "", 2, "SamAccountName,name,ipphone,telephonenumber") If @error = 0 Then Local $conta1 = 0 Local $conta1trovati = 0 $string2search = '' While $search1[0][0] > $conta1 $conta1 += 1 If StringInStr($search1[$conta1][0], $cercato) <> 0 Then $List_lines = $search1[$conta1][0] & "|" & $search1[$conta1][1] & "|" & $search1[$conta1][2] & " " & $search1[$conta1][3] $lastphonefound = $search1[$conta1][2] & " " & $search1[$conta1][3] ; to save last machine found GUICtrlCreateListViewItem($List_lines, $idListview) _ArrayAdd($trovati1, $search1[$conta1][0]) _ArrayAdd($trovatiPHONE1, $search1[$conta1][2] & " " & $search1[$conta1][3]) $conta1trovati += 1 EndIf WEnd ; Initiate LVEx - use filling array - no count parameter - default insert mark colour (black) - drag image - sortable + not select all text + editable headers $List_lines_Index = _GUIListViewEx_Init($idListview, $List_lines, 0, 0, True, 1 + 2 + 8) GOLLOG("checked n° " & $conta1 & " users") GOLLOG("Found n° " & $conta1trovati & " users") If $conta1trovati = 1 Then $only1user = 1 Else $only1user = 0 EndIf Else GOLLOG("error in user search " & @error) EndIf $search2 = _AD_GetObjectsInOu($OU2, "", 2, "name,description,operatingSystem") ;search in machines If @error = 0 Then Local $conta2 = 0 Local $conta2trovati = 0 $string2search = '' While $search2[0][0] > $conta2 $conta2 += 1 If StringInStr($search2[$conta2][1], $cercato) <> 0 Or StringInStr($search2[$conta2][0], $cercato) <> 0 Then $List2_lines = $search2[$conta2][0] & "|" & $search2[$conta2][1] & "|" & $search2[$conta2][2] $lastmachinefound = $search2[$conta2][0] ; to save last machine found GUICtrlCreateListViewItem($List2_lines, $id2Listview) If BitAND(GUICtrlRead($idchkbox3), $GUI_CHECKED) = $GUI_CHECKED Then ; V.0.75 IPrelated($search2[$conta2][0]) EndIf _ArrayAdd($trovati2, $search2[$conta2][0]) $conta2trovati += 1 EndIf WEnd ; Initiate LVEx - use filling array - no count parameter - default insert mark colour (black) - drag image - sortable + not select all text + editable headers $List2_lines_Index = _GUIListViewEx_Init($id2Listview, $List2_lines, 0, 0, True, 1 + 2 + 8) GOLLOG("Checked n° " & $conta2 & " machines") GOLLOG("Found n° " & $conta2trovati & " machines") If $conta2trovati = 1 Then $only1machine = 1 Else $only1machine = 0 EndIf Else GOLLOG("error in machines search " & @error) EndIf EndIf ; second searchtype----------------------------------------------------------------------_-_--------------------------- If $searchtype = "machinename-username" Then $search2 = _AD_GetObjectsInOu($OU2, "", 2, "name,description,operatingSystem") ;search in machines If @error = 0 Then Local $conta2 = 0 Local $conta2trovati = 0 $string2search = '' While $search2[0][0] > $conta2 $conta2 += 1 If StringInStr($search2[$conta2][0], $cercato) <> 0 Then $List2_lines = $search2[$conta2][0] & "|" & $search2[$conta2][1] & "|" & $search2[$conta2][2] GUICtrlCreateListViewItem($List2_lines, $id2Listview) If BitAND(GUICtrlRead($idchkbox3), $GUI_CHECKED) = $GUI_CHECKED Then ; V.0.75 IPrelated($search2[$conta2][0]) EndIf _ArrayAdd($trovati2, $search2[$conta2][0]) $conta2trovati += 1 EndIf WEnd ; Initiate LVEx - use filling array - no count parameter - default insert mark colour (black) - drag image - sortable + not select all text + editable headers $List2_lines_Index = _GUIListViewEx_Init($id2Listview, $List2_lines, 0, 0, True, 1 + 2 + 8) GOLLOG("Checked n° " & $conta2 & " machines") GOLLOG("Found n° " & $conta2trovati & " machines") Else GOLLOG("error in machines search " & @error) EndIf EndIf _AD_Close() EndFunc ;==>Multisearch Func IPrelated($pinghost) Local $sIPAddress = "" Local $shostname = "" Local $pcping = Ping($pinghost) If $pcping = 0 Then Select Case @error = 1 Local $errorping = "host is offline" Case @error = 2 Local $errorping = "host is unreachable" Case @error = 3 Local $errorping = "bad destination" Case @error = 4 Local $errorping = "not found for other errors" EndSelect GOLLOG($pinghost & " " & $errorping) Else GOLLOG($pinghost & " ping in " & $pcping & " ms") ; Start the TCP service. TCPStartup() $sIPAddress = TCPNameToIP($pinghost) $shostname = _TCPIpToName($sIPAddress, 0) TCPShutdown() ; Close the TCP service. GOLLOG("IP address is: " & $sIPAddress) GOLLOG("reverse lookup:" & $shostname) EndIf EndFunc ;==>IPrelated Func autodeploy() ; pensato per la prima installazione e update Local $TipDT = Ping($toping) Local $ntest = 1 While $TipDT = 0 And $ntest < 3 Sleep(200) $TipDT = Ping($toping) $ntest += 1 WEnd If $TipDT = 0 Then GOLLOG("unable to check updates") Else If Not FileExists($umddir) Then GOLLOG("Procedo con Autodeploy") If DirCreate($umddir) Then GOLLOG("-> creata cartella " & $umddir) Else GOLLOG("-> problema ! non creata cartella " & $umddir) EndIf GOLLOG("posiziono eseguibile in " & $umddir) FileCopy(@ScriptDir & "\umd.exe", $umddir & "umd.exe", 1) If Not FileExists(@DesktopDir & "\umd.lnk") Then GOLLOG("desktop link creation...") FileCreateShortcut($umddir & "\" & $prgname, @DesktopDir & "\umd.lnk") EndIf GOLLOG("posiziono VNConf in " & $umddir) FileCopy($sourceexepath & "\vncconf.vnc", $umddir & "\" & "vncconf.vnc", 1) GOLLOG("AutoDeploy completato") ; ora devo spegnere e riavviare quello in \cpa_da Local $sCmdFile ; phoenix modificata NON è quella standard di autoupdate FileDelete(@TempDir & "\phoenix.bat") $sCmdFile = 'ping 127.0.0.1 -n 2 > NUL' & @CRLF _ & ':loop' & @CRLF _ & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _ & 'start c:\autoit\umd\umd.exe' & @CRLF _ & 'del %0' FileWrite(@TempDir & "\phoenix.bat", $sCmdFile) GOLLOG("program is closing, see ya in deployed version...") Sleep(1000) Run(@TempDir & "\phoenix.bat", @TempDir, @SW_HIDE) Exit ; exit and real update EndIf Local $currtime = FileGetTime(@ScriptDir & "\" & $prgname, $FT_MODIFIED, 1) Local $newtime = FileGetTime($sourceexepath & "\" & $prgname, $FT_MODIFIED, 1) If $newtime > $currtime Then GOLLOG("update available!") If Not FileExists(@DesktopDir & "\umd.lnk") Then GOLLOG("desktop link creation...") FileCreateShortcut($umddir & "\" & $prgname, @DesktopDir & "\umd.lnk") EndIf Local $sCmdFile GOLLOG("posiziono VNConf in " & $umddir) FileCopy($sourceexepath & "\vncconf.vnc", $umddir & "\" & "vncconf.vnc", 1) FileDelete(@TempDir & "\phoenix.bat") $sCmdFile = 'ping 127.0.0.1 -n 2 > NUL' & @CRLF _ & ':loop' & @CRLF _ & 'del "' & @ScriptFullPath & '"' & @CRLF _ & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _ & 'copy "' & $sourceexepath & '"\"' & $prgname & '" "' & @ScriptFullPath & @CRLF _ & 'start ' & @ScriptFullPath & @CRLF _ & 'del %0' FileWrite(@TempDir & "\phoenix.bat", $sCmdFile) GOLLOG("program is closing, see ya in next version..") Sleep(1000) Run(@TempDir & "\phoenix.bat", @TempDir, @SW_HIDE) Exit ; exit and real update Else GOLLOG("UMD already updated") EndIf EndIf EndFunc ;==>autodeploy Func renewlistview() ; cancella e ricrea GUICtrlDelete($idListview) GUICtrlDelete($id2Listview) CLVW() CLVW2() EndFunc ;==>renewlistview Func CLVW() ;crea listview utenti $idListview = GUICtrlCreateListView("SamAccountName|Name|phone", 5, 15, 570, 265, $LVS_SHOWSELALWAYS) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)) _GUICtrlListView_SetColumnWidth($idListview, 0, 175) _GUICtrlListView_SetColumnWidth($idListview, 1, 175) _GUICtrlListView_SetColumnWidth($idListview, 2, 150) GUICtrlSetFont(-1, 9, 800, 0, "consolas") EndFunc ;==>CLVW Func CLVW2() ;crea listview macchine $id2Listview = GUICtrlCreateListView("Name|Description|Operating System", 5, 300, 570, 265, $LVS_SHOWSELALWAYS) _GUICtrlListView_SetExtendedListViewStyle($id2Listview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)) _GUICtrlListView_SetColumnWidth($id2Listview, 0, 120) _GUICtrlListView_SetColumnWidth($id2Listview, 1, 180) _GUICtrlListView_SetColumnWidth($id2Listview, 2, 230) GUICtrlSetFont(-1, 9, 800, 0, "consolas") EndFunc ;==>CLVW2 Func GOLLOG($logtext) ; Gollog V.2.3 gestione CRLF si o no ; gestione a capo automatico oltre i xx caratteri; gestione pulitura ogni totmila char Perla pearl ; basta aggiungere |nocrlf50 a fine stringa, dove 50 sono gli xx caratteri, conta la prima riga dove si supera quel limite. ; to declare $gollogcount = 0,$lastlog="sicrlf",$cachelog="",$guititle = "nomegui",$Gollogedit,$logfile = @ScriptDir & "\GOLLOG_LOG_", $months2NOTzip = 3 ; e anche le misure dell'edit: $geleft = 32, $getop = 32, $gewidth = 553, $geheight = 377 ; #include <File.au3> #include <GuiEdit.au3> #include <_zip.au3> ; to insert FUNCs: GOLLOG CLEANEDIT GOLzipZIP $gollogcount += StringLen($logtext) Local $logfiletimerange = @YEAR & @MON Local $linelimit = StringRight($logtext, 2) If StringRight($logtext, 9) = "|nocrlf" & $linelimit Then $logtext = StringTrimRight($logtext, 9) Local $acapo = "no" Else Local $acapo = "si" $gollogcount += 4 If $gollogcount > 13000 Then Sleep(3000) cleanedit() $gollogcount = 0 EndIf EndIf If $acapo = "no" And (StringLen($cachelog) <= $linelimit) Then ;pearl perla non a capo se If $lastlog = "nocrlf" Then If WinExists($guititle) Then ; per non scrivere in gui se questa non esiste _GUICtrlEdit_AppendText($Gollogedit, $logtext) EndIf Else If WinExists($guititle) Then ; per non scrivere in gui se questa non esiste _GUICtrlEdit_AppendText($Gollogedit, @MDAY & "/" & @MON & "_" & @HOUR & ":" & @MIN & " " & $logtext) EndIf EndIf $cachelog = $cachelog & $logtext $lastlog = "nocrlf" Else If $lastlog = "nocrlf" Then If WinExists($guititle) Then ; per non scrivere in gui se questa non esiste _GUICtrlEdit_AppendText($Gollogedit, $logtext & @CRLF) EndIf $cachelog = $cachelog & $logtext _FileWriteLog($logfile & $logfiletimerange & ".txt", $cachelog) $cachelog = "" Else If WinExists($guititle) Then ; per non scrivere in gui se questa non esiste _GUICtrlEdit_AppendText($Gollogedit, @MDAY & "/" & @MON & "_" & @HOUR & ":" & @MIN & " " & $logtext & @CRLF) EndIf _FileWriteLog($logfile & $logfiletimerange & ".txt", $logtext) EndIf $lastlog = "sicrlf" EndIf EndFunc ;==>GOLLOG Func cleanedit() ; cleaning of edit every n° lines (in program put if $nlines > xlines then this function) GUICtrlDelete($Gollogedit) $Gollogedit = GUICtrlCreateEdit("", $geleft, $getop, $gewidth, $geheight) ;, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_BORDER)) GUICtrlSetData(-1, "" & @CRLF) GUICtrlSetFont(-1, 9, 800, 0, "consolas") GUICtrlSetColor(-1, 0xffff4d) GUICtrlSetBkColor(-1, 0x3333ff) GUICtrlSetCursor(-1, 3) EndFunc ;==>cleanedit Func GOLzipLOG($months2NOTzip) ; zipping old log leaving unzipped only n months GOLLOG("Starting old logs zipping..") ; path extraction zone Local $logfiletimerange = @YEAR & @MON Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" Local $arraylogpath = _PathSplit($logfile & $logfiletimerange & ".txt", $sDrive, $sDir, $sFileName, $sExtension) Local $logpath = $arraylogpath[1] & $arraylogpath[2] Local $hSearch = FileFindFirstFile($logfile & "*.txt") ; searching for logs Local $logconta = 0 While 1 ; single file processing cycle Local $sFileName = FileFindNextFile($hSearch) ; If there is no more file matching the search. If @error Then ExitLoop Local $stringtime = StringTrimRight(StringRight($sFileName, 10), 4) ;obtaining year-month like 201609 If $logfiletimerange - $stringtime > $months2NOTzip Then ;zipping If Not FileExists($logfile & ".zip") Then If Not _Zip_Create($logfile & ".zip", 1) Then GOLLOG("Error " & @error & " creating " & $logfile & ".zip") Else GOLLOG("Created new log archive: " & $logfile & ".zip") EndIf Else GOLLOG("adding to archive: " & $logfile & ".zip") EndIf If Not _zip_additem($logfile & ".zip", $logpath & $sFileName) Then GOLLOG("Error " & @error & " zipping: " & $logpath & $sFileName) Else GOLLOG("Added: " & $logpath & $sFileName) $logconta += 1 If Not FileDelete($logpath & $sFileName) Then GOLLOG("ERROR - Unable to DELETE log file " & $logpath & $sFileName) EndIf EndIf EndIf WEnd GOLLOG("Finished = " & $logconta & " log files zipped") EndFunc ;==>GOLzipLOG The minimum for make it work in your domain (no admin rights required, no writing on domain performed) is to modify these globals: Global $prgname = "umd.exe", $umddir = "c:\autoit\UMD\", $sourceexepath = "\\the .exe path for autodeploy", $toping = ("ip to ping") ; environment related: $sourceexepath is for autodeploy/autoupdate, these operations depend on pinging $toping Global $OU1 = "OU=Users,OU=IT,DC=??,DC=???,DC=local", $OU2 = "OU=Clients,OU=IT,DC=??,DC=???,DC=local" ;domain related, the first is the domain OU (organizational unit) where to search for users, the second the OU for machines. You have to recompile modifying at minimum $toping with a NON pingable IP (to disable auto deploy - update) and certainly the domain OU for your users and machines. The vncconf.vnc is to be modified with the standard (I hope for you..) VNC password in your company, OR you can remove the line and VNC will request the psw every time. After, Just copy the executable and the other file (vncconf.vnc) in a folder in your PC and try it. The autodeploy/update feature work in this way: if the script can ping $toping value, then pick the executable from $sourceexepath, and perform "installation" (link and copying .exe, no win register involved) or updating. Let me know your experience.. vncconf.vnc UMD.au3
    1 point
  15. Nothing special - just another analogue clock. -> Read https://en.wikipedia.org/wiki/Swiss_railway_clock for more information. Requires Windows7+ OS! Widget style GUI: ;The Hilfiker / MobaTime Swiss Railway Clock ;Coded by UEZ build 2019-07-07 ;Thanks to Eukalyptus for the _CreateBrushedAluminum() function! #pragma Compile(Icon, "GDI+ Swiss Railway Clock.ico") #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_stripped.au3" #AutoIt3Wrapper_UseX64=n Break(0) #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> ProcessSetPriority(@AutoItPID, $PROCESS_LOW) _GDIPlus_Startup() Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit Global $iW, $iH, $iX, $iY, $sTitle = "GDI+ Swiss Railway Clock v1.16" $iW = IniRead(@ScriptDir & "\GDI+ Swiss Railway Clock.ini", "Settings", "GUI_Size", 200) $iW = $iW < 100 ? 100 : $iW > 800 ? 800 : $iW $iH = $iW $iX = IniRead(@ScriptDir & "\GDI+ Swiss Railway Clock.ini", "Settings", "GUI_PosX", -1) $iY = IniRead(@ScriptDir & "\GDI+ Swiss Railway Clock.ini", "Settings", "GUI_PosY", -1) Global Const $fRad = ACos(-1) / 180, $fDeg = 180 / ACos(-1), $iTimer = 30, $ULW_ALPHA = 2, $SC_DRAGMOVE = 0xF012, $fDeltaShadow = 20 Global $hBitmap, $hHBitmap, $hCanvas, $hBitmap_Clock, $hBrush_Shadow, $hBrush_Update, $hPen_Update, $fDiameter = $iW, $fShadowAngle, $fMin_next, _ $fRadius = $fDiameter / 2, $fSec, $fMin, $fHr, $fAmplitude = 3, $fSize, $hOld Global $tSize = DllStructCreate($tagSIZE), $tSource = DllStructCreate($tagPOINT), $tBlend = DllStructCreate($tagBLENDFUNCTION) $tSize.X = $iW $tSize.Y = $iH $tBlend.Alpha = 255 $tBlend.Format = 1 Global Const $hScrDC = _WinAPI_GetDC($hGUI), $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) AutoItSetOption("GUIOnEventMode", 1) GDIPlus_SwissRailwayClockWidget() AutoItSetOption("GUIOnEventMode", 0) _GDIPlus_Shutdown() Func GDIPlus_SwissRailwayClockWidget() $bExit = False $hGUI = GUICreate($sTitle, $iW, $iH, $iX, $iY, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED)) GUISetState(@SW_SHOW, $hGUI) ;create canvas elements $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW + $fDeltaShadow, $iH + $fDeltaShadow) $hCanvas = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local Const $iAlpha = 0x0D / $iW * 200 $hBrush_Shadow = _GDIPlus_BrushCreateSolid(BitShift(0x0D + $iAlpha, -24) + 0x202020) $hPen_Update = _GDIPlus_PenCreate(0xFFA02020) $hBrush_Update = _GDIPlus_BrushCreateSolid(0) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) $hBitmap_Clock = GenerateClockBg($fDiameter) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About") $fMin_next = @MIN GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") GUIRegisterMsg($WM_TIMER, "Draw") ;$WM_TIMER = 0x0113 Local $iID = DllCall("User32.dll", "uint_ptr", "SetTimer", "hwnd", $hGUI, "uint_ptr", 1, "uint", $iTimer, "ptr", 0)[0] Do If $bExit Then ExitLoop Until Not Sleep(100) ;release resources GUIRegisterMsg($WM_TIMER, "") DllCall("user32.dll", "bool", "KillTimer", "hwnd", $hGUI, "uint_ptr", $iID) GUIRegisterMsg($WM_LBUTTONDOWN, "") _GDIPlus_PenDispose($hPen_Update) _GDIPlus_BrushDispose($hBrush_Shadow) _GDIPlus_BrushDispose($hBrush_Update) _GDIPlus_GraphicsDispose($hCanvas) _GDIPlus_ImageDispose($hCanvas) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_DeleteDC($hMemDC) IniWrite(@ScriptDir & "\GDI+ Swiss Railway Clock.ini", "Settings", "GUI_Size", WinGetPos($hGUI)[2]) IniWrite(@ScriptDir & "\GDI+ Swiss Railway Clock.ini", "Settings", "GUI_PosX", WinGetPos($hGUI)[0]) IniWrite(@ScriptDir & "\GDI+ Swiss Railway Clock.ini", "Settings", "GUI_PosY", WinGetPos($hGUI)[1]) GUIDelete($hGUI) EndFunc ;==>GDIPlus_SwissRailwayClockWidget Func Draw($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _GDIPlus_GraphicsClear($hCanvas, 0x00000000) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hBitmap_Clock, 0, 0, $fDiameter + $fDeltaShadow, $fDiameter + $fDeltaShadow) UpdateClock($hCanvas, $fDiameter) $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, DllStructGetPtr($tSize), $hMemDC, DllStructGetPtr($tSource), 0, DllStructGetPtr($tBlend), $ULW_ALPHA) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hHBitmap) EndFunc ;==>Draw Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) Switch $hWnd Case $hGUI _SendMessage($hWnd, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndSwitch EndFunc ;==>_WM_LBUTTONDOWN Func _Exit_About() $bExit = True EndFunc ;==>_Exit_About Func UpdateClock($hGfx, $fDiameter) Static $bBounce = 0, $f = 0 Local $m1 = $fDiameter * 0.015 ;hour $fHr = 30 * (@HOUR + @MIN / 60) _GDIPlus_GraphicsTranslateTransform($hGfx, $fRadius, $fRadius) _GDIPlus_GraphicsRotateTransform($hGfx, $fHr) _GDIPlus_GraphicsTranslateTransform($hGfx, -$fRadius, -$fRadius) Local $iWidth1 = $fDiameter * 0.0375, _ $iHeight1 = $fDiameter / 2.5, _ $iWidth12 = $iWidth1 / 2, _ $fPosY = $fDiameter * 0.2, $iWidth2, $iWidth22, $fPosY2 _GDIPlus_BrushSetSolidColor($hBrush_Update, 0xFF101010) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hGfx, "handle", $hBrush_Shadow, _ "float", $fRadius - $iWidth12 + Cos(($fShadowAngle - $fHr) * $fRad) * $m1, _ "float", $fPosY + Sin(($fShadowAngle - $fHr) * $fRad) * $m1, _ "float", $iWidth1, "float", $iHeight1) ;~ DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hGfx, "handle", $hBrush_Update, _ ;~ "float", $fRadius - $iWidth12, _ ;~ "float", $fPosY, _ ;~ "float", $iWidth1, "float", $iHeight1) Local $tPoints = DllStructCreate("float p[8]"), $factor = $iW / 160 ; 1----2 ; | | ; 4----3 ;1 $tPoints.p(1) = $fRadius - $iWidth12 $tPoints.p(2) = $fPosY ;2 $tPoints.p(3) = $tPoints.p(1) + $iWidth1 $tPoints.p(4) = $fPosY ;3 $tPoints.p(5) = $tPoints.p(3) + $factor $tPoints.p(6) = $fPosY + $iHeight1 ;4 $tPoints.p(7) = $tPoints.p(1) - $factor $tPoints.p(8) = $tPoints.p(6) DllCall($__g_hGDIPDll, "int", "GdipFillPolygon", "handle", $hGfx, "handle", $hBrush_Update, _ "struct*", $tPoints, "int", 4, "int", "FillModeAlternate") _GDIPlus_GraphicsResetTransform($hGfx) ;min If $fMin_next <> @MIN Then $bBounce = 1 Switch $bBounce Case 1 $fMin = (6 * Mod(($fMin_next + 1), 60)) + Sin($f * 1.9) * $fAmplitude If $fAmplitude = 0 Then $fMin_next = @MIN $f = 0 $fAmplitude = 3 $bBounce = 0 Else $fAmplitude -= 0.5 $fAmplitude = $fAmplitude <= 0 ? 0 : $fAmplitude $f += 1 EndIf Case Else $fMin = (6 * @MIN) EndSwitch _GDIPlus_GraphicsTranslateTransform($hGfx, $fRadius, $fRadius) _GDIPlus_GraphicsRotateTransform($hGfx, $fMin) _GDIPlus_GraphicsTranslateTransform($hGfx, -$fRadius, -$fRadius) $iWidth1 = $fDiameter * 0.03 $iHeight1 = $fRadius $iWidth12 = $iWidth1 / 2 $fPosY = $fDiameter * 0.1 DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hGfx, "handle", $hBrush_Shadow, _ "float", $fRadius - $iWidth12 + Cos(($fShadowAngle - $fMin) * $fRad) * $m1, _ "float", $fPosY + Sin(($fShadowAngle - $fMin) * $fRad) * $m1, _ "float", $iWidth1, "float", $iHeight1) ;~ DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hGfx, "handle", $hBrush_Update, _ ;~ "float", $fRadius - $iWidth12, _ ;~ "float", $fPosY, _ ;~ "float", $iWidth1, "float", $iHeight1) ;1 $tPoints.p(1) = $fRadius - $iWidth12 $tPoints.p(2) = $fPosY ;2 $tPoints.p(3) = $tPoints.p(1) + $iWidth1 $tPoints.p(4) = $fPosY ;3 $tPoints.p(5) = $tPoints.p(3) + $factor $tPoints.p(6) = $fPosY + $iHeight1 ;4 $tPoints.p(7) = $tPoints.p(1) - $factor $tPoints.p(8) = $tPoints.p(6) DllCall($__g_hGDIPDll, "int", "GdipFillPolygon", "handle", $hGfx, "handle", $hBrush_Update, _ "struct*", $tPoints, "int", 4, "int", "FillModeAlternate") _GDIPlus_GraphicsResetTransform($hGfx) ;sec $fSec = 6 * (@SEC * 1.02564 + @MSEC / 1000) If $fSec >= 360 Then $fSec = 0 _GDIPlus_GraphicsTranslateTransform($hGfx, $fRadius, $fRadius) _GDIPlus_GraphicsRotateTransform($hGfx, $fSec) _GDIPlus_GraphicsTranslateTransform($hGfx, -$fRadius, -$fRadius) $fPosY = $fDiameter * 0.27 $fPosY2 = $fDiameter * 0.19 $iWidth1 = $fDiameter * 0.0095 $iHeight1 = $fRadius * 1.3 - $fPosY $iWidth12 = $iWidth1 / 2 $iWidth2 = $fDiameter * 0.083333 $iWidth22 = $iWidth2 / 2 ;shadow seconds DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hGfx, "handle", $hBrush_Shadow, _ "float", $fRadius + Cos(($fShadowAngle - $fSec) * $fRad) * $m1, _ "float", $fPosY + Sin(($fShadowAngle - $fSec) * $fRad) * $m1, _ "float", $iWidth1 + $fDiameter * 0.006667, "float", $iHeight1 + $fDiameter * 0.006667) DllCall($__g_hGDIPDll, "int", "GdipFillEllipse", "handle", $hGfx, "handle", $hBrush_Shadow, _ "float", $fRadius - $iWidth22 + Cos(($fShadowAngle - $fSec) * $fRad) * $m1, _ "float", $fPosY2 + Sin(($fShadowAngle - $fSec) * $fRad) * $m1, _ "float", $iWidth2, "float", $iWidth2) ;seconds _GDIPlus_BrushSetSolidColor($hBrush_Update, 0xFFC01010) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hGfx, "handle", $hBrush_Update, _ "float", $fRadius - $iWidth12, _ "float", $fPosY, _ "float", $iWidth1, "float", $iHeight1) DllCall($__g_hGDIPDll, "int", "GdipFillEllipse", "handle", $hGfx, "handle", $hBrush_Update, _ "float", $fRadius - $iWidth22, _ "float", $fPosY2, _ "float", $iWidth2, "float", $iWidth2) _GDIPlus_GraphicsResetTransform($hGfx) ;button in the center DllCall($__g_hGDIPDll, "int", "GdipFillEllipse", "handle", $hGfx, "handle", $hBrush_Update, _ "float", $fRadius - $iWidth1, _ "float", $fRadius - $iWidth1, _ "float", 2 * $iWidth1, "float", 2 * $iWidth1) DllCall($__g_hGDIPDll, "int", "GdipDrawEllipse", "handle", $hGfx, "handle", $hPen_Update, _ "float", $fRadius - $iWidth1, _ "float", $fRadius - $iWidth1, _ "float", 2 * $iWidth1, "float", 2 * $iWidth1) EndFunc ;==>UpdateClock Func GenerateClockBg($fDiameter, $iBGColor = 0xF8FFFFFF) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($fDiameter + $fDeltaShadow, $fDiameter + $fDeltaShadow), $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap), _ $hBrush = _GDIPlus_BrushCreateSolid($iBGColor), $fBorderSize = $fDiameter * 0.03333, _ $hEffect = _GDIPlus_EffectCreateBlur($fDiameter / 50, 1), $hPen = _GDIPlus_PenCreate(0xA0000000, $fBorderSize) _GDIPlus_GraphicsSetSmoothingMode($hGfx, 4) _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 4) _GDIPlus_GraphicsSetTextRenderingHint($hGfx, 4) Local Const $fSize = $fDiameter * 0.942 - $fBorderSize / 2 Local Const $hLBrush = _GDIPlus_LineBrushCreate($fBorderSize, $fBorderSize, $fSize, $fSize, 0xFCFFFFFF, 0xF8F0F0F0, 3) _GDIPlus_LineBrushSetSigmaBlend($hLBrush, 0.33333) _GDIPlus_LineBrushSetGammaCorrection($hLBrush) Local Const $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, -$fSize, -$fSize, True) _GDIPlus_MatrixRotate($hMatrix, 90, True) _GDIPlus_MatrixTranslate($hMatrix, $fSize, $fSize, True) _GDIPlus_LineBrushMultiplyTransform($hLBrush, $hMatrix, True) _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_GraphicsFillEllipse($hGfx, $fBorderSize, $fBorderSize, $fSize, $fSize, $hLBrush) ;~ Local Const $hPath = _GDIPlus_PathCreate() ;~ _GDIPlus_PathAddEllipse($hPath, $fBorderSize, $fBorderSize, $fSize, $fSize) ;~ Local $hLBrush = _GDIPlus_PathBrushCreateFromPath($hPath) ;~ _GDIPlus_PathBrushSetCenterColor($hLBrush, 0xF8F0F0FF) ;~ _GDIPlus_PathBrushSetCenterPoint($hLBrush, $fSize * 0.70, $fSize * 0.70) ;~ _GDIPlus_PathBrushSetSurroundColor($hLBrush, 0xFBFFFFFF) ;~ _GDIPlus_PathBrushSetGammaCorrection($hLBrush, True) ;~ _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hLBrush) ;~ _GDIPlus_PathDispose($hPath) Local $fShadow_vx = $fDiameter * 0.0095, $fShadow_vy = $fDiameter * 0.01 $fShadowAngle = ATan($fShadow_vy / $fShadow_vx) * $fDeg If $fShadow_vx < 0 And $fShadow_vy >= 0 Then $fShadowAngle += 180 If $fShadow_vx < 0 And $fShadow_vy < 0 Then $fShadowAngle -= 180 _GDIPlus_GraphicsDrawEllipse($hGfx, $fBorderSize + $fShadow_vx, $fBorderSize + $fShadow_vy, $fSize, $fSize, $hPen) _GDIPlus_BitmapApplyEffect($hBitmap, $hEffect) _GDIPlus_BrushSetSolidColor($hBrush) _GDIPlus_PenSetColor($hPen, 0xF0000000) Local Const $hBitmap_Texture = _CreateBrushedAluminum($fDiameter, $fDiameter, $fShadowAngle) Local Const $hTexture = _GDIPlus_TextureCreate($hBitmap_Texture) DllCall($__g_hGDIPDll, "int", "GdipSetPenBrushFill", "ptr", $hPen, "ptr", $hTexture) _GDIPlus_GraphicsDrawEllipse($hGfx, $fBorderSize, $fBorderSize, $fSize, $fSize, $hPen) _GDIPlus_GraphicsTranslateTransform($hGfx, $fRadius, $fRadius) _GDIPlus_GraphicsRotateTransform($hGfx, -6) _GDIPlus_GraphicsTranslateTransform($hGfx, -$fRadius, -$fRadius) Local $iWidth1 = $fDiameter * 0.026667, $iHeight1 = $fDiameter / 10, $iWidth12 = $iWidth1 / 2, $fPosY = $fDiameter * 0.083333, _ $iWidth2 = $fDiameter * 0.013333, $iHeight2 = $fDiameter * 0.0416667, $iWidth22 = $iWidth2 / 2 For $i = 0 To 59 _GDIPlus_GraphicsTranslateTransform($hGfx, $fRadius, $fRadius) _GDIPlus_GraphicsRotateTransform($hGfx, 6) _GDIPlus_GraphicsTranslateTransform($hGfx, -$fRadius, -$fRadius) Switch Mod($i, 5) Case 0 _GDIPlus_GraphicsFillRect($hGfx, $fRadius - $iWidth12, $fPosY, $iWidth1, $iHeight1, $hBrush) Case Else _GDIPlus_GraphicsFillRect($hGfx, $fRadius - $iWidth22, $fPosY, $iWidth2, $iHeight2, $hBrush) EndSwitch Next _GDIPlus_GraphicsResetTransform($hGfx) Local Const $hBitmap_Logo = _GDIPlus_BitmapCreateFromMemory(_Au3_Icon()) Local Const $hBitmap_Logo_Scaled = _GDIPlus_ImageResize($hBitmap_Logo, $fDiameter * 0.125, $fDiameter * 0.125) Local $aDim = _GDIPlus_ImageGetDimension($hBitmap_Logo_Scaled) _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Logo_Scaled, $fRadius - $aDim[0] / 2, $fRadius / 2, $aDim[0], $aDim[1]) _GDIPlus_ImageDispose($hBitmap_Logo) _GDIPlus_ImageDispose($hBitmap_Logo_Scaled) Local Const $hFamily = _GDIPlus_FontFamilyCreate("Segoe Script"), $hFont = _GDIPlus_FontCreate($hFamily, $fDiameter * 0.025), $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) _GDIPlus_BrushSetSolidColor($hBrush, 0xE0000000) _GDIPlus_GraphicsDrawStringEx($hGfx, "Clock coded by" & @CRLF & "UEZ", $hFont, _GDIPlus_RectFCreate($fRadius - $fRadius * 0.2, $fRadius + $fRadius * 0.2, $fRadius * 0.4, $fRadius * 0.4), $hFormat, $hBrush) _GDIPlus_ImageDispose($hBitmap_Texture) _GDIPlus_BrushDispose($hTexture) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_EffectDispose($hEffect) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hLBrush) _GDIPlus_GraphicsDispose($hGfx) Return $hBitmap EndFunc ;==>GenerateClockBg Func _CreateBrushedAluminum($iW, $iH, $fLightAngle = 40, $iBlurDist = 12, $fBlurTrans = 0.6666, $fRed = 0.8, $fGreen = 0.9, $fBlue = 1, $iLightColor = 0xF0FFFFFF, $fLightSigma = 0.5, $fLightScale = 0.83) ;coded by Eukalyptus! $iBlurDist = Ceiling($iBlurDist) $iBlurDist += 1 - Mod($iBlurDist, 2) Local $iOverSize = 0 For $i = 1 To $iBlurDist Step 2 $iOverSize += $i + $i + 1 Next Local $iWO = $iW + $iOverSize ;========================================= ; Add Noise ;========================================= Local $iNoiseSize = 40 Local $hBmp_Noise = _GDIPlus_BitmapCreateFromScan0($iNoiseSize, $iNoiseSize) Local $hGfx_Noise = _GDIPlus_ImageGetGraphicsContext($hBmp_Noise) Local $tData = _GDIPlus_BitmapLockBits($hBmp_Noise, 0, 0, $iNoiseSize, $iNoiseSize, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB) Local $iStride = DllStructGetData($tData, "Stride") Local $iWidth = DllStructGetData($tData, "Width") Local $iHeight = DllStructGetData($tData, "Height") Local $pScan0 = DllStructGetData($tData, "Scan0") Local $tPixel = DllStructCreate("dword[" & $iWidth * $iHeight & "];", $pScan0) Local $iAmp For $row = 0 To $iHeight - 1 For $col = 0 To $iWidth - 1 $iAmp = Random(0, 0xFF, 1) DllStructSetData($tPixel, 1, BitOR(0xFF000000, BitShift($iAmp, -16), BitShift($iAmp, -8), $iAmp), $row * $iWidth + $col + 1) Next Next _GDIPlus_BitmapUnlockBits($hBmp_Noise, $tData) ;========================================= ; Create Full NoiseBitmap ;========================================= Local $hBmp_Full = _GDIPlus_BitmapCreateFromScan0($iWO, $iH) Local $hGfx_Full = _GDIPlus_ImageGetGraphicsContext($hBmp_Full) _GDIPlus_GraphicsSetSmoothingMode($hGfx_Full, 4) _GDIPlus_GraphicsSetInterpolationMode($hGfx_Full, 3) Local $iXOff, $iYOff, $iSizeX, $iSizeY For $y = 0 To $iH Step $iNoiseSize / 2 For $x = 0 To $iWO Step $iNoiseSize / 2 $iXOff = Random(0, $iNoiseSize / 2, 1) $iYOff = Random(0, $iNoiseSize / 2, 1) $iSizeX = $iNoiseSize - $iXOff $iSizeY = $iNoiseSize - $iYOff _GDIPlus_GraphicsDrawImageRectRect($hGfx_Full, $hBmp_Noise, $iXOff, $iYOff, $iSizeX, $iSizeY, $x, $y, $iSizeX, $iSizeY) Next Next _GDIPlus_GraphicsDispose($hGfx_Noise) _GDIPlus_BitmapDispose($hBmp_Noise) ;========================================= ; MotionBlur ;========================================= Local $hBmp_Full2 = _GDIPlus_BitmapCreateFromScan0($iWO, $iH) Local $hGfx_Full2 = _GDIPlus_ImageGetGraphicsContext($hBmp_Full2) _GDIPlus_GraphicsSetSmoothingMode($hGfx_Full2, 4) _GDIPlus_GraphicsSetInterpolationMode($hGfx_Full, 3) Local $tColorMatrix = DllStructCreate("float[5]; float[5]; float[5]; float[5]; float[5];") DllStructSetData($tColorMatrix, 1, 1, 1) DllStructSetData($tColorMatrix, 2, 1, 2) DllStructSetData($tColorMatrix, 3, 1, 3) DllStructSetData($tColorMatrix, 4, $fBlurTrans, 4) DllStructSetData($tColorMatrix, 5, 1, 5) Local $hImgAttrib = _GDIPlus_ImageAttributesCreate() DllCall($__g_hGDIPDll, "int", "GdipSetImageAttributesColorMatrix", "ptr", $hImgAttrib, "int", 1, "int", 1, "struct*", $tColorMatrix, "struct*", 0, "int", 0) For $i = 1 To $iBlurDist Step 2 DllCall($__g_hGDIPDll, "int", "GdipDrawImageRectRect", "ptr", $hGfx_Full2, "ptr", $hBmp_Full, _ "float", $i, "float", 0, "float", $iWO, "float", $iH, _ "float", 0, "float", 0, "float", $iWO, "float", $iH, _ "int", 2, "ptr", $hImgAttrib, "ptr", 0, "ptr", 0) If $i >= $iBlurDist Then DllStructSetData($tColorMatrix, 1, $fRed, 1) DllStructSetData($tColorMatrix, 2, $fGreen, 2) DllStructSetData($tColorMatrix, 3, $fBlue, 3) DllStructSetData($tColorMatrix, 4, 1, 4) DllCall($__g_hGDIPDll, "int", "GdipSetImageAttributesColorMatrix", "ptr", $hImgAttrib, "int", 1, "int", 1, "struct*", $tColorMatrix, "struct*", 0, "int", 0) EndIf DllCall($__g_hGDIPDll, "int", "GdipDrawImageRectRect", "ptr", $hGfx_Full, "ptr", $hBmp_Full2, _ "float", $i + 1, "float", 0, "float", $iWO, "float", $iH, _ "float", 0, "float", 0, "float", $iWO, "float", $iH, _ "int", 2, "ptr", $hImgAttrib, "ptr", 0, "ptr", 0) Next _GDIPlus_ImageAttributesDispose($hImgAttrib) _GDIPlus_GraphicsDispose($hGfx_Full2) _GDIPlus_BitmapDispose($hBmp_Full2) _GDIPlus_GraphicsDispose($hGfx_Full) ;========================================= ; Add Light ;========================================= Local $hBmp_Alu = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local $hGfx_Alu = _GDIPlus_ImageGetGraphicsContext($hBmp_Alu) _GDIPlus_GraphicsSetSmoothingMode($hGfx_Alu, 4) _GDIPlus_GraphicsSetInterpolationMode($hGfx_Alu, 3) _GDIPlus_GraphicsDrawImage($hGfx_Alu, $hBmp_Full, -$iOverSize, 0) _GDIPlus_BitmapDispose($hBmp_Full) Local $tPointF1 = DllStructCreate("float; float;") Local $tPointF2 = DllStructCreate("float; float;") DllStructSetData($tPointF2, 2, $iH * $fLightScale) $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateLineBrush", "struct*", $tPointF1, "struct*", $tPointF2, "uint", 0, "uint", $iLightColor, "int", 0, "handle*", 0) If @error Or Not IsArray($aResult) Then Return SetError(1, 4, False) Local $hBrush = $aResult[6] _GDIPlus_LineBrushSetSigmaBlend($hBrush, $fLightSigma) _GDIPlus_LineBrushSetGammaCorrection($hBrush) DllCall($__g_hGDIPDll, "int", "GdipRotateLineTransform", "ptr", $hBrush, "float", $fLightAngle, "int", 0) _GDIPlus_GraphicsFillRect($hGfx_Alu, 0, 0, $iW, $iH, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfx_Alu) Return $hBmp_Alu EndFunc ;==>_CreateBrushedAluminum ;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2018-02-02 Func _Au3_Icon($bSaveBinary = False, $sSavePath = @ScriptDir) Local $Au3_Icon $Au3_Icon &= 'iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAP0ElEQVR4XtWZW4hs6VXHf+v79qWquruquqtvZ/r0uc8540yScTIQQ0JkDOYyGhIkhhAxxhdR8mDAgAg+6FsE9UVffNMH8S0ERAwS1DFeEo3m6owzmUySc+Zc+15VXZd9+dZyp6ro4pDTORlGIfnDn703TW/+//X9v/Wt3i3PPfccP85w/GhBgLqkS23ixhpRfau6bgItIPpRN5Ag0Xl88jYrxu/E+KA492E0vJd44d245BKQ/H8bkAe80wMOEE5HA5c8SpQ822yv/ubW9vnfffyxR3+vs7r6YcS9HewZnP9ZXPwE0Py/NuCBJj65iERvQPybcNFP4JKzuPgq+CeR6GnwV3FJB4juM+mSNj55Ehe97/LFC5947PL2ey5tb755daW1+fiVc295+qk3fuTShfPPPnb10d+J60sfI6o9BbRer4EIaOLis1Nh6dtBfs6ljY82ljqfiNLFX8X597uk/ksrG4/8ftJo/lq62P51XPQOJHoc3DV8egZYxLkLcW3xQ088fvWTj2ysXItjnxRlGY6Ojmxvb98iJwtnz6xeXO80tx+9t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2PbWOtI1WzIC8Vg1Bp94fdwau37+78KdhzaHgFLbpA4OEgwmzNmPR8RCZDVuj2elG3e/S5NIn/KMuLQyR+Ucv80zs7ey+BbVVinIjUVpcXL816O82613Zd' $Au3_Icon &= 'gMTEOQcCqIo4RlkpVRu2Uk129w8DneWxeO9v3N79l+pCnuVfxvRfCdkLwIDXAPnSf33tU+fOnvktEXNFUUi1af3e3sHXNRQfA746P0+p4eJlxJ9D5I3OR09fPnfml6vD5m6rubCdRC4FAUDNdDTOe977ej2NUjOjdzxgNBwVh73h3/ooGXrvk2w8esE0PI9Nus11oM9rhHzhi//xtpXV1c+msW92uz0ODw6fA/1t4Es8GDEu3kDcFRclP6Ua2nGcbMdxvI4hzossLdQvAeRFeS/Liv00jddUtej2Bs9pKP4TDYdgOdBD3C4h2wcCrx1M/8kn7j2Y/gxwM03Tz2RZdouHo4GLOuA2EGliNBGpY3qM8+uAoeV3MBvjXBucTJ5dfIcwGgIGlIDxOjAx8DrhgQioEdUjxCmmEQDlaDATGTPF+JRKv24Dbp71GX9M8L84Jo46QVTs6gAAAABJRU5ErkJggg==' Local $bString = _WinAPI_Base64Decode($Au3_Icon) If @error Then Return SetError(1, 0, 0) $bString = Binary($bString) If $bSaveBinary Then Local Const $hFile = FileOpen($sSavePath & "\au3-icon2.png", 18) If @error Then Return SetError(2, 0, $bString) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_Au3_Icon Func _WinAPI_Base64Decode($sB64String) Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "") Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]") $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "") Return DllStructGetData($bBuffer, 1) EndFunc ;==>_WinAPI_Base64Decode Download: GDI+ Swiss Railway Clock v1.16 (Widget).au3 GUI version (discontinued): ;the Hilfiker / MobaTime Swiss Railway Clock ;coded by UEZ build 2018-03-01 ;thanks to Eukalyptus for the _CreateBrushedAluminum() function! #Pragma Compile(Icon, "GDI+ Swiss Railway Clock.ico") #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_stripped.au3" #AutoIt3Wrapper_UseX64=n Break(0) #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> ProcessSetPriority(@AutoItPID, $PROCESS_LOW) _GDIPlus_Startup() Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit Global Const $iW = 512, $iH = $iW, $iWh = $iW / 2, $iHh = $iH / 2, $sTitle = "GDI+ Swiss Railway Clock v1.1" Global Const $fRad = ACos(-1) / 180, $fDeg = 180 / ACos(-1), $iTimer = 30, $fDeltaShadow = $iW * 0.020 Global $hDC, $hCanvas, $hBitmap_Clock, $hBrush_Shadow, $hBrush_Update, $hPen_Update, $fDiameter = $iW, $hDC_backbuffer, $fShadowAngle, $fMin_next, _ $fRadius = $fDiameter / 2, $fSec, $fMin, $fHr, $fAmplitude = 3 AutoItSetOption("GUIOnEventMode", 1) GDIPlus_SwissRailwayClock() AutoItSetOption("GUIOnEventMode", 0) _GDIPlus_Shutdown() Func GDIPlus_SwissRailwayClock() $bExit = False $hGUI = GUICreate($sTitle, $iW + $fDeltaShadow, $iH + $fDeltaShadow, -1, -1, -1, $WS_EX_TOPMOST) GUISetBkColor(0xFFFFFF, $hGUI) GUISetState(@SW_SHOW, $hGUI) ;~ GUISetCursor(16, 1) ;create canvas elements $hDC = _WinAPI_GetDC($hGUI) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW + $fDeltaShadow, $iH + $fDeltaShadow) $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) $hBrush_Shadow = _GDIPlus_BrushCreateSolid(0x14A0A0A0) $hPen_Update = _GDIPlus_PenCreate(0xFFA02020) $hBrush_Update = _GDIPlus_BrushCreateSolid(0) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) $fDiameter = $fDiameter < 128 ? 128 : $fDiameter > 1024 ? 1024 : $fDiameter $hBitmap_Clock = GenerateClockBg($fDiameter) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About") $fMin_next = @MIN GUIRegisterMsg($WM_TIMER, "Draw") ;$WM_TIMER = 0x0113 Local $iID = DllCall("User32.dll", "uint_ptr", "SetTimer", "hwnd", $hGUI, "uint_ptr", 1, "uint", $iTimer, "ptr", 0)[0] Do If $bExit Then ExitLoop Until Not Sleep(100) ;release resources GUIRegisterMsg($WM_TIMER, "") DllCall("user32.dll", "bool", "KillTimer", "hwnd", $hGUI, "uint_ptr", $iID) _GDIPlus_PenDispose($hPen_Update) _GDIPlus_BrushDispose($hBrush_Shadow) _GDIPlus_BrushDispose($hBrush_Update) _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($hGUI, $hDC) GUIDelete($hGUI) EndFunc ;==>GDIPlus_SwissRailwayClock Func Draw($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _GDIPlus_GraphicsDrawImageRect($hCanvas, $hBitmap_Clock, 0, 0, $fDiameter + $fDeltaShadow, $fDiameter + $fDeltaShadow) UpdateClock($hCanvas, $fDiameter) _WinAPI_BitBlt($hDC, 0, 0, $iW + $fDeltaShadow, $iH + $fDeltaShadow, $hDC_backbuffer, 0, 0, $SRCCOPY) EndFunc Func _Exit_About() $bExit = True EndFunc ;==>_Exit_About Func UpdateClock($hGfx, $fDiameter) Static $bBounce = 0, $f = 0 Local $m1 = $fDiameter * 0.015 ;hour $fHr = 30 * (@HOUR + @MIN / 60) _GDIPlus_GraphicsTranslateTransform($hGfx, $fRadius, $fRadius) _GDIPlus_GraphicsRotateTransform($hGfx, $fHr) _GDIPlus_GraphicsTranslateTransform($hGfx, -$fRadius, -$fRadius) Local $iWidth1 = $fDiameter * 0.0375, _ $iHeight1 = $fDiameter / 2.5, _ $iWidth12 = $iWidth1 / 2, _ $fPosY = $fDiameter * 0.2, $iWidth2, $iWidth22, $fPosY2 _GDIPlus_BrushSetSolidColor($hBrush_Update, 0xFF101010) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hGfx, "handle", $hBrush_Shadow, _ "float", $fRadius - $iWidth12 + Cos(($fShadowAngle - $fHr) * $fRad) * $m1, _ "float", $fPosY + Sin(($fShadowAngle - $fHr) * $fRad) * $m1, _ "float", $iWidth1, "float", $iHeight1) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hGfx, "handle", $hBrush_Update, _ "float", $fRadius - $iWidth12, _ "float", $fPosY, _ "float", $iWidth1, "float", $iHeight1) _GDIPlus_GraphicsResetTransform($hGfx) ;min If $fMin_next <> @MIN Then $bBounce = 1 Switch $bBounce Case 1 $fMin = (6 * Mod(($fMin_next + 1), 60)) + Sin($f * 1.9) * $fAmplitude If $fAmplitude = 0 Then $fMin_next = @MIN $f = 0 $fAmplitude = 3 $bBounce = 0 Else $fAmplitude -= 0.5 $fAmplitude = $fAmplitude <= 0 ? 0 : $fAmplitude $f += 1 EndIf Case Else $fMin = (6 * @MIN) EndSwitch _GDIPlus_GraphicsTranslateTransform($hGfx, $fRadius, $fRadius) _GDIPlus_GraphicsRotateTransform($hGfx, $fMin) _GDIPlus_GraphicsTranslateTransform($hGfx, -$fRadius, -$fRadius) $iWidth1 = $fDiameter * 0.03 $iHeight1 = $fRadius $iWidth12 = $iWidth1 / 2 $fPosY = $fDiameter * 0.1 DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hGfx, "handle", $hBrush_Shadow, _ "float", $fRadius - $iWidth12 + Cos(($fShadowAngle - $fMin) * $fRad) * $m1, _ "float", $fPosY + Sin(($fShadowAngle - $fMin) * $fRad) * $m1, _ "float", $iWidth1, "float", $iHeight1) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hGfx, "handle", $hBrush_Update, _ "float", $fRadius - $iWidth12, _ "float", $fPosY, _ "float", $iWidth1, "float", $iHeight1) _GDIPlus_GraphicsResetTransform($hGfx) ;sec $fSec = 6 * (@SEC * 1.02564 + @MSEC / 1000) If $fSec >= 360 Then $fSec = 0 _GDIPlus_GraphicsTranslateTransform($hGfx, $fRadius, $fRadius) _GDIPlus_GraphicsRotateTransform($hGfx, $fSec) _GDIPlus_GraphicsTranslateTransform($hGfx, -$fRadius, -$fRadius) $fPosY = $fDiameter * 0.27 $fPosY2 = $fDiameter * 0.19 $iWidth1 = $fDiameter * 0.0095 $iHeight1 = $fRadius * 1.3 - $fPosY $iWidth12 = $iWidth1 / 2 $iWidth2 = $fDiameter * 0.083333 $iWidth22 = $iWidth2 / 2 ;shadow seconds DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hGfx, "handle", $hBrush_Shadow, _ "float", $fRadius + Cos(($fShadowAngle - $fSec) * $fRad) * $m1, _ "float", $fPosY + Sin(($fShadowAngle - $fSec) * $fRad) * $m1, _ "float", $iWidth1 + $fDiameter * 0.006667, "float", $iHeight1 + $fDiameter * 0.006667) DllCall($__g_hGDIPDll, "int", "GdipFillEllipse", "handle", $hGfx, "handle", $hBrush_Shadow, _ "float", $fRadius - $iWidth22 + Cos(($fShadowAngle - $fSec) * $fRad) * $m1, _ "float", $fPosY2 + Sin(($fShadowAngle - $fSec) * $fRad) * $m1, _ "float", $iWidth2, "float", $iWidth2) ;seconds _GDIPlus_BrushSetSolidColor($hBrush_Update, 0xFFC01010) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hGfx, "handle", $hBrush_Update, _ "float", $fRadius - $iWidth12, _ "float", $fPosY, _ "float", $iWidth1, "float", $iHeight1) DllCall($__g_hGDIPDll, "int", "GdipFillEllipse", "handle", $hGfx, "handle", $hBrush_Update, _ "float", $fRadius - $iWidth22, _ "float", $fPosY2, _ "float", $iWidth2, "float", $iWidth2) _GDIPlus_GraphicsResetTransform($hGfx) ;button in the center DllCall($__g_hGDIPDll, "int", "GdipFillEllipse", "handle", $hGfx, "handle", $hBrush_Update, _ "float", $fRadius - $iWidth1, _ "float", $fRadius - $iWidth1, _ "float", 2 * $iWidth1, "float", 2 * $iWidth1) DllCall($__g_hGDIPDll, "int", "GdipDrawEllipse", "handle", $hGfx, "handle", $hPen_Update, _ "float", $fRadius - $iWidth1, _ "float", $fRadius - $iWidth1, _ "float", 2 * $iWidth1, "float", 2 * $iWidth1) EndFunc Func GenerateClockBg($fDiameter) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($fDiameter + $fDeltaShadow, $fDiameter + $fDeltaShadow), $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap), _ $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000), $fBorderSize = $fDiameter * 0.03333, _ $hEffect = _GDIPlus_EffectCreateBlur($fDiameter / 50, 0), $hPen = _GDIPlus_PenCreate(0xA0000000, $fBorderSize) _GDIPlus_GraphicsSetSmoothingMode($hGfx, 4) _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 4) _GDIPlus_GraphicsSetTextRenderingHint($hGfx, 4) _GDIPlus_GraphicsClear($hGfx, 0xFFFFFFFF) Local Const $fSize = $fDiameter * 0.95 - $fBorderSize / 2 Local $fShadow_vx = $fDiameter * 0.0095, $fShadow_vy = $fDiameter * 0.01 $fShadowAngle = ATan($fShadow_vy / $fShadow_vx) * $fDeg If $fShadow_vx < 0 And $fShadow_vy >= 0 Then $fShadowAngle += 180 If $fShadow_vx < 0 And $fShadow_vy < 0 Then $fShadowAngle -= 180 _GDIPlus_GraphicsDrawEllipse($hGfx, $fBorderSize + $fShadow_vx, $fBorderSize + $fShadow_vy, $fSize, $fSize, $hPen) _GDIPlus_BitmapApplyEffect($hBitmap, $hEffect) _GDIPlus_PenSetColor($hPen, 0xF0000000) Local Const $hBitmap_Texture = _CreateBrushedAluminum($fDiameter, $fDiameter, $fShadowAngle) Local Const $hTexture = _GDIPlus_TextureCreate($hBitmap_Texture) DllCall($__g_hGDIPDll, "int", "GdipSetPenBrushFill", "ptr", $hPen, "ptr", $hTexture) _GDIPlus_GraphicsDrawEllipse($hGfx, $fBorderSize, $fBorderSize, $fSize, $fSize, $hPen) _GDIPlus_GraphicsTranslateTransform($hGfx, $fRadius, $fRadius) _GDIPlus_GraphicsRotateTransform($hGfx, -6) _GDIPlus_GraphicsTranslateTransform($hGfx, -$fRadius, -$fRadius) Local $iWidth1 = $fDiameter * 0.026667, $iHeight1 = $fDiameter / 10, $iWidth12 = $iWidth1 / 2, $fPosY = $fDiameter * 0.083333, _ $iWidth2 = $fDiameter * 0.013333, $iHeight2 = $fDiameter * 0.0416667, $iWidth22 = $iWidth2 / 2 For $i = 0 to 59 _GDIPlus_GraphicsTranslateTransform($hGfx, $fRadius, $fRadius) _GDIPlus_GraphicsRotateTransform($hGfx, 6) _GDIPlus_GraphicsTranslateTransform($hGfx, -$fRadius, -$fRadius) Switch Mod($i, 5) Case 0 _GDIPlus_GraphicsFillRect($hGfx, $fRadius - $iWidth12, $fPosY, $iWidth1, $iHeight1, $hBrush) Case Else _GDIPlus_GraphicsFillRect($hGfx, $fRadius - $iWidth22, $fPosY, $iWidth2, $iHeight2, $hBrush) EndSwitch Next _GDIPlus_GraphicsResetTransform($hGfx) Local Const $hBitmap_Logo = _GDIPlus_BitmapCreateFromMemory(_Au3_Icon()) Local Const $hBitmap_Logo_Scaled = _GDIPlus_ImageResize($hBitmap_Logo, $fDiameter * 0.08, $fDiameter * 0.08) Local $aDim = _GDIPlus_ImageGetDimension($hBitmap_Logo_Scaled) _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Logo_Scaled, $fRadius - $aDim[0] / 2, $fRadius / 1.75, $aDim[0], $aDim[1]) _GDIPlus_ImageDispose($hBitmap_Logo) _GDIPlus_ImageDispose($hBitmap_Logo_Scaled) Local Const $hFamily = _GDIPlus_FontFamilyCreate("Segoe Script"), $hFont = _GDIPlus_FontCreate($hFamily, $fDiameter * 0.025), $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;~ _GDIPlus_BrushSetSolidColor($hBrush, 0xFF400000) _GDIPlus_GraphicsDrawStringEx($hGfx, "Clock by" & @CRLF & "UEZ", $hFont, _GDIPlus_RectFCreate($fRadius - $fRadius * 0.2, $fRadius + $fRadius * 0.2, $fRadius * 0.4, $fRadius * 0.4), $hFormat, $hBrush) _GDIPlus_ImageDispose($hBitmap_Texture) _GDIPlus_BrushDispose($hTexture) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_EffectDispose($hEffect) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfx) Return $hBitmap EndFunc Func _CreateBrushedAluminum($iW, $iH, $fLightAngle = 40, $iBlurDist = 12, $fBlurTrans = 0.6666, $fRed = 0.8, $fGreen = 0.9, $fBlue = 1, $iLightColor = 0xF0FFFFFF, $fLightSigma = 0.5, $fLightScale = 0.83) ;coded by Eukalyptus! $iBlurDist = Ceiling($iBlurDist) $iBlurDist += 1 - Mod($iBlurDist, 2) Local $iOverSize = 0 For $i = 1 To $iBlurDist Step 2 $iOverSize += $i + $i + 1 Next Local $iWO = $iW + $iOverSize ;========================================= ; Add Noise ;========================================= Local $iNoiseSize = 40 Local $hBmp_Noise = _GDIPlus_BitmapCreateFromScan0($iNoiseSize, $iNoiseSize) Local $hGfx_Noise = _GDIPlus_ImageGetGraphicsContext($hBmp_Noise) Local $tData = _GDIPlus_BitmapLockBits($hBmp_Noise, 0, 0, $iNoiseSize, $iNoiseSize, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB) Local $iStride = DllStructGetData($tData, "Stride") Local $iWidth = DllStructGetData($tData, "Width") Local $iHeight = DllStructGetData($tData, "Height") Local $pScan0 = DllStructGetData($tData, "Scan0") Local $tPixel = DllStructCreate("dword[" & $iWidth * $iHeight & "];", $pScan0) Local $iAmp For $row = 0 To $iHeight - 1 For $col = 0 To $iWidth - 1 $iAmp = Random(0, 0xFF, 1) DllStructSetData($tPixel, 1, BitOR(0xFF000000, BitShift($iAmp, -16), BitShift($iAmp, -8), $iAmp), $row * $iWidth + $col + 1) Next Next _GDIPlus_BitmapUnlockBits($hBmp_Noise, $tData) ;========================================= ; Create Full NoiseBitmap ;========================================= Local $hBmp_Full = _GDIPlus_BitmapCreateFromScan0($iWO, $iH) Local $hGfx_Full = _GDIPlus_ImageGetGraphicsContext($hBmp_Full) _GDIPlus_GraphicsSetSmoothingMode($hGfx_Full, 4) _GDIPlus_GraphicsSetInterpolationMode($hGfx_Full, 3) Local $iXOff, $iYOff, $iSizeX, $iSizeY For $y = 0 To $iH Step $iNoiseSize / 2 For $x = 0 To $iWO Step $iNoiseSize / 2 $iXOff = Random(0, $iNoiseSize / 2, 1) $iYOff = Random(0, $iNoiseSize / 2, 1) $iSizeX = $iNoiseSize - $iXOff $iSizeY = $iNoiseSize - $iYOff _GDIPlus_GraphicsDrawImageRectRect($hGfx_Full, $hBmp_Noise, $iXOff, $iYOff, $iSizeX, $iSizeY, $x, $y, $iSizeX, $iSizeY) Next Next _GDIPlus_GraphicsDispose($hGfx_Noise) _GDIPlus_BitmapDispose($hBmp_Noise) ;========================================= ; MotionBlur ;========================================= Local $hBmp_Full2 = _GDIPlus_BitmapCreateFromScan0($iWO, $iH) Local $hGfx_Full2 = _GDIPlus_ImageGetGraphicsContext($hBmp_Full2) _GDIPlus_GraphicsSetSmoothingMode($hGfx_Full2, 4) _GDIPlus_GraphicsSetInterpolationMode($hGfx_Full, 3) Local $tColorMatrix = DllStructCreate("float[5]; float[5]; float[5]; float[5]; float[5];") DllStructSetData($tColorMatrix, 1, 1, 1) DllStructSetData($tColorMatrix, 2, 1, 2) DllStructSetData($tColorMatrix, 3, 1, 3) DllStructSetData($tColorMatrix, 4, $fBlurTrans, 4) DllStructSetData($tColorMatrix, 5, 1, 5) Local $hImgAttrib = _GDIPlus_ImageAttributesCreate() DllCall($__g_hGDIPDll, "int", "GdipSetImageAttributesColorMatrix", "ptr", $hImgAttrib, "int", 1, "int", 1, "struct*", $tColorMatrix, "struct*", 0, "int", 0) For $i = 1 To $iBlurDist Step 2 DllCall($__g_hGDIPDll, "int", "GdipDrawImageRectRect", "ptr", $hGfx_Full2, "ptr", $hBmp_Full, _ "float", $i, "float", 0, "float", $iWO, "float", $iH, _ "float", 0, "float", 0, "float", $iWO, "float", $iH, _ "int", 2, "ptr", $hImgAttrib, "ptr", 0, "ptr", 0) If $i >= $iBlurDist Then DllStructSetData($tColorMatrix, 1, $fRed, 1) DllStructSetData($tColorMatrix, 2, $fGreen, 2) DllStructSetData($tColorMatrix, 3, $fBlue, 3) DllStructSetData($tColorMatrix, 4, 1, 4) DllCall($__g_hGDIPDll, "int", "GdipSetImageAttributesColorMatrix", "ptr", $hImgAttrib, "int", 1, "int", 1, "struct*", $tColorMatrix, "struct*", 0, "int", 0) EndIf DllCall($__g_hGDIPDll, "int", "GdipDrawImageRectRect", "ptr", $hGfx_Full, "ptr", $hBmp_Full2, _ "float", $i + 1, "float", 0, "float", $iWO, "float", $iH, _ "float", 0, "float", 0, "float", $iWO, "float", $iH, _ "int", 2, "ptr", $hImgAttrib, "ptr", 0, "ptr", 0) Next _GDIPlus_ImageAttributesDispose($hImgAttrib) _GDIPlus_GraphicsDispose($hGfx_Full2) _GDIPlus_BitmapDispose($hBmp_Full2) _GDIPlus_GraphicsDispose($hGfx_Full) ;========================================= ; Add Light ;========================================= Local $hBmp_Alu = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local $hGfx_Alu = _GDIPlus_ImageGetGraphicsContext($hBmp_Alu) _GDIPlus_GraphicsSetSmoothingMode($hGfx_Alu, 4) _GDIPlus_GraphicsSetInterpolationMode($hGfx_Full, 3) _GDIPlus_GraphicsDrawImage($hGfx_Alu, $hBmp_Full, -$iOverSize, 0) _GDIPlus_BitmapDispose($hBmp_Full) Local $tPointF1 = DllStructCreate("float; float;") Local $tPointF2 = DllStructCreate("float; float;") DllStructSetData($tPointF2, 2, $iH * $fLightScale) $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateLineBrush", "struct*", $tPointF1, "struct*", $tPointF2, "uint", 0, "uint", $iLightColor, "int", 0, "handle*", 0) If @error Or Not IsArray($aResult) Then Return SetError(1, 4, False) Local $hBrush = $aResult[6] _GDIPlus_LineBrushSetSigmaBlend($hBrush, $fLightSigma) _GDIPlus_LineBrushSetGammaCorrection($hBrush) DllCall($__g_hGDIPDll, "int", "GdipRotateLineTransform", "ptr", $hBrush, "float", $fLightAngle, "int", 0) _GDIPlus_GraphicsFillRect($hGfx_Alu, 0, 0, $iW, $iH, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfx_Alu) Return $hBmp_Alu EndFunc ;==>_CreateBrushedAluminum ;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2018-02-02 Func _Au3_Icon($bSaveBinary = False, $sSavePath = @ScriptDir) Local $Au3_Icon $Au3_Icon &= 'iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAP0ElEQVR4XtWZW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GTPF+JRKv24Dbp71GX9M8L84Jo46QVTs6gAAAABJRU5ErkJggg==' Local $bString = _WinAPI_Base64Decode($Au3_Icon) If @error Then Return SetError(1, 0, 0) $bString = Binary($bString) If $bSaveBinary Then Local Const $hFile = FileOpen($sSavePath & "\au3-icon2.png", 18) If @error Then Return SetError(2, 0, $bString) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_Au3_Icon Func _WinAPI_Base64Decode($sB64String) Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "") Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]") $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "") Return DllStructGetData($bBuffer, 1) EndFunc ;==>_WinAPI_Base64Decode If you want to run in x64 mode please use AutoIt version 3.3.14.3 since the bug in function _GDIPlus_EffectCreate() has been fixed!
    1 point
  16. Hello again. Both functions, _FileReadToArray() and _ArrayUnique(), have parameters that enable or disable the line count being assigned to the first element of the array- see AutoIt help file. Or you can click on these functions that are blue in colour in the code box below to see the online AutoIt help. #include <File.au3> #include <Array.au3> ProcessAndCleanFiles() Func ProcessAndCleanFiles() Local $sFileName = "\\poop\IC3.txt" ; FileToWorkOn ;Remove the extra /'s at the end of each TestCodeLineFor IC3 Local $Whattowrite = StringRegExpReplace(FileRead($sFileName), "(?m)/*$", "") Local $hFileOpen = FileOpen($sFileName, 2) FileWrite($hFileOpen, $Whattowrite) FileClose($hFileOpen) ; Remove duplicates from file Local $aFile, $aArray _FileReadToArray($sFileName, $aFile, 0) ; $iFlags parameter, $FRTA_NOCOUNT (0) - array is 0-based use UBound() to get size, _ArrayDisplay($aFile) $aArray = _ArrayUnique($aFile, 0, 0, 0, 0) ; $iCount parameter, $ARRAYUNIQUE_NOCOUNT (0) returns a list without a count. _ArrayDisplay($aArray) _FileWriteFromArray($sFileName, $aArray) EndFunc ;==>ProcessAndCleanFiles
    1 point
  17. I'm sorry but I do not write in English I need to google translator I read this document http://books.google.it/books?id=1TpDgwNGIK8C&pg=PA28&lpg=PA28&dq=cross-reference+table+corrupted+file+pdf&source=bl&ots=oFAVUiJD-T&sig=RWW2bQkS04Q-v7U5aMTK4qwY944&hl=it&sa=X&ei=hogcU_-iEqvpywO654DgBA&redir_esc=y#v=onepage&q=cross-reference%20table%20corrupted%20file%20pdf&f=false I edited the original file release 1.0.3 I changed all @crlf whit chr(10) Global $PDF_VERSION = "%PDF-1.5" & @CRLF & "%" & ChrW(199) & ChrW(200) & ChrW(201) & ChrW(202) whit Global $PDF_VERSION = "%PDF-1.5" & chr(10) & "%" & ChrW(226) & ChrW(227) & ChrW(207) & ChrW(211) into Func _BeginPage __ToBuffer("<< /Length " & $intPage + 2 & " 0 R >>" & @CRLF & "stream") whit __ToBuffer("<<"&chr(10)&"/Length >>stream") into Func _ClosePDFFile() __ToBuffer("xref") __ToBuffer("0 " & $_iMaxObject+1) __ToBuffer("0000000000 65535 f") For $i = 1 To $_iMaxObject __ToBuffer($aXREF[$i]) Next __ToBuffer("trailer" & @CRLF & _ "<< /Size " & $_iMaxObject + 1 & "/Info 1 0 R" & "/Root 2 0 R" & ">>") __ToBuffer("startxref" & @CRLF & StringLen("startxref" & @CRLF & $_Buffer & "%%EOF" & @CRLF) + 6) $_FileName = FileOpen($PDF_NAME,18) FileWrite($_FileName, $_Buffer & "%%EOF" & @CRLF) FileClose($_FileName) If $_bOpen Then ShellExecute($PDF_NAME) whit dim $position_xref=stringlen($_Buffer) __ToBuffer("xref") __ToBuffer("0 " & $_iMaxObject+1) __ToBuffer("0000000000 65535 f"&chr(13)) For $i = 1 To $_iMaxObject __ToBuffer($aXREF[$i]&chr(13)) Next __ToBuffer("trailer" & chr(10) & _ "<< /Size " & $_iMaxObject + 1 & "/Info 1 0 R" & "/Root 2 0 R" & ">>") __ToBuffer("startxref" & chr(10) & $position_xref & chr(10) & "%%EOF") $_FileName = FileOpen($PDF_NAME,18) FileWrite($_FileName, $_Buffer) FileClose($_FileName) $_Pages = "" $_sPage = "" $_sFONT = "" $_Image = "" $_sObject = "" $_iResource = "" $_Buffer = "" If $_bOpen Then ShellExecute($PDF_NAME) into Func _LoadResImage __ToBuffer("<</Type /XObject /Subtype /Image /Name /" & $sImgAlias & " /Width " & $_iImageW & " /Height " & $_iImageH & " /Filter /DCTDecode /ColorSpace /DeviceRGB /BitsPerComponent 8" & " /Length " & $iObj + 1 & " 0 R" & ">>") __ToBuffer("stream" & @CRLF & $ImgBuf & @CRLF & "endstream") whit __ToBuffer("<</Type /XObject /Subtype /Image /Name /" & $sImgAlias & " /Width " & $_iImageW & " /Height " & $_iImageH & " /Filter /DCTDecode /ColorSpace /DeviceRGB /BitsPerComponent 8"&chr(10)&"/Length "&stringlen($ImgBuf)&">>stream") __ToBuffer($ImgBuf) __ToBuffer("endstream") into Func _StartObject __ToBuffer("<< /Type /XObject /Subtype /Form /FormType 1 /Name /" & $sAlias & " /BBox [" & __ToStr($__SetMargin) & " " & __ToStr($__SetMargin) & " " & __ToStr($_PageWidth - $__SetMargin) & " " & __ToStr($_PageHeight - $__SetMargin) & "] /Matrix [1 0 0 1 0 0] /Length " & $i + 1 & " 0 R >>" & @CRLF & _ "stream") whit __ToBuffer("<< /Type /XObject /Subtype /Form /FormType 1 /Name /" & $sAlias & " /BBox [" & __ToStr($__SetMargin) & " " & __ToStr($__SetMargin) & " " & __ToStr($_PageWidth - $__SetMargin) & " " & __ToStr($_PageHeight - $__SetMargin) & "] /Matrix [1 0 0 1 0 0]"&chr(10)&"/Length >>stream") into Func __InitObj $aXREF[$iObj] = StringRight("0000000000" & StringLen($_Buffer)+$_Offset+$iObj+1, 10) & " 00000 n" whit $aXREF[$iObj] = StringRight("0000000000" & StringLen($_Buffer), 10) & " 00000 n" into Func _EndObject() $_iTmpOffset = $_Offset - $_iTmpOffset __ToBuffer("endstream") __EndObj() __InitObj() __ToBuffer($_iTmpOffset) __EndObj() whit $_iTmpOffset = $_Offset - $_iTmpOffset __ToBuffer("endstream") __EndObj() dim $aArray1=_StringBetween($_Buffer,"/Length >>stream","endstream") dim $stringlen for $i=0 to ubound($aArray1)-1 $stringlen=$stringlen+stringlen($aArray1[$i]) next $_Buffer=StringReplace($_Buffer,"/Length >>stream","/Length "&$stringlen-1&">>stream") __InitObj() __ToBuffer($_iTmpOffset) __EndObj() into Func _EndPage() $_iTmpOffset = $_Offset - $_iTmpOffset __ToBuffer("endstream") __EndObj() ; Scrie dimensiunea __InitObj() __ToBuffer($_iTmpOffset) __EndObj() whit $_iTmpOffset = $_Offset - $_iTmpOffset __ToBuffer("endstream") __EndObj() dim $aArray1=_StringBetween($_Buffer,"/Length >>stream","endstream") dim $stringlen for $i=0 to ubound($aArray1)-1 $stringlen=$stringlen+stringlen($aArray1[$i]) next $_Buffer=StringReplace($_Buffer,"/Length >>stream","/Length "&$stringlen-1&">>stream") ; Scrie dimensiunea __InitObj() __ToBuffer($_iTmpOffset) __EndObj() so my pdf files are compatible with "Acrobat Reader X" and "flipping pdf reader" and "sumatra pdf" and "pdf-xchange viewer" I am attaching the modified file udf MPDF_UDF.au3
    1 point
  18. Gianni

    AutoIt Snippets

    This function (micro Lookup) receives either an IPv4 address or a hostname or an DomainName and returns an array with: [0] IP Address [1] Hostname.DomainName [2] Hostname (alone) to determine if the incoming data is an ip address it uses an regular expression pattern found here #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <iNet.au3> ; example of use: Local $Net_Result[3] Local $NetAdrs[5] = ["localhost", @ComputerName, "127.0.0.1", "www.google.com", "216.34.181.60"] For $i = 0 To UBound($NetAdrs) - 1 $Net_Result = _mLookup($NetAdrs[$i]) ConsoleWrite($Net_Result[0] & @TAB & $Net_Result[1] & @CRLF) Next ; This Function accepts either an IPaddress or a Host/Domain name and returns ; a 3 elements array element[0]=IPaddress element[1]=hostname.domain element[2]=hostnameOnly Func _mLookup($Net_ID) Local $Net_Names[3] TCPStartup() If StringRegExp($Net_ID, "^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$") Then $Net_Names[1] = _TCPIpToName($Net_ID) ; Resolves IP adress to Hostname If @error Then $Net_Names[1] = "Hostname_error" $Net_Names[0] = $Net_ID Else $Net_Names[0] = TCPNameToIP($Net_ID) ; Resolves Hostname to IP adress If @error Then $Net_Names[0] = "IP_error" $Net_Names[1] = $Net_ID EndIf TCPShutdown() Local $temp = StringSplit($Net_Names[1], ".") $Net_Names[2] = $temp[1] Return $Net_Names EndFunc ;==>_mLookup bye
    1 point
  19. guinness

    AutoIt Snippets

    This is my 200th documented snippet (though some are re-writes) and my last for quite some time, so good luck to those who post snippets here. ConsoleWrite('GMT TimeStamp: ' & _GetUnixTimeStamp() & @CRLF) ; Version: 1.00. AutoIt: V3.3.8.1 ; Retrieve the current unix timestamp of todays date. Func _GetUnixTimeStamp() Local $aReturn = StringRegExp(BinaryToString(InetRead('http://www.currenttimestamp.com')), 'current_times=s(d{10});', 3) If @error Then Return SetError(1, 0, 0) EndIf Return StringStripWS($aReturn[0], 3) EndFunc ;==>_GetUnixTimeStamp
    1 point
  20. PsaltyDS

    Zoom IE

    There is no zoom in an IE ActiveX control (embedded) instance, even when done manually. So as far as I know you're out of luck. Exactly as with the full IE instance, XDPI and YDPI are there for read-only reference, though: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> _IEErrorHandlerRegister () $oIE = _IECreateEmbedded () GUICreate("Embedded Web control Test", 640, 580, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360) $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30) $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30) $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30) $GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30) GUISetState() ;Show GUI _IENavigate ($oIE, "http://www.autoitscript.com") $oScreen = $oIE.document.parentwindow.screen $iXDPI = $oScreen.deviceXDPI $iYDPI = $oScreen.deviceYDPI $iLogicalXDPI = $oScreen.logicalXDPI $iLogicalYDPI = $oScreen.logicalYDPI $iXZoom = $iXDPI / $iLogicalXDPI * 100 $iYZoom = $iYDPI / $iLogicalYDPI * 100 ConsoleWrite("$iXDPI = " & $iXDPI & "; $iYDPI = " & $iYDPI & @LF) ConsoleWrite("$iLogicalXDPI = " & $iLogicalXDPI & "; $iLogicalYDPI = " & $iLogicalYDPI & @LF) ConsoleWrite("Horizontal Zoom = %" & $iXZoom & "; Vertical Zoom = %" & $iYZoom & @LF) ; Waiting for user to close the window While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_Button_Home _IENavigate ($oIE, "http://www.autoitscript.com") Case $msg = $GUI_Button_Back _IEAction ($oIE, "back") Case $msg = $GUI_Button_Forward _IEAction ($oIE, "forward") Case $msg = $GUI_Button_Stop _IEAction ($oIE, "stop") EndSelect WEnd GUIDelete() Exit
    1 point
×
×
  • Create New...