Code : Tout sélectionner
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#region ### START Koda GUI section ### Form=
Global $radiobox = "rien", $text, $pswd, $post, $sServerURL = 'http://beetxt.com/insert.php', $URL, $aURL
$Form1 = GUICreate("Beetxt3", 420, 88, 192, 124)
$Label1 = GUICtrlCreateLabel("Texte :", 16, 8, 40, 17)
$Label2 = GUICtrlCreateLabel("Mot de passe :", 16, 32, 77, 17)
$Edit1 = GUICtrlCreateEdit("", 120, 8, 185, 73)
GUICtrlSetData(-1, "")
$Radio1 = GUICtrlCreateRadio("Supprimer", 312, 8, 81, 17)
$Radio2 = GUICtrlCreateRadio("Ne pas supprimer", 312, 32, 105, 17)
$Button1 = GUICtrlCreateButton("Go", 312, 56, 99, 25)
$Input1 = GUICtrlCreateInput("", 8, 56, 97, 21)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
If $radiobox == "rien" Then
MsgBox(16, "Beetxt3", "Vous avez oublié de cocher l'option ""Supprimer"" ou ""Ne pas supprimer""")
Else
$text = GUICtrlRead($Edit1)
If $text = "" Then
MsgBox(16, "Beetxt3", "Vous avez oublié de mettre un texte")
Else
$pswd = GUICtrlRead($Input1)
If $pswd = "" Then
$post = "text=" & $text & "&password=&delete_indicate=" & $radiobox
Else
$post = "text=" & $text & "&password=" & $pswd & "&delete_indicate=" & $radiobox
EndIf
$URL = HttpPost($sServerURL, $post)
;~ ClipPut($URL)
If StringInStr($URL, "<strong>Oops!</strong> Invalid form.</p>") Then
MsgBox(16, "Beetxt3", "Erreur :( Réessayez encore")
Else
Beetxt3GUI()
EndIf
EndIf
EndIf
Case $Radio1
$radiobox = 1
Case $Radio2
$radiobox = 0
EndSwitch
WEnd
Func Beetxt3GUI()
Opt("GUIOnEventMode", 1)
$aURL = _StringBetween($URL, "<a href='", "'>")
If Not IsArray($aURL) Then Exit MsgBox(16, "Beetxt3", "Réessayez encore :(")
$Form2 = GUICreate("Résultats de Beetxt3", 402, 69, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Label1_1 = GUICtrlCreateLabel("URL : ", 8, 8, 35, 17)
GUICtrlCreateInput($aURL[0], 56, 8, 281, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY))
$Button1_1 = GUICtrlCreateButton("Copier", 344, 8, 51, 25)
GUICtrlSetOnEvent($Button1_1, "Button1Click")
$Label2_1 = GUICtrlCreateLabel("URL éditable", 8, 40, 66, 17)
$Input1_1 = GUICtrlCreateInput("", 80, 40, 257, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY))
If UBound($aURL) = 2 Then
GUICtrlSetData($Input1_1, $aURL[1])
$Button2_1 = GUICtrlCreateButton("Copier", 344, 40, 51, 25)
GUICtrlSetOnEvent(-1, "Button2Click")
Else
GUICtrlSetData($Input1_1, "Non disponible")
EndIf
GUISetState(@SW_SHOW)
EndFunc ;==>Beetxt3GUI
Func Button1Click()
ClipPut($aURL[0])
MsgBox(64, "Beetxt3", "Copié ;)")
EndFunc ;==>Button1Click
Func Button2Click()
ClipPut($aURL[1])
MsgBox(64, "Beetxt3", "Copié ;)")
EndFunc ;==>Button2Click
Func Form1Close()
Exit
EndFunc ;==>Form1Close
Func HttpPost($sURL, $sData)
Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHTTP.Open("POST", $sURL, False)
If (@error) Then Return SetError(1, 0, 0)
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oHTTP.Send($sData)
If (@error) Then Return SetError(2, 0, 0)
If ($oHTTP.Status <> 200) Then Return SetError(3, 0, 0)
Return SetError(0, 0, $oHTTP.ResponseText)
EndFunc ;==>HttpPost