#include-once ; =================================================================== ;~ Author : Olish ;~ Created : 2006/07/25 ; =================================================================== ;~ Modified : pat4005 ;~ Last modified : 2020/06/11 ; =================================================================== ; Example ;~ _WoL_WakeDevice('001CC0CAED7A') ; the second parameter (if necessery) must be a broadcast address of your local network segment (i.e. 192.168.0.255 for a network 192.168.0.0) ; =================================================================== ; Functions ; =================================================================== Func _WoL_WakeDevice($sMACAddress, $sIPAddress = StringRegExp(@IPAddress1, '(.*\..*\..*\.).*', 1)[0] & 255) Local $iSocket, $iResult UDPStartUp() $iSocket = UDPOpen($sIPAddress, 7) $iResult = UDPSend($iSocket, _WOL_GenerateMagicPacket($sMACAddress)) UDPCloseSocket($iSocket) UDPShutdown() EndFunc ; This function generate the "Magic Packet" Func _WOL_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 ; This function convert a MAC Address Byte (e.g. "1f") to a char Func _HexToChar($strHex) Return Chr(Dec($strHex)) EndFunc