Leaderboard
Popular Content
Showing content with the highest reputation on 02/15/2013 in all areas
-
Hello everybody ! You want a source code for Wake On LAN without copyright ? It's here ! ENJOY ! $IPAddress = "192.168.1.255"; This is the broadcast address ! $MACAddress = "000D8787E226" UDPStartUp() $connexion = UDPOpen($IPAddress, 7) $res = UDPSend($connexion, GenerateMagicPacket($MACAddress)) MsgBox(0, "", $res) UDPCloseSocket($connexion) UDPShutdown() ; =================================================================== ; Functions ; =================================================================== ; This function convert a MAC Address Byte (e.g. "1f") to a char Func HexToChar($strHex) Return Chr(Dec($strHex)) EndFunc ; This function generate the "Magic Packet" Func GenerateMagicPacket($strMACAddress) $MagicPacket = "" $MACData = "" For $p = 1 To 11 Step 2 $MACData = $MACData & HexToChar(StringMid($strMACAddress, $p, 2)) Next For $p = 1 To 6 $MagicPacket = HexToChar("ff") & $MagicPacket Next For $p = 1 To 16 $MagicPacket = $MagicPacket & $MACData Next Return $MagicPacket EndFunc Thanks for your remarks... Next to see you !1 point
-
JohnOne, I always thought I went to Gatwick rather than Bristol. M231 point
-
jdelaney, You could use a wrapper function along these lines: #include <Array.au3> $sString = "Here is a string which we will split" Global $aArray[2] = [$sString, StringSplit($sString, " ")] _Extract_Inner_Index($aArray[1], 2) _ArraySort($aArray[1], 0, 1) _Extract_Inner_Index($aArray[1], 2) Func _Extract_Inner_Index(ByRef $avInput, $iIndex) MsgBox(64, "_Extract_Inner_Index", "Index [" & $iIndex & "] = " & $avInput[$iIndex]) EndFunc It needs a lot of errorchecking code added and is not exactly elegant, but it is better than nothing. M231 point
-
If you compile the program as a 32 bit program and use this to momentarily turn off redirection to run the Telnet program, it won't matter which version of the OS it's being run on because it will just ignore the redirection request on a system that it doesn't apply to (x86 OS). #autoit3wrapper_usex64=n ; runs the script in 32 bit program mode ; Use False to disable redirection, it will only apply to the program if running as 32 bit process _Wow64FsRedirection(False) Run("C:\Windows\System32\telnet.exe") _Wow64FsRedirection(True) ; http://www.autoitscript.com/forum/topic/111647-macro-problem-in-win7-x64/#entry790037 Func _Wow64FsRedirection($state) ; Disables or reverts the filesystem redirector for a 32 bit process running on 64bit OS If Not @AutoItX64 And @OSArch = 'X64' Then If $state Then DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "int", 0) Else DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 0); or 1 as per help EndIf If @error Then Return SetError(1) EndIf EndFunc1 point
-
Need Help... Array to ListView
coffeeturtle reacted to Mowalk for a topic
Of course! the problem was that if the Gateway or the DNS were not configured in the system the variable $currentDNS and $currentGW were empty variable instead of an array. Thats why i got the Subscript used with non-Array variable error. So i add lines which check if the variables are arrays and if not turn them into arrays. I also added the "not set" so that the listview woulnd't just be empty at that part of the table but say that the GW/DNS is not set. i hope that makes sense so far. here is the new code Func UpdateAdapters() _GUICtrlListView_DeleteAllItems($ListView) $count = 0 $objWMI = ObjGet("winmgmts:\\.\root\cimv2") $collection = $objWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colNIC = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapter WHERE Netconnectionstatus = 2") Dim $pcinfo For $object In $colNIC $pcinfo = $pcinfo & $object.name & @CRLF Next For $obj In $collection If $obj.DHCPEnabled = -1 Then $currentDHCPStatus = "TRUE" Else $currentDHCPStatus = "FALSE" EndIf $currentIP = $obj.IPAddress $currentSubnet = $obj.IPSubnet $currentGateway = $obj.DefaultIPGateway $currentDNS = $obj.DNSServerSearchOrder Next For $obj In $collection $count = $count + 1 If $obj.DHCPEnabled = -1 Then $currentDHCPStatus1 = "TRUE" Else $currentDHCPStatus1 = "FALSE" EndIf $currentIP = $obj.IPAddress $currentSubnet = $obj.IPSubnet $currentGateway = $obj.DefaultIPGateway $currentDNS = $obj.DNSServerSearchOrder ; New Lines start here---------------------- if Not IsArray($currentGateway) Then Dim $currentGateway[$count+1] $currentGateway[0] = "not set" EndIf if Not IsArray($currentDNS) Then Dim $currentDNS[$count+1] $currentDNS[0] = "not set" EndIf ;New Lines end here--------------------- $item2 = GUICtrlCreateListViewItem("Name | Subnet | Gateway | DNS | DHCP", $ListView) GUICtrlSetData($item2, $pcinfo & " | " & $currentIP[0] & " | " & $currentSubnet[0] & " | " & $currentGateway[0] & " | " & $currentDNS[0] & " | " & $currentDHCPStatus) Next EndFunc1 point -
Crazy crypt
ActualAkshay reacted to Melba23 for a topic
ActualAkshay, I did - look at edit in my post above. M231 point -
Crazy crypt
ActualAkshay reacted to Melba23 for a topic
ActualAkshay, You get a different result from the first encryption because you are encrypting a number - the second and third results are identical (as I expected) because you are encrypting the same string in each case. All clear? M23 Edit: And the fourth is different again because you are encrypting a different string (with surrounding quotes).1 point -
wolf9228 #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0 This code will make your script even less than it is now. You can add #include1 point
-
I made a dll that will use winhttp in threads to make multiple background requests. I couldn't get it to work with autoit and the winhttp library or wininet either. the multithreaded dll worked nicely, maybe you can try that.1 point
-
Good coding practices in AutoIt
jaberwacky reacted to BrewManNH for a topic
What is the consensus on functions doing one thing and only one thing? In other words, would it be considered good coding practice to make your functions work this way? I'm throwing this out there because I honestly don't know what the best practice is for this case. I read on here about functions doing one thing and only one thing to make the code easier to follow. Now of course, this applies to C++ programming, but I wonder if it should apply equally to good coding practices in AutoIt? I found that by doing this in one of my larger scripts, it makes the script easier to follow without so many comments needed. Now the functions are named what each piece was doing, rather than a loop in the middle of a function with a comment telling me why it's there.1 point -
This should work too: $PID = Run(".....") AdlibRegister("_CheckProcess", 250) ; Your code goes here Func _CheckProcess() If Not ProcessExists($PID) Then exit EndFunc1 point
-
resolve remote computername
minimen456 reacted to UEZ for a topic
I don't know whether _TCPIpToName will work when there is no DNS/WINS available. Here a WMI version: ;code by UEZ 2011 Global Const $oErrorHandler = ObjEvent("AutoIt.Error", "ObjErrorHandler") $sIP = "127.0.0.1" MsgBox(0, "Get Host Name", "IP: " & $sIP & " -> Host Name: " & WMI_GetHostName($sIP)) Func WMI_GetHostName($host) Local $HostNameWMI, $colItems, $colItem, $ping $ping = Ping($host) If $ping Then $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $host & "\root\cimv2") If @error Then Return SetError(2, 0, "") $colItems = $objWMIService.ExecQuery("SELECT SystemName FROM Win32_NetworkAdapter WHERE NetConnectionStatus=2", "WQL", 0x30) If IsObj($colItems) Then For $objItem In $colItems If $objItem.SystemName = "" Then Return SetError(3, 0, "") Return $objItem.SystemName Next Return $HostNameWMI Else Return SetError(3, 0, "") EndIf Else Return SetError(1, 0, "") EndIf EndFunc Func ObjErrorHandler() ConsoleWrite( "A COM Error has occured!" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oErrorHandler.description & @CRLF & _ "err.windescription:" & @TAB & $oErrorHandler & @CRLF & _ "err.number is: " & @TAB & Hex($oErrorHandler.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oErrorHandler.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oErrorHandler.scriptline & @CRLF & _ "err.source is: " & @TAB & $oErrorHandler.source & @CRLF & _ "err.helpfile is: " & @TAB & $oErrorHandler.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oErrorHandler.helpcontext & @CRLF _ ) EndFunc Br, UEZ1 point