Hallo!
Endlich ist mein neustes AutoIt-Projekt fertig: Linkout
Zitat
Linkout lädt für Dich jede beliebige Bilddatei von deinem Computer ins Internet, wahlweise auf einen FTP-Server, oder einen kostenlosen Image-Hoster deiner Wahl.Des weiteren kannst du mit Linkout auch direkt Bildschirmfotos (sog. Screenshots), Daten aus der Zwischenablage, Bilder deiner Webcam oder Dateien aus dem Internet auswählen - Linkout konvertiert sie, und lädt diese mit nur einem einzigen Klick ins Internet, damit du sie z.B. über Messenger verschicken, oder in Foren und Communities mit einem einfachen Link zeigen kannst.
Download
http://www.linkout.de/
Screenshots
[Blockierte Grafik: http://pennywise.e-ee.de/Webcam/linkout_20110116_184814193.jpg]
Source
Spoiler anzeigen
#cs
Linkout v1.0.0
programmed by Daniel Jäger
linkout.de
#ce
; Includes (Constants)
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
#include <WindowsConstants.au3>
#include <WebcamConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstants.au3>
#include <Constants.au3>
; Includes (Functions)
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
#include <ScreenCapture.au3>
#include <ClipBoard.au3>
#include <GDIPlus.au3>
#include <String.au3>
#include <FTPEx.au3>
#include <Misc.au3>
; Globals
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
Global Const $app_name = "Linkout"
Global Const $app_version = "1.0.0"
Global $window
Global $windowb = False
Global $webcam_timer = -1
[/autoit] [autoit][/autoit] [autoit]Global $dll_avi
Global $dll_user
Global $cap
Global $w = 800
Global $h = 600
Global $ws = 800
Global $hs = $ws / (@DesktopWidth / @DesktopHeight)
; Initialisation & HotKeys & Options
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
AutoItSetOption("TrayMenuMode", 1)
[/autoit] [autoit][/autoit] [autoit]HotKeySet("{PRINTSCREEN}", "File_Snapshot")
HotKeySet("!{PRINTSCREEN}", "File_SnapshotWin")
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]; GUI (Webcam)
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
$gui_webcam = GUICreate($app_name & " - (Quelle: Webcam)", $w, $h / 2 + 70)
[/autoit] [autoit][/autoit] [autoit]$button_webcam_snap = GUICtrlCreateButton("Foto aufnehmen", 0, $h / 2, $w / 4, 50)
$button_webcam_wait = GUICtrlCreateButton("Selbstauslöser", $w / 4, $h / 2, $w / 4, 50, $BS_MULTILINE)
$button_webcam_upload = GUICtrlCreateButton("Hochladen", $w / 2, $h / 2, $w / 2, 50)
Global $webcam_preview
Webcam_ResetPreview()
$w_quelle = GUICtrlCreateMenu("Linkout")
$w_quelle_webcam = GUICtrlCreateMenuItem("Webcam", $w_quelle)
GUICtrlSetState(-1, $GUI_DISABLE)
$w_quelle_file = GUICtrlCreateMenuItem("Datei", $w_quelle)
GUICtrlCreateMenuItem("", $w_quelle)
$w_exit = GUICtrlCreateMenuItem("Beenden", $w_quelle)
$w_settings = GUICtrlCreateMenu("Einstellungen")
$w_settings_timer = GUICtrlCreateMenuItem("Selbstauslöser...", $w_settings)
$w_settings_auf = GUICtrlCreateMenuItem("Webcam-Auflösung...", $w_settings)
$w_settings_cam = GUICtrlCreateMenuItem("Webcam-Einstellungen...", $w_settings)
GUICtrlCreateMenuItem("", $w_settings)
$w_settings_upload = GUICtrlCreateMenu("Upload-Methode", $w_settings)
$w_settings_upload_ftp = GUICtrlCreateMenuItem("FTP-Server", $w_settings_upload, 0, True)
GUICheck("webcam", "upload", "ftp")
$w_settings_upload_imageshack = GUICtrlCreateMenuItem("ImageShack.us", $w_settings_upload, 1, True)
GUICheck("webcam", "upload", "imageshack")
$w_settings_link = GUICtrlCreateMenu("Link-Ausgabe", $w_settings)
$w_settings_link_text = GUICtrlCreateMenuItem("Normaler Text", $w_settings_link, 0, True)
GUICheck("webcam", "link", "plain")
$w_settings_link_bb = GUICtrlCreateMenuItem("BB-Code", $w_settings_link, 1, True)
GUICheck("webcam", "link", "bb")
$w_settings_link_html = GUICtrlCreateMenuItem("HTML-Code", $w_settings_link, 2, True)
GUICheck("webcam", "link", "html")
GUICtrlCreateMenuItem("", $w_settings)
$w_settings_ftp = GUICtrlCreateMenuItem("FTP-Einstellungen...", $w_settings)
$w_help = GUICtrlCreateMenu("Hilfe")
$w_help_about = GUICtrlCreateMenuItem("Über "&$app_name, $w_help)
; GUI (File)
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
$gui_file = GUICreate($app_name & " - (Quellen: Dateien, Screenshots)", $ws, $hs + 70, -1, -1, Default, $WS_EX_ACCEPTFILES)
[/autoit] [autoit][/autoit] [autoit]$button_file_select = GUICtrlCreateButton("Lokale Datei auswählen...", 0, $hs, $ws / 5, 50)
$button_file_load = GUICtrlCreateButton("Von Link downloaden...", $ws / 5, $hs, $ws / 5, 50)
$button_file_clip = GUICtrlCreateButton("Aus Zwischenablage (Strg+V)", ($ws / 5) * 2, $hs, $ws / 5, 50)
$button_file_edit = GUICtrlCreateButton("Bild bearbeiten", ($ws / 5) * 3, $hs, $ws / 5, 50)
$button_file_upload = GUICtrlCreateButton("Hochladen", ($ws / 5) * 4, $hs, $ws / 5, 50)
Global $dropper = GUICtrlCreateLabel("", 0, 0, $ws, $hs)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetState(-1, $GUI_DISABLE)
Global $file_preview
File_ResetPreview()
$f_quelle = GUICtrlCreateMenu("Linkout")
$f_quelle_webcam = GUICtrlCreateMenuItem("Webcam", $f_quelle)
$f_quelle_file = GUICtrlCreateMenuItem("Datei", $f_quelle)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateMenuItem("", $f_quelle)
$f_exit = GUICtrlCreateMenuItem("Beenden", $f_quelle)
$f_settings = GUICtrlCreateMenu("Einstellungen")
$f_settings_image = GUICtrlCreateMenuItem("Screenshot-Qualität...", $f_settings)
GUICtrlCreateMenuItem("", $f_settings)
$f_settings_upload = GUICtrlCreateMenu("Upload-Methode", $f_settings)
$f_settings_upload_ftp = GUICtrlCreateMenuItem("FTP-Server", $f_settings_upload, 0, True)
GUICheck("file", "upload", "ftp")
$f_settings_upload_imageshack = GUICtrlCreateMenuItem("ImageShack.us", $f_settings_upload, 1, True)
GUICheck("file", "upload", "imageshack")
$f_settings_link = GUICtrlCreateMenu("Link-Ausgabe", $f_settings)
$f_settings_link_text = GUICtrlCreateMenuItem("Normaler Text", $f_settings_link, 0, True)
GUICheck("file", "link", "plain")
$f_settings_link_bb = GUICtrlCreateMenuItem("BB-Code", $f_settings_link, 1, True)
GUICheck("file", "link", "bb")
$f_settings_link_html = GUICtrlCreateMenuItem("HTML-Code", $f_settings_link, 2, True)
GUICheck("file", "link", "html")
GUICtrlCreateMenuItem("", $f_settings)
$f_settings_ftp = GUICtrlCreateMenuItem("FTP-Einstellungen...", $f_settings)
$f_help = GUICtrlCreateMenu("Hilfe")
$f_help_about = GUICtrlCreateMenuItem("Über "&$app_name, $f_help)
; GUI (FTP-Settings)
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
$gui_ftp = GUICreate("FTP-Einstellungen", 310, 195)
[/autoit] [autoit][/autoit] [autoit]GUICtrlCreateLabel("Host:", 10, 13)
$input_ftp_host = GUICtrlCreateInput("", 80, 10, 140)
GUICtrlCreateLabel("Port:", 225, 13)
$input_ftp_port = GUICtrlCreateInput("", 252, 10, 28, -1, $ES_NUMBER)
GUICtrlCreateLabel("Username:", 10, 43)
$input_ftp_user = GUICtrlCreateInput("", 80, 40, 200)
GUICtrlCreateLabel("Passwort:", 10, 73)
$input_ftp_pass = GUICtrlCreateInput("", 80, 70, 200, -1, $ES_PASSWORD)
GUICtrlCreateLabel("Pfad:", 10, 103)
$input_ftp_path = GUICtrlCreateInput("", 80, 100, 200)
$button_ftp_path = GUICtrlCreateButton("?", 285, 100, 20, 22)
GUICtrlCreateLabel("Adresse:", 10, 133)
$input_ftp_link = GUICtrlCreateInput("", 80, 130, 200)
$button_ftp_link = GUICtrlCreateButton("?", 285, 130, 20, 22)
$button_ftp_save = GUICtrlCreateButton("Speichern", 80, 160, 98)
$button_ftp_abort = GUICtrlCreateButton("Abbrechen", 184, 160, 98)
; GUI (Screenshot-Quality)
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
$gui_image = GUICreate("Screenshot-Qualität", 310, 110)
[/autoit] [autoit][/autoit] [autoit]GUICtrlCreateLabel("Screenshot-Qualität: (höhere Qualität = größere Dateien)", 10, 13)
$slider_image = GUICtrlCreateSlider(10, 35, 290, 30)
$button_image_save = GUICtrlCreateButton("Speichern", 100, 75, 98)
$button_image_abort = GUICtrlCreateButton("Abbrechen", 202, 75, 98)
; GUI (Selfshot-Timer)
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
$gui_timer = GUICreate("Selbstauslöser", 250, 80)
[/autoit] [autoit][/autoit] [autoit]GUICtrlCreateLabel("Selbstauslöser:", 10, 13)
$input_timer = GUICtrlCreateInput("5", 90, 10, 50, -1, $ES_NUMBER)
$stepper_image = GUICtrlCreateUpdown($input_timer)
GUICtrlCreateLabel("Sekunden", 150, 13)
$button_timer_save = GUICtrlCreateButton("Speichern", 20, 45, 100)
$button_timer_abort = GUICtrlCreateButton("Abbrechen", 125, 45, 100)
; Main-Loop
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
GUIGetCurrentWindow()
[/autoit] [autoit][/autoit] [autoit]While 1
Switch GUIGetMsg()
Case $w_help_about, $f_help_about
getInfo($app_name&" v"&$app_version&@CRLF&"programmiert von Daniel Jäger - w3-media.org")
Case $f_quelle_webcam
setConfig("main", "quelle", "webcam")
GUIChangeWindow($gui_webcam)
Case $w_quelle_file
setConfig("main", "quelle", "file")
GUIChangeWindow($gui_file)
Case $w_settings_cam
DllCall($dll_user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DLG_VIDEOSOURCE, "int", 0, "int", 0)
Case $w_settings_auf
DllCall($dll_user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DLG_VIDEOFORMAT, "int", 0, "int", 0)
Case $w_settings_ftp, $f_settings_ftp
Upload_FTP_LoadSettings()
GUIShowSettings($gui_ftp)
Case $button_ftp_save
Upload_FTP_SaveSettings()
GUIHideSettings($gui_ftp)
Case $button_ftp_abort
GUIHideSettings($gui_ftp)
Case $f_settings_image
GUICtrlSetData($slider_image, getConfig("file", "quality"))
GUIShowSettings($gui_image)
Case $button_image_save
setConfig("file", "quality", GUICtrlRead($slider_image))
GUIHideSettings($gui_image)
Case $button_image_abort
GUIHideSettings($gui_image)
Case $w_settings_timer
GUICtrlSetData($input_timer, getConfig("webcam", "timer"))
GUIShowSettings($gui_timer)
Case $button_timer_save
setConfig("webcam", "timer", GUICtrlRead($input_timer))
GUIHideSettings($gui_timer)
Case $button_timer_abort
GUIHideSettings($gui_timer)
Case $button_ftp_path
getInfo("Der Pfad zum Speicherort der hochgeladenen Bilder, getrennt durch Slashs."&@CRLF&"Zum Beispiel: html/bilder/linkout")
Case $button_ftp_link
getInfo("Der Link zum Speicherort der Bilder."&@CRLF&"Zum Beispiel: http://mein.server.de/bilder/linkout/")
Case $button_webcam_snap
Webcam_Snapshot()
Case $button_webcam_wait
If (GUICtrlRead($button_webcam_wait) = "Selbstauslöser") Then
$webcam_timer = getConfig("webcam", "timer")
GUISetTimerButton($webcam_timer)
$realtimer = TimerInit()
Else
$webcam_timer = -1
GUICtrlSetData($button_webcam_wait, "Selbstauslöser")
EndIf
Case $button_webcam_upload
GUICtrlSetState($button_webcam_upload, $GUI_DISABLE)
Webcam_Upload()
GUICtrlSetState($button_webcam_upload, $GUI_ENABLE)
Case $button_file_select
File_Select()
Case $button_file_load
File_Load()
Case $button_file_clip
File_Clip()
Case $button_file_upload
GUICtrlSetState($button_file_upload, $GUI_DISABLE)
File_Upload()
GUICtrlSetState($button_file_upload, $GUI_ENABLE)
Case $button_file_edit
File_Edit()
Case $f_settings_upload_ftp
setConfig("file", "upload", "ftp")
Case $f_settings_upload_imageshack
setConfig("file", "upload", "imageshack")
Case $f_settings_link_bb
setConfig("file", "link", "bb")
Case $f_settings_link_html
setConfig("file", "link", "html")
Case $f_settings_link_text
setConfig("file", "link", "plain")
Case $w_settings_link_bb
setConfig("webcam", "link", "bb")
Case $w_settings_link_html
setConfig("webcam", "link", "html")
Case $w_settings_link_text
setConfig("webcam", "link", "plain")
Case $w_settings_upload_ftp
setConfig("webcam", "upload", "ftp")
Case $w_settings_upload_imageshack
setConfig("webcam", "upload", "imageshack")
Case $GUI_EVENT_DROPPED
File_Dropped()
Case $GUI_EVENT_CLOSE, $w_exit, $f_exit
If ($windowb = $gui_ftp) Then
GUIHideSettings($gui_ftp)
ElseIf ($windowb = $gui_image) Then
GUIHideSettings($gui_image)
Else
GUISetState(@SW_DISABLE, $window)
Webcam_Close()
_GDIPlus_Shutdown()
Exit
EndIf
EndSwitch
If ($window = $gui_file And _IsPressed("11") And _IsPressed("56")) Then
While _IsPressed("11") And _IsPressed("56")
wend
File_Clip()
EndIf
If ($webcam_timer <> -1) Then
If (TimerDiff($realtimer) >= 1000) Then
$webcam_timer -= 1
$realtimer = TimerInit()
GUISetTimerButton($webcam_timer)
EndIf
If ($webcam_timer = 0) Then
Webcam_Snapshot()
$webcam_timer = -1
EndIf
EndIf
WEnd
; Webcam-Functions
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
Func Webcam_Init()
$dll_avi = DllOpen("avicap32.dll")
$dll_user = DllOpen("user32.dll")
$cap = DllCall($dll_avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD, $WS_VISIBLE), "int", 0, "int", 0, "int", $w / 2, "int", $h / 2, "hwnd", $gui_webcam, "int", 1)
DllCall($dll_user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0)
DllCall($dll_user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0)
DllCall($dll_user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0)
DllCall($dll_user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0)
DllCall($dll_user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0)
EndFunc
Func Webcam_Close()
If ($window = $gui_webcam) Then
DllCall($dll_user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_END, "int", 0, "int", 0)
DllCall($dll_user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0)
DllClose($dll_user)
EndIf
EndFunc
Func Webcam_Snapshot()
$filename = @ScriptDir & "/data/webcam.bmp"
DllCall($dll_user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0)
DllCall($dll_user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $filename)
Webcam_ResetPreview()
EndFunc
Func Webcam_Upload()
$newname = getFilename()
$bitmap = _GDIPlus_BitmapCreateFromFile("data/webcam.bmp")
_GDIPlus_ImageSaveToFile($bitmap, "data/uploads/"&$newname)
_GDIPlus_BitmapDispose($bitmap)
Upload_Complete(Upload_Method("data/uploads/"&$newname, getConfig("webcam", "upload")), getConfig("webcam", "link"))
EndFunc
Func Webcam_ResetPreview()
GUICtrlDelete($webcam_preview)
$webcam_preview = GUICtrlCreatePic("data/webcam.bmp", $w / 2, 0, $w / 2, $h / 2)
EndFunc
; File-Functions
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
Func File_Edit()
GUICtrlDelete($file_preview)
GUICtrlCreateLabel("Bild wird bearbeitet...", $ws/2-30, $hs/2-35)
GUISetState(@SW_DISABLE)
RunWait("mspaint.exe temp.jpg", @ScriptDir & "/data")
GUISetState(@SW_ENABLE)
WinActivate($app_name)
File_ResetPreview()
EndFunc
Func File_Dropped()
$drop = _GDIPlus_ImageLoadFromFile(@GUI_DragFile)
_GDIPlus_ImageSaveToFile($drop, "data/temp.jpg")
_GDIPlus_ImageDispose($drop)
File_ResetPreview()
EndFunc
Func File_Select()
$dialog = FileOpenDialog($app_name, @DesktopDir, "Bilder (*.jpg;*.png;*.gif;*.bmp;*.jpeg)", 3)
If (@error) Then
Return
EndIf
$sel = _GDIPlus_ImageLoadFromFile($dialog)
_GDIPlus_ImageSaveToFile($sel, @ScriptDir & "/data/temp.jpg")
_GDIPlus_ImageDispose($sel)
File_ResetPreview()
EndFunc
Func File_Load()
$url = InputBox($app_name, "Bitte eine URL eingeben:", "", "", 300, 125)
If (@error) Then
Return
EndIf
$download = InetGet($url, "data/temp.tmp", 0, 1)
$size = InetGetSize($url)
getProgress(False)
Do
ProgressSet(InetGetInfo($download, 0) / $size * 100)
Sleep(250)
Until InetGetInfo($download, 2)
ProgressOff()
$tmp = _GDIPlus_ImageLoadFromFile("data/temp.tmp")
_GDIPlus_ImageSaveToFile($tmp, "data/temp.jpg")
_GDIPlus_ImageDispose($tmp)
File_ResetPreview()
EndFunc
Func File_Snapshot()
If ($window <> $gui_file) Then
Return
EndIf
_ScreenCapture_SetJPGQuality(getConfig("file", "quality"))
_ScreenCapture_Capture(@ScriptDir&"\data\temp.jpg", 0, 0, -1, -1, False)
File_TakeScreen()
EndFunc
Func File_SnapshotWin()
If ($window <> $gui_file) Then
Return
EndIf
$list = WinList()
_ScreenCapture_SetJPGQuality(getConfig("file", "quality"))
_ScreenCapture_CaptureWnd(@ScriptDir&"\data\temp.jpg", WinGetHandle("[ACTIVE]"), 0, 0, -1, -1, False)
File_TakeScreen()
EndFunc
Func File_TakeScreen()
File_ResetPreview()
If (Not WinActive($app_name)) Then
getTray("Screenshot wurde erstellt.")
EndIf
EndFunc
Func File_Clip()
$clip = ClipGet()
If (@error = 2) Then
_ClipBoard_GetData(8)
$data = "0x424d000000000000000036000000" & StringTrimLeft(_ClipBoard_GetData(8), 2)
$fhandle = FileOpen("data/temp.tmp", 18)
FileWrite($fhandle, $data)
FileClose($fhandle)
$bitmap = _GDIPlus_ImageLoadFromFile("data/temp.tmp")
_GDIPlus_ImageSaveToFile($bitmap, "data/temp.jpg")
_GDIPlus_ImageDispose($bitmap)
Else
If (Not FileExists($clip)) Then
Return
Else
$clipfile = _GDIPlus_ImageLoadFromFile($clip)
_GDIPlus_ImageSaveToFile($clipfile, "data/temp.jpg")
_GDIPlus_ImageDispose($clipfile)
EndIf
EndIf
File_ResetPreview()
EndFunc
Func File_ResetPreview()
$newfile = @ScriptDir&"\data\temp.jpg"
$new = _GDIPlus_ImageLoadFromFile($newfile)
$width = _GDIPlus_ImageGetWidth($new)
$height = _GDIPlus_ImageGetHeight($new)
_GDIPlus_ImageDispose($new)
If ($width > $ws Or $height > $hs) Then
$faktor_w = 100 / $width * $ws / 100
$faktor_h = 100 / $height * $hs / 100
If ($faktor_w < $faktor_h) Then
$faktor = $faktor_w
Else
$faktor = $faktor_h
EndIf
$nwidth = $width * $faktor
$nheight = $height * $faktor
Else
$nwidth = $width
$nheight = $height
EndIf
$left = ($ws - $nwidth) / 2
$top = ($hs - $nheight) / 2
GUICtrlDelete($file_preview)
$file_preview = GUICtrlCreatePic($newfile, $left, $top, $nwidth, $nheight)
GUICtrlSetData($dropper, "")
EndFunc
Func File_Upload()
$newname = getFilename()
FileCopy(@ScriptDir & "\data\temp.jpg", "data/uploads/"&$newname)
Upload_Complete(Upload_Method("data/uploads/"&$newname, getConfig("file", "upload")), getConfig("file", "link"))
EndFunc
; Upload-Functions
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
Func Upload_Method($file, $method)
Switch $method
Case "imageshack"
Return Upload_Imageshack($file)
Case "ftp"
Return Upload_FTP($file)
EndSwitch
EndFunc
Func Upload_Imageshack($file)
$curl = Run("data/curl.exe --form fileupload=@"&$file&" imageshack.us/upload_api.php", @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
getProgress()
Do
$line = StderrRead($curl)
If ($line <> "") Then
$s = StringSplit($line, " ", 2)
If (UBound($s) > 1) Then
ProgressSet($s[1])
EndIf
EndIf
Until @error
ProgressOff()
$line = StdoutRead($curl)
$str = _StringBetween($line, "<image_link>", "</image_link>")
Return $str[0]
EndFunc
Func Upload_FTP($file)
$con = _FTP_Open("Linkout_"&Random(1000, 9999, 1))
$ftp = _FTP_Connect($con, getConfig("ftp", "host"), getConfig("ftp", "user"), _StringEncrypt(0, getConfig("ftp", "pass"), "r!6+Gv?3Hb.a-2Uk="))
If (@error) Then
getError("Ein Fehler bei der FTP-Verbindung wurde festgestellt.")
Return False
EndIf
$path = StringSplit(getConfig("ftp", "path"), "/")
$link = getConfig("ftp", "link")
For $i = 1 To $path[0]
_FTP_DirSetCurrent($ftp, $path[$i])
Next
$filename = StringSplit($file, "/")
If (FileGetSize($file) < 150 * 1024) Then
_FTP_FilePut($ftp, $file, $filename[$filename[0]])
Else
getProgress()
_FTP_ProgressUpload($ftp, $file, $filename[$filename[0]], "Upload_FTP_Progress")
ProgressOff()
EndIf
_FTP_Close($con)
Return $link&$filename[$filename[0]]
EndFunc
Func Upload_FTP_Progress($percent)
ProgressSet($percent)
Return 1
EndFunc
Func Upload_Complete($filename, $tags)
If ($filename = False) Then
Return
EndIf
Switch $tags
Case "html"
$code = '<img src="'&$filename&'" alt="" />'
Case "bb"
$code = ''
Case "plain"
$code = $filename
EndSwitch
getTray("Das Bild wurde erfolgreich hochgeladen, und der Link in die Zwischenablage kopiert.")
ClipPut($code)
EndFunc
; FTP-Setting-Functions
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
Func Upload_FTP_SaveSettings()
$data_pass = _StringEncrypt(1, GUICtrlRead($input_ftp_pass), "r!6+Gv?3Hb.a-2Uk=")
$data_path = GUICtrlRead($input_ftp_path)
$data_link = GUICtrlRead($input_ftp_link)
If (StringRight($data_link, 1) <> "/") Then
$data_link &= "/"
EndIf
If (StringLeft($data_path, 1) = "/") Then
$data_path = StringTrimLeft($data_path, 1)
EndIf
If (StringRight($data_path, 1) = "/") Then
$data_path = StringTrimRight($data_path, 1)
EndIf
setConfig("ftp", "host", GUICtrlRead($input_ftp_host))
setConfig("ftp", "port", GUICtrlRead($input_ftp_port))
setConfig("ftp", "user", GUICtrlRead($input_ftp_user))
setConfig("ftp", "link", $data_link)
setConfig("ftp", "path", $data_path)
setConfig("ftp", "pass", $data_pass)
EndFunc
Func Upload_FTP_LoadSettings()
GUICtrlSetData($input_ftp_host, getConfig("ftp", "host"))
GUICtrlSetData($input_ftp_link, getConfig("ftp", "link"))
GUICtrlSetData($input_ftp_path, getConfig("ftp", "path"))
GUICtrlSetData($input_ftp_port, getConfig("ftp", "port"))
GUICtrlSetData($input_ftp_user, getConfig("ftp", "user"))
GUICtrlSetData($input_ftp_pass, "********")
EndFunc
; GUI-Functions
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
Func GUISetTimerButton($secs)
If ($secs <> 0) Then
$word = "Sekunde"
If ($secs <> 1) Then
$word &= "n"
EndIf
GUICtrlSetData($button_webcam_wait, $webcam_timer & " " & $word & @CRLF & "(Abbrechen)")
Else
GUICtrlSetData($button_webcam_wait, "Selbstauslöser")
EndIf
EndFunc
Func GUICheck($section, $name, $value)
If (getConfig($section, $name) = $value) Then
GUICtrlSetState(-1, $GUI_CHECKED)
EndIf
EndFunc
Func GUIHideSettings($hide)
GUISetState(@SW_ENABLE, $window)
GUISetState(@SW_HIDE, $hide)
$windowb = False
GUISwitch($window)
EndFunc
Func GUIShowSettings($show)
$windowb = $show
GUISetState(@SW_DISABLE, $window)
GUISetState(@SW_SHOW, $show)
EndFunc
Func GUIChangeWindow($new)
If ($new = $gui_webcam) Then
Webcam_Init()
Else
Webcam_Close()
EndIf
GUISetState(@SW_HIDE, $window)
$window = $new
GUISetState(@SW_SHOW, $window)
EndFunc
Func GUIGetCurrentWindow()
If (getConfig("main", "quelle") = "file") Then
GUIChangeWindow($gui_file)
Else
GUIChangeWindow($gui_webcam)
EndIf
EndFunc
; Notification-Functions
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
Func getError($text)
MsgBox(16+8192, $app_name, $text)
EndFunc
Func getInfo($text)
MsgBox(64+8192, $app_name, $text)
EndFunc
Func getTray($text)
TrayTip($app_name, $text, 3)
EndFunc
; Misc-Functions
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
Func getProgress($up = True)
If ($up) Then
$m = "Bild wird hochgeladen."
Else
$m = "Bild wird runtergeladen."
EndIf
ProgressOn($app_name, "", $m)
EndFunc
Func getConfig($section, $key)
Return IniRead("data/config.ini", $section, $key, "")
EndFunc
Func setConfig($section, $key, $value)
IniWrite("data/config.ini", $section, $key, $value)
EndFunc
Func getFilename()
Return "linkout_"&@YEAR&@MON&@MDAY&"_"&@HOUR&@MIN&@SEC&@MSEC&".jpg"
EndFunc