Jump to content

Recommended Posts

Posted

Hello, I have an autoit program that has various keyboard shortcuts to make my job easier.  One of the fuctions in the larger program converts a highlighted MAC address to make it lower case and in a xxxx.xxxx.xxxx format.  It worked great for years, I have a new machine at work and its suddenly stopped working and I can't figure out why.  I am not a programmer (I know networking).  

HotKeySet("^{`}", "macfix")                ;  format MAC addresses
Func macfix()
    ClipPut ("")
    _SendEx("^c")
    $mac = ClipGet()
    $mac = StringLower($mac) ; convert to lower case if necessary
    $mac = StringRegExpReplace ($mac, "[^0-9a-f]", "")  ; remove anything besides numbers and letters a-f
    If (StringLen ($mac) <> 12) Then
        MsgBox (0, "Error", "Invalid MAC address")  ; check for correct number of characters
    Else
        $macSplit = StringSplit($mac, "")  ;  split mac apart, every character to a different position of the array
        Sleep (20)
        $mac = $macSplit[1] & $macSplit[2] & $macSplit[3] & $macSplit[4] & "." & $macSplit[5] & $macSplit[6] & $macSplit[7] & _
                $macSplit[8] & "." & $macSplit[9] & $macSplit[10] & $macSplit[11] & $macSplit[12]  ;  recombine them into a valid mac address
        _SendeX ($mac)  ;  replace highlighted text with corrected mac address
        ClipPut ($mac)  ;  put new mac address in clipboard for easy pasting
    EndIf
EndFunc

The function will just return the 'invalid mac address' error even if its a valid string.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...