msdn constants importer

    • Offizieller Beitrag

    Hallo,

    Ein paar von euch kennen das Problem bestimmt auch: Man will mal wieder eine super UDF zaubern und holt sich die Informationen von msdn. Die Funktionen rauszuschreiben funktioniert meistens ohne Probleme, aber es ist schrecklich alle Struct-Konstanten (DllStructCreate) von msdn in ein Script zu packen, und das auch noch richtig Formatiert.
    Deswegen dieses kleine Tool: Einfach starten, ein Link von msdn in die Zwischenablage kopieren und das Tool macht den rest. Es holt sich die Daten von msdn und schreibt sie, natürlich hübsch Formatiert, in eine von dem Anwender spezifizierte Datei.

    Hiermal ein Beispiel link: http://msdn.microsoft.com/en-us/library/ms941841.aspx

    Hoffe es kann jemand gebrauchen:

    Spoiler anzeigen
    [autoit]

    ;==================
    ;msdn constants importer
    ;by GtaSpider
    ;==================

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;PLEASE CHANGE IF YOU WANT
    Global Const $sVarBefore = "$tag" ; will be: $tagTITLE_OF_THE_CONSTANT
    Global Const $sConstFileToWrite = @ScriptDir&"\Clip_Constants.au3"; the Constants will be written in the next line of the file
    ;STOP CHANGE

    [/autoit] [autoit][/autoit] [autoit]

    FileWrite($sConstFileToWrite,";Constants importet from msdn with 'msdn constants importer' by GtaSpider'"&@CRLF&@CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("^c","_clip")
    HotKeySet("^C","_clip")
    HotKeySet("^{ins}","_clip")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(500)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _clip()
    HotKeySet(@HotKeyPressed)
    Send(@HotKeyPressed)
    Local $sURL = ClipGet()
    If StringInStr($sURL,"msdn.microsoft.com") Then
    TrayTip("Clip",$sURL,2)
    Local $sSource = BinaryToString(InetRead($sURL))
    Local $aRegExp = StringRegExp($sSource,'(?s)<div class="title">(.*?)</div>.*?<pre class="libCScode".*?>.*?\{(.*?)}.*?</pre>',3)
    If UBound($aRegExp) < 2 Then
    MsgBox(16,"Clip","Error, RegExp returnd bad values")
    Else
    Local $sTitle = $aRegExp[0]
    Local $sData = $aRegExp[1]

    [/autoit] [autoit][/autoit] [autoit]

    $sData = StringStripCR(StringReplace(StringReplace($sData,@LF,''),@CRLF,''))
    Local $sNewLine = 'Global Const '&$sVarBefore&$sTitle&' = "',$sRet
    Local $aData = StringSplit($sData,";"),$i
    For $i = 1 To $aData[0]
    If Not StringLen($aData[$i]) Then ContinueLoop
    $sNewLine &= $aData[$i]&"; "
    If StringLen($sNewLine) > 100 Then
    $sRet &= $sNewLine& '" & _'&@CRLF
    $sNewLine = @TAB&@TAB&'"'
    EndIf
    Next
    $sRet &= $sNewLine&'"'
    If StringRight($sRet,10) = ' & _'&@CRLF&@TAB&@TAB&'""' Then $sRet = StringTrimRight($sRet,10)
    FileWrite($sConstFileToWrite,$sRet&@CRLF)
    TrayTip($sTitle,"Successful insertet to"&@CRLF&$sConstFileToWrite,2)
    EndIf
    EndIf
    HotKeySet(@HotKeyPressed,"_clip")
    EndFunc

    [/autoit]

    Greetings
    Spider