[SciTE] Send To aPaste

    • Ein markierter Abschnitt oder die gesammte Datei wird per POST an apaste.square7.ch verschickt und der Link geholt.
    • Die aktuellen Einstellungen zu Syntax und Ablaufdatum werden in einer .ini abgelegt und beim nächsten Skriptaufruf wieder geladen.
    • Starten per Tool-Menü oder Ctrl+Shift+Alt+A.

    [Blockierte Grafik: http://www.abload.de/img/unbenanntyfucz.png]

    "in \AutoIt3\SciTE\aPaste\apaste.au3 speichern"
    [autoit]


    #region include
    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>
    #include <array.au3>
    #include <String.au3>
    #endregion include

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

    Opt("GUIOnEventMode", 1)
    Opt("GUIResizeMode", 544)
    #region
    Global $oReceived, $sLink
    Global $settings = @ScriptDir & "\settings.ini"
    Global $aSyntax[158][2] = [["autoit", "AutoIt"], _
    ["bash", "BASH"], _
    ["c", "C"], _
    ["cpp", "C++"], _
    ["css", "CSS"], _
    ["html4strict", "HTML 4.01 strict"], _
    ["java", "Java"], _
    ["javascript", "JavaScript"], _
    ["mirc", "mIRC"], _
    ["perl", "Perl"], _
    ["php", "PHP"], _
    ["text", "Plain text"], _
    ["python", "Python"], _
    ["rails", "Ruby on Rails"], _
    ["ruby", "Ruby"], _
    ["sql", "SQL"], _
    ["tcl", "TCL"], _
    ["whois", "WHOIS (RPSL format)"], _
    ["xml", "XML"], _
    ["xorg_conf", "xorg.conf"], _
    ["text", "Plain Text"], _
    ["abap", "ABAP"], _
    ["actionscript", "ActionScript"], _
    ["actionscript3", "ActionScript 3"], _
    ["ada", "Ada"], _
    ["apache", "Apache"], _
    ["applescript", "AppleScript"], _
    ["apt_sources", "Apt sources.list"], _
    ["asm", "ASM"], _
    ["asp", "ASP"], _
    ["autoit", "AutoIt"], _
    ["avisynth", "AviSynth"], _
    ["bash", "BASH"], _
    ["basic4gl", "Basic4GL"], _
    ["bf", "Brainfuck"], _
    ["bibtex", "BibTeX"], _
    ["blitzbasic", "BlitzBasic"], _
    ["bnf", "BNF"], _
    ["boo", "Boo"], _
    ["c", "C"], _
    ["c_mac", "C for Macs"], _
    ["caddcl", "CADDCL"], _
    ["cadlisp", "CADLisp"], _
    ["cfdg", "CFDG"], _
    ["cfm", "ColdFusion"], _
    ["cil", "CIL"], _
    ["cmake", "CMake"], _
    ["cobol", "COBOL"], _
    ["cpp-qt", "C++ (with QT extensions)"], _
    ["cpp", "C++"], _
    ["csharp", "C#"], _
    ["css", "CSS"], _
    ["d", "D"], _
    ["dcs", "DCS"], _
    ["delphi", "Delphi"], _
    ["diff", "Diff-output"], _
    ["div", "DIV"], _
    ["dos", "DOS"], _
    ["dot", "dot"], _
    ["eiffel", "Eiffel"], _
    ["email", "E-mail (mbox\eml\RFC format)"], _
    ["erlang", "Erlang"], _
    ["fo", "FO"], _
    ["fortran", "Fortran"], _
    ["freebasic", "FreeBasic"], _
    ["genero", "Genero"], _
    ["gettext", "GNU Gettext .po/.pot"], _
    ["glsl", "glSlang"], _
    ["gml", "GML"], _
    ["gnuplot", "GNUPlot"], _
    ["groovy", "Groovy"], _
    ["haskell", "Haskell"], _
    ["hq9plus", "HQ9+"], _
    ["html4strict", "HTML 4.01 strict"], _
    ["idl", "Unoidl"], _
    ["ini", "INI"], _
    ["inno", "Inno Script"], _
    ["intercal", "INTERCAL"], _
    ["io", "IO"], _
    ["java", "Java"], _
    ["java5", "Java 5"], _
    ["javascript", "JavaScript"], _
    ["kixtart", "KiXtart"], _
    ["klonec", "KLone with C"], _
    ["klonecpp", "KLone with C++"], _
    ["latex", "LaTeX"], _
    ["lisp", "Generic Lisp"], _
    ["locobasic", "Locomotive Basic"], _
    ["lolcode", "LOLcode"], _
    ["lotusformulas", "@Formula/@Command"], _
    ["lotusscript", "LotusScript"], _
    ["lscript", "Lightwave Script"], _
    ["lsl2", "Linden Script"], _
    ["lua", "LUA"], _
    ["m68k", "Motorola 68000 Assembler"], _
    ["make", "GNU make"], _
    ["matlab", "Matlab"], _
    ["mirc", "mIRC"], _
    ["modula3", "Modula-3"], _
    ["mpasm", "Microchip Assembler"], _
    ["mxml", "MXML"], _
    ["mysql", "MySQL"], _
    ["nsis", "NSIS"], _
    ["oberon2", "Oberon-2"], _
    ["objc", "Objective-C"], _
    ["ocaml-brief", "Objective Caml"], _
    ["oobas", "OOo Basic"], _
    ["oracle11", "Oracle 11i"], _
    ["oracle8", "Oracle 8"], _
    ["pascal", "Pascal"], _
    ["per", "Per (forms)"], _
    ["perl", "Perl"], _
    ["php-brief", "PHP (Brief version)"], _
    ["php", "PHP"], _
    ["pic16", "PIC16 Assembler"], _
    ["pixelbender", "Pixel Bender"], _
    ["text", "Plain text"], _
    ["plsql", "Oracle 9.2 PL/SQL"], _
    ["povray", "Povray"], _
    ["powershell", "PowerShell"], _
    ["progress", "Progress"], _
    ["prolog", "Prolog"], _
    ["properties", "Property"], _
    ["providex", "ProvideX"], _
    ["python", "Python"], _
    ["qbasic", "QuickBASIC"], _
    ["rails", "Ruby on Rails"], _
    ["rebol", "Rebol"], _
    ["reg", "Microsoft REGEDIT"], _
    ["robots", "Robots.txt"], _
    ["ruby", "Ruby"], _
    ["sas", "SAS"], _
    ["scala", "Scala"], _
    ["scheme", "Scheme"], _
    ["scilab", "SciLab"], _
    ["sdlbasic", "sdlBasic"], _
    ["smalltalk", "Smalltalk"], _
    ["smarty", "Smarty"], _
    ["sql", "SQL"], _
    ["tcl", "TCL"], _
    ["teraterm", "Tera Term Macro"], _
    ["thinbasic", "thinBasic"], _
    ["tsql", "T-SQL"], _
    ["typoscript", "TypoScript"], _
    ["vb", "Visual Basic"], _
    ["vbnet", "Visual Basic .NET"], _
    ["verilog", "Verilog"], _
    ["vhdl", "VHDL"], _
    ["vim", "Vim"], _
    ["visualfoxpro", "Visual FoxPro"], _
    ["visualprolog", "Visual Prolog"], _
    ["whitespace", "Whitespace"], _
    ["whois", "WHOIS (RPSL format)"], _
    ["winbatch", "WinBatch"], _
    ["xml", "XML"], _
    ["xorg_conf", "xorg.conf"], _
    ["xpp", "Axapta/Dynamics Ax X++"], _
    ["z80", "ZiLOG Z80 Assembler"]]

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

    Global $aExpiration[3][2] = [["d", "1 Tag"], _
    ["m", "1 Monat"], _
    ["f", "Nie"]]
    #endregion

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

    #region write/read .ini
    If Not FileExists($settings) Then
    IniWrite($settings, "main", "syntax", "autoit")
    IniWrite($settings, "main", "expiration", "f")
    EndIf
    $syntax = _FindInArray($aSyntax, IniRead($settings, "main", "syntax", "autoit"), 1)
    $expiration = _FindInArray($aExpiration, IniRead($settings, "main", "expiration", "f"), 1)
    #endregion write/read .ini

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

    #region gui
    $gui = GUICreate("Send To aPaste", 445, 145, -1, -1)

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

    GUICtrlCreateGroup("Send", 8, 8, 161, 130)
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    $rFile = GUICtrlCreateRadio("complete file", 24, 32, 113, 17)
    $rSelected = GUICtrlCreateRadio("selected code", 24, 56, 113, 17)
    $bSend = GUICtrlCreateButton("send", 50, 92, 75, 25, $WS_GROUP)
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    GUICtrlCreateGroup("", -99, -99, 1, 1)

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

    GUICtrlCreateGroup("Settings", 176, 8, 262, 130)
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    GUICtrlCreateLabel("Syntax highlighting:", 184, 36, 95, 17)
    GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
    $cSyntax = GUICtrlCreateCombo($syntax, 288, 32, 145, 25)
    GUICtrlCreateLabel("Post expiration:", 184, 60, 76, 17)
    GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
    $cExpiration = GUICtrlCreateCombo($expiration, 288, 56, 145, 25)
    GUICtrlCreateLabel("Name / Title: ", 184, 110, 83, 17)
    GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
    $iName = GUICtrlCreateInput("", 288, 104, 145, 25)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    #endregion gui

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

    #region events
    GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
    GUICtrlSetOnEvent($bSend, "_send")
    #endregion events
    GUISetState()
    #region set data
    If $cmdline[0] < 1 Then
    MsgBox(64, "Error", "missing parameter")
    Exit
    EndIf
    If $cmdline[2] <> "" Then
    GUICtrlSetState($rSelected, $Gui_CHECKED)
    Else
    GUICtrlSetState($rFile, $Gui_CHECKED)
    GUICtrlSetState($rSelected, $GUI_DISABLE)
    EndIf
    For $i = 0 To UBound($aSyntax) - 1
    GUICtrlSetData($cSyntax, $aSyntax[$i][1], $syntax)
    Next
    For $i = 0 To UBound($aExpiration) - 1
    GUICtrlSetData($cExpiration, $aExpiration[$i][1], $expiration)
    Next
    #endregion set data

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

    While 1
    Sleep(100)
    WEnd

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

    Func _FindInArray($array, $value, $switch)
    $index = _ArraySearch($array, $value)
    If $index = -1 Then Return -1

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

    If $switch = 0 Then
    $result = $array[$index][0]
    ElseIf $switch = 1 Then
    $result = $array[$index][1]
    Else
    SetError(1, 0, False)
    EndIf
    Return $result
    EndFunc ;==>_FindInArray

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

    Func _URIEncode($sData)
    ; Prog@ndy
    Local $aData = StringSplit(BinaryToString(StringToBinary($sData, 4), 1), "")
    Local $nChar
    $sData = ""
    For $i = 1 To $aData[0]
    $nChar = Asc($aData[$i])
    Switch $nChar
    Case 45, 46, 48 - 57, 65 To 90, 95, 97 To 122, 126
    $sData &= $aData[$i]
    Case 32
    $sData &= "+"
    Case Else
    $sData &= "%" & Hex($nChar, 2)
    EndSwitch
    Next
    Return $sData
    EndFunc ;==>_URIEncode

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

    Func _send()
    Local $bPostAsGuest, $LoginKey
    Local Static $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
    GUISetState(@SW_DISABLE, $gui)
    If BitAND(GUICtrlRead($rFile), $Gui_CHECKED) = $Gui_CHECKED Then
    $open = FileOpen($cmdline[1], 0)
    $paste_code = _URIEncode(FileRead($open))
    FileClose($open)
    ElseIf BitAND(GUICtrlRead($rSelected), $Gui_CHECKED) = $Gui_CHECKED Then
    $paste_code = _URIEncode($cmdline[2])
    EndIf
    $paste_name = GUICtrlRead($iName)
    $paste_expire_date = _FindInArray($aExpiration, GUICtrlRead($cExpiration), 0)
    $paste_format = _FindInArray($aSyntax, GUICtrlRead($cSyntax), 0)
    $paste_devkey = "52b07d8a33022af5c03f899c734818c8"

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

    ;Login
    $oHTTP.Open("POST", "http://apaste.square7.ch/index.php", False)
    $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)")
    $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")

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

    $oHTTP.Send("?form=editor&paste=Submit&poster=" & $paste_name & "&format=" & $paste_format & "&expiry=" & $paste_expire_date & "&code2=" & $paste_code)

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

    $oReceived = $oHTTP.ResponseText
    If $oReceived <> "" Then
    $aResult = StringRegExp($oReceived, '<div id="topInfo"><h1>.*?<br/><a href="(.*?)" title="Download this paste">', 1, 1)
    $sLink = StringReplace($aResult[0], "?dl=", "")
    $gui2 = GUICreate("url", 258, 76, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
    $Input = GUICtrlCreateInput($sLink, 8, 8, 241, 21)
    $Button1 = GUICtrlCreateButton("copy to clipboard", 24, 40, 115, 25, $WS_GROUP)
    GUICtrlSetOnEvent(-1, "_clipput")
    $Button2 = GUICtrlCreateButton("open url", 152, 40, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent(-1, "_execute")
    GUISetState(@SW_SHOW)
    Else
    MsgBox(64, "Error", "no response")
    EndIf
    EndFunc ;==>_send

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

    Func _execute()
    ShellExecute($sLink)
    EndFunc ;==>_execute

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

    Func _clipput()
    If ClipPut($sLink) Then
    _exit()
    Else
    MsgBox(64, "Error", "unable to copy url to clipboard")
    EndIf
    EndFunc ;==>_clipput

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

    Func _exit()
    If $cmdline[0] < 1 Then Return
    IniWrite($settings, "main", "syntax", _FindInArray($aSyntax, GUICtrlRead($cSyntax), 0))
    IniWrite($settings, "main", "expiration", _FindInArray($aExpiration, GUICtrlRead($cExpiration), 0))
    Exit
    EndFunc ;==>_exit

    [/autoit] [autoit][/autoit] [autoit][/autoit]
    &quot;SciTE -&gt; Options -&gt; Open User Options File - am Ende einfügen
    Code
    # 41 SendToaPaste
    command.41.*="$(autoit3dir)\autoit3.exe" "$(SciteDefaultHome)\aPaste\apaste.au3" "$(FilePath)" "$(CurrentSelection)"
    command.name.41.*=Send to aPaste
    command.shortcut.41.*=Ctrl+Shift+Alt+A
  • Ja da war i2c wohl schneller. :D
    (Dabei hatte ich gehofft, das wenigstens bis Samstag niemand auf dieselbe Idee kommt.)

    Ich wollt zwar auch mal was nützliches zum Forum beitragen, aber was solls.
    (Vielleicht kann ich mein Skript irgendwo brauchen, waren < 5 Stunden Arbeit dank der verkackten _IE... - Funktionen =\ )

    Jedenfalls, tolles Skript ;)

    Mfg

    There's a joke that C has the speed and efficieny of assembly language combined with readability of....assembly language. In other words, it's just a glorified assembly language. - Teh Interwebz

    C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, you blow off your whole leg. - Bjarne Stroustrup
    Genie zu sein, bedeutet für mich, alles zu tun, was ich will. - Klaus Kinski

  • Ich werde mal mein Script auf die neue API einstellen und hier posten falls jemand eine Alternative zu i2c's Variante möchte :)

    Mfg

    There's a joke that C has the speed and efficieny of assembly language combined with readability of....assembly language. In other words, it's just a glorified assembly language. - Teh Interwebz

    C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, you blow off your whole leg. - Bjarne Stroustrup
    Genie zu sein, bedeutet für mich, alles zu tun, was ich will. - Klaus Kinski

  • So,
    wie gesagt, hier ist meine Variante :D

    \AutoIt3\SciTE\aPaste\apaste.au3 speichern
    [autoit]

    #cs
    Send to aPaste
    aPaste by minx @ autoit.de
    http://apaste.square7.ch/

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

    Creator: PainTain @ autoit.de
    Idea from i2c's "Send to Pastebin"
    #ce

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

    #include <ComboConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Array.au3>
    #include <EditConstants.au3>

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

    HotKeySet("{ESC}", "_ExitFadeOff")

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

    Local $asEntites[6] = ["","","","","",""]

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

    $hGUI = GUICreate("Send to aPaste", 660, 202, 192, 125)
    GUICtrlCreateLabel("ID", -100, -100, 4, 4)
    GUICtrlCreateGroup("To Send", 16, 8, 185, 185)
    $idRadioCurSciTE = GUICtrlCreateRadio("Current SciTE Source", 32, 32, 145, 25)
    GUICtrlSetState(-1, $GUI_CHECKED)
    $idRadioOwnText = GUICtrlCreateRadio("Other text:", 32, 120, 129, 25)
    $idBtnPasteText = GUICtrlCreateButton("Paste some text :)", 32, 152, 155, 25)
    $idRadioCurSel = GUICtrlCreateRadio("Current Selection", 32, 80, 113, 17)
    GUICtrlSetState($idBtnPasteText, $GUI_DISABLE)
    GUICtrlCreateGroup("Settings", 224, 8, 337, 185)
    GUICtrlCreateLabel("Syntax:", 240, 64, 42, 17)
    $idComboSyntax = GUICtrlCreateCombo("AutoIt", 355, 64, 185, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE))
    GUICtrlSetData(-1, "BASH|C|C++|CSS|HTML 4.01 strict|Java|JavaScript|mIRC|Perl|PHP|Plain text|Python|Ruby on Rails|Ruby|SQL|TCL|XML|xorg.conf|----------------------------|ABAP|ActionScript|ActionScript 3|Ada|Apache|AppleScript|Apt sources.list|ASM|ASP|AutoIt|AviSynth|BASH|Basic4GL|Brainfuck|BibTex|BlitzBasic|BNF|Boo|C|C for Macs|CADDCL|CADLisp|CFDG|ColdFusion|CIL|CMake|COBOL|C++ (with QT extensions)|C++|C#|CSS|D|DCS|Delphi|Diff-output|DIV|DOS|dot|Eiffel||Erlang|Fo|Fortran|FreeBasic|Genero|GNU Gettext .po/.pot|glSlang|GML|GNUPlot|Groovy|Haskell|HQ9+|HTML 4.01 strict|Unoidl|INI|InnoScript|INTERCAL|IO|Java|Java 5|JavaScript|KiXtart|KLone with C|KLone with C++|LaTex|Generic Lisp|Locomotive Basic|LOLcode|@Formula/@Command|LotusScript|Lightwave Script|Linden Script|LUA|Motorola 68000 Assembler|GNU make|Matlab|mIRC|Modula-3|Microchip Assembler|MXML|MySQL|NSIS|Oberon-2|Objective-C|Objective Caml|OOo Basic|Oracle 11i|Oracle 8|Pascal||PErl||PHP|PIC16 Assembler|Pixel Bender|Plain text|Oracle 9.2 PL/SQL|Povray|PowerShell|Progress|Prolog|Property|ProvideX|Python|QuickBASIC|Ruby on Rails|Rebol|Microsoft REGEDIT|Robots.txt|Ruby|SAS|Scala|Scheme|SciLab|sdlBasic|Smalltalk|Smarty|SQL|TCL|Tera Term Macro|thinBasic|T-SQL|TypoScript|Visual Basic|Visual Basic .NET|Verilog|VHDL|Vim|Visual FoxPro|Visual Prolog|Whitespace|WinBatch|XML|xorg.conf|Axapta/Dynamics Ax X++|ZiLOG Z80 Assembler")
    GUICtrlCreateLabel("Title:", 240, 96, 63, 17)
    $idInputTitle = GUICtrlCreateInput("", 355, 96, 185, 21)
    GUICtrlCreateLabel("Paste expiration:", 240, 128, 85, 17)
    $idInputPasteExpiration = GUICtrlCreateInput("", 355, 128, 185, 25, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_NUMBER))
    GUICtrlCreateLabel(" Private?", 236, 164, 63, 17)
    $idComboPrivate = GUICtrlCreateCombo("No", 356, 161, 185, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE))
    GUICtrlSetData(-1, "Yes")
    GUICtrlCreateLabel("Author Name:", 240, 32, 69, 17)
    $idInputAuthorName = GUICtrlCreateInput("", 356, 30, 185, 21)
    $idBtnSend = GUICtrlCreateButton("Send!", 584, 16, 59, 169)

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

    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)

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

    While 1
    Switch GUIGetMsg()
    Case (Execute("1,60200 * 10^(-23)") - 4) ;)
    _ExitFadeOff()
    Case $idRadioOwnText
    GUICtrlSetState($idBtnPasteText, $GUI_ENABLE)
    Case $idBtnPasteText
    $asEntites[0] = _OwnText_GUI()
    Case $idBtnSend
    If BitAND(GUICtrlRead($idRadioOwnText), $GUI_CHECKED) And $asEntites[0] = "" Then
    MsgBox(16, "Send to aPaste", "Text cannot be empty!")
    Exit ;// Eventuell schönere Lösung
    ElseIf BitAND(GUICtrlRead($idRadioCurSciTE), $GUI_CHECKED) Then
    $asEntites[0] = FileRead($CmdLine[1])
    ElseIf BitAND(GUICtrlRead($idRadioCurSel), $GUI_CHECKED) Then
    $asEntites[0] = $CmdLine[2]
    EndIf
    $asEntites[1] = GUICtrlRead($idComboSyntax)
    $asEntites[2] = GUICtrlRead($idInputTitle)
    $asEntites[3] = GUICtrlRead($idInputPasteExpiration)
    $asEntites[4] = GUICtrlRead($idComboPrivate)
    $asEntites[5] = GUICtrlRead($idInputAuthorName)
    ;~ _ArrayDisplay($asEntites)
    _SendPaste($asEntites)
    _ExitFadeOff()
    EndSwitch
    WEnd

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

    Func _OwnText_GUI()
    $hGUI_OwnText = GUICreate("Send to aPaste ", 618, 385, 192, 124, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
    $idEdit_OwnText_Text = GUICtrlCreateEdit("", 0, 0, 617, 337)
    $idBtn_OwnText_Ok = GUICtrlCreateButton("OK!", 8, 344, 291, 33)
    $idBtn_OwnText_Cancel = GUICtrlCreateButton("Cancel", 320, 344, 291, 33)
    GUISetState(@SW_SHOW)

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

    While 1
    Switch GUIGetMsg()
    Case -3
    GUIDelete($hGUI_OwnText)
    Return
    Case $idBtn_OwnText_Cancel
    GUIDelete($hGUI_OwnText)
    Return
    Case $idBtn_OwnText_Ok
    $sReturn = GUICtrlRead($idEdit_OwnText_Text)
    GUIDelete($hGUI_OwnText)
    Return $sReturn
    EndSwitch
    WEnd
    EndFunc

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

    Func _ExitFadeOff() ; Kleine Spielerei :D
    For $i = 255 To 0 Step -10
    WinSetTrans("Send to aPaste", "ID", $i)
    Sleep(15)
    Next
    Exit
    EndFunc

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

    Func _SendPaste(ByRef $asData) ;// 0 = Text, 1 = Syntax, 2 = Title, 3 = Expiration, 4 = Password, 5 = Name
    If $asData[4] = "No" Then
    $asData[4] = 0
    Else
    $asData[4] = 1
    EndIf

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

    $asData[1] = _Syntax($asData[1])

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

    $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
    $oHTTP.Open("POST", "http://apaste.square7.ch/index.php/api/create", False)
    $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")

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

    $oHTTP.Send("text=" & $asData[0] & "&title=" & $asData[2] & "&name=" & $asData[5] & "&private=" & $asData[4] & "&expire=" & $asData[3] & "&lang=" & $asData[1])

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

    $sLink = $oHTTP.ResponseText
    $asLinkSplitted = StringSplit($sLink, "/")
    _URLDisplay("http://apaste.square7.ch/index.php/view/" & $asLinkSplitted[$asLinkSplitted[0]])
    Return
    EndFunc

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

    Func _Syntax($sFullSyntaxName)
    Local $asSyntax[158][2] = [["autoit", "AutoIt"], _ ;Array made by i2c
    ["bash", "BASH"], _
    ["c", "C"], _
    ["cpp", "C++"], _
    ["css", "CSS"], _
    ["html4strict", "HTML 4.01 strict"], _
    ["java", "Java"], _
    ["javascript", "JavaScript"], _
    ["mirc", "mIRC"], _
    ["perl", "Perl"], _
    ["php", "PHP"], _
    ["text", "Plain text"], _
    ["python", "Python"], _
    ["rails", "Ruby on Rails"], _
    ["ruby", "Ruby"], _
    ["sql", "SQL"], _
    ["tcl", "TCL"], _
    ["whois", "WHOIS (RPSL format)"], _
    ["xml", "XML"], _
    ["xorg_conf", "xorg.conf"], _
    ["text", "Plain Text"], _
    ["abap", "ABAP"], _
    ["actionscript", "ActionScript"], _
    ["actionscript3", "ActionScript 3"], _
    ["ada", "Ada"], _
    ["apache", "Apache"], _
    ["applescript", "AppleScript"], _
    ["apt_sources", "Apt sources.list"], _
    ["asm", "ASM"], _
    ["asp", "ASP"], _
    ["autoit", "AutoIt"], _
    ["avisynth", "AviSynth"], _
    ["bash", "BASH"], _
    ["basic4gl", "Basic4GL"], _
    ["bf", "Brainfuck"], _
    ["bibtex", "BibTeX"], _
    ["blitzbasic", "BlitzBasic"], _
    ["bnf", "BNF"], _
    ["boo", "Boo"], _
    ["c", "C"], _
    ["c_mac", "C for Macs"], _
    ["caddcl", "CADDCL"], _
    ["cadlisp", "CADLisp"], _
    ["cfdg", "CFDG"], _
    ["cfm", "ColdFusion"], _
    ["cil", "CIL"], _
    ["cmake", "CMake"], _
    ["cobol", "COBOL"], _
    ["cpp-qt", "C++ (with QT extensions)"], _
    ["cpp", "C++"], _
    ["csharp", "C#"], _
    ["css", "CSS"], _
    ["d", "D"], _
    ["dcs", "DCS"], _
    ["delphi", "Delphi"], _
    ["diff", "Diff-output"], _
    ["div", "DIV"], _
    ["dos", "DOS"], _
    ["dot", "dot"], _
    ["eiffel", "Eiffel"], _
    ["email", "E-mail (mbox\eml\RFC format)"], _
    ["erlang", "Erlang"], _
    ["fo", "FO"], _
    ["fortran", "Fortran"], _
    ["freebasic", "FreeBasic"], _
    ["genero", "Genero"], _
    ["gettext", "GNU Gettext .po/.pot"], _
    ["glsl", "glSlang"], _
    ["gml", "GML"], _
    ["gnuplot", "GNUPlot"], _
    ["groovy", "Groovy"], _
    ["haskell", "Haskell"], _
    ["hq9plus", "HQ9+"], _
    ["html4strict", "HTML 4.01 strict"], _
    ["idl", "Unoidl"], _
    ["ini", "INI"], _
    ["inno", "Inno Script"], _
    ["intercal", "INTERCAL"], _
    ["io", "IO"], _
    ["java", "Java"], _
    ["java5", "Java 5"], _
    ["javascript", "JavaScript"], _
    ["kixtart", "KiXtart"], _
    ["klonec", "KLone with C"], _
    ["klonecpp", "KLone with C++"], _
    ["latex", "LaTeX"], _
    ["lisp", "Generic Lisp"], _
    ["locobasic", "Locomotive Basic"], _
    ["lolcode", "LOLcode"], _
    ["lotusformulas", "@Formula/@Command"], _
    ["lotusscript", "LotusScript"], _
    ["lscript", "Lightwave Script"], _
    ["lsl2", "Linden Script"], _
    ["lua", "LUA"], _
    ["m68k", "Motorola 68000 Assembler"], _
    ["make", "GNU make"], _
    ["matlab", "Matlab"], _
    ["mirc", "mIRC"], _
    ["modula3", "Modula-3"], _
    ["mpasm", "Microchip Assembler"], _
    ["mxml", "MXML"], _
    ["mysql", "MySQL"], _
    ["nsis", "NSIS"], _
    ["oberon2", "Oberon-2"], _
    ["objc", "Objective-C"], _
    ["ocaml-brief", "Objective Caml"], _
    ["oobas", "OOo Basic"], _
    ["oracle11", "Oracle 11i"], _
    ["oracle8", "Oracle 8"], _
    ["pascal", "Pascal"], _
    ["per", "Per (forms)"], _
    ["perl", "Perl"], _
    ["php-brief", "PHP (Brief version)"], _
    ["php", "PHP"], _
    ["pic16", "PIC16 Assembler"], _
    ["pixelbender", "Pixel Bender"], _
    ["text", "Plain text"], _
    ["plsql", "Oracle 9.2 PL/SQL"], _
    ["povray", "Povray"], _
    ["powershell", "PowerShell"], _
    ["progress", "Progress"], _
    ["prolog", "Prolog"], _
    ["properties", "Property"], _
    ["providex", "ProvideX"], _
    ["python", "Python"], _
    ["qbasic", "QuickBASIC"], _
    ["rails", "Ruby on Rails"], _
    ["rebol", "Rebol"], _
    ["reg", "Microsoft REGEDIT"], _
    ["robots", "Robots.txt"], _
    ["ruby", "Ruby"], _
    ["sas", "SAS"], _
    ["scala", "Scala"], _
    ["scheme", "Scheme"], _
    ["scilab", "SciLab"], _
    ["sdlbasic", "sdlBasic"], _
    ["smalltalk", "Smalltalk"], _
    ["smarty", "Smarty"], _
    ["sql", "SQL"], _
    ["tcl", "TCL"], _
    ["teraterm", "Tera Term Macro"], _
    ["thinbasic", "thinBasic"], _
    ["tsql", "T-SQL"], _
    ["typoscript", "TypoScript"], _
    ["vb", "Visual Basic"], _
    ["vbnet", "Visual Basic .NET"], _
    ["verilog", "Verilog"], _
    ["vhdl", "VHDL"], _
    ["vim", "Vim"], _
    ["visualfoxpro", "Visual FoxPro"], _
    ["visualprolog", "Visual Prolog"], _
    ["whitespace", "Whitespace"], _
    ["whois", "WHOIS (RPSL format)"], _
    ["winbatch", "WinBatch"], _
    ["xml", "XML"], _
    ["xorg_conf", "xorg.conf"], _
    ["xpp", "Axapta/Dynamics Ax X++"], _
    ["z80", "ZiLOG Z80 Assembler"]]

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

    If $sFullSyntaxName = "----------------------------" Then $sFullSyntaxName = "Plain text"
    $iIndex = _ArraySearch($asSyntax, $sFullSyntaxName)
    Return $asSyntax[$iIndex][1]
    EndFunc

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

    Func _URLDisplay($sLink)
    $hGUI_URL = GUICreate("Send To aPaste", 404, 153, 192, 124)
    $idURL = GUICtrlCreateInput($sLink, 16, 16, 369, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY))
    $idBtnCopy = GUICtrlCreateButton("Copy to Clipboard", 16, 56, 171, 33)
    $idBtnDownload = GUICtrlCreateButton("Download Paste", 216, 56, 171, 33)
    $idBtnOpen = GUICtrlCreateButton("Open in Browser", 16, 104, 371, 33)

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

    GUISetState(@SW_SHOW, $hGUI_URL)

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

    While 1
    Switch GUIGetMsg()
    Case -3
    Return
    Case $idBtnCopy
    ClipPut($sLink)
    Case $idBtnDownload
    $asLinkSplitted = StringSplit($sLink, "/")
    $sText = BinaryToString(InetRead("http://apaste.square7.ch/index.php/view/raw/" & $asLinkSplitted[$asLinkSplitted[0]]))
    $sPath = FileSaveDialog("Save Paste", "::{450D8FBA-AD25-11D0-98A8-0800361B1103}", "Alle (*.*)|Textdateien (*.txt)", 16)
    FileWrite($sPath & ".txt", $sText)
    Case $idBtnOpen
    ShellExecute($sLink)
    EndSwitch
    WEnd
    EndFunc

    [/autoit]


    (Bei Expiration ist die Zeit in Minuten anzugeben, für das Speichern für immer muss ich noch minx fragen wegen der API ;))

    SciTE --&gt; Options --&gt; &quot;Open User Options File&quot; (Am Ende einfügen)
    Code
    # 42 Send To aPaste by PainTain
    command.42.*="$(autoit3dir)\AutoIt3.exe" "$(SciteDefaultHome)\aPaste\apaste.au3" "$(FilePath)" "$(CurrentSelection)"
    command.name.42.*=Send to aPaste
    command.shortcut.42.*=Ctrl+Shift+Alt+Y


    Funktioniert mit der neuen aPaste-API :)

    Hoffe es gefällt euch :D
    (Auf Wunsch baue ich auch das Speichern der Einstellungwen in einer INI wie bei i2c's Variante :))

    Mfg

    There's a joke that C has the speed and efficieny of assembly language combined with readability of....assembly language. In other words, it's just a glorified assembly language. - Teh Interwebz

    C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, you blow off your whole leg. - Bjarne Stroustrup
    Genie zu sein, bedeutet für mich, alles zu tun, was ich will. - Klaus Kinski

    2 Mal editiert, zuletzt von PainTain (13. Februar 2013 um 21:30)