Jump to content
wakillon

TinyPicSharer v 1.0.3.4 New Version 08 June 2013

Recommended Posts

wakillon

TinyPicSharer :

20130608142234.png

A simple and handy tool for capture window or picture by mouse grab and an uploader for 10 Pic Hosters !

You can also Resize, Convert, Optimize, add WaterMark to your images easily.

(optimization with jpegtran.exeoptipng.exegifsicle.exe command line tools)

In plus it can extract images from Docs (pdf, doc, docx, odt, odp, ppt, pptx, pps, ppsx)

(Doc extraction with b2xtranslator and pdfextract.exe command line tools)

Just Drag'n drop a picture/doc on the Host Logo for load it.

I have replaced Curl by WinHttp functions and TrIDLib.DLL by my own FileGetType function.

 

20130608145543.jpg

 

Previous downloads : 1343

Update of 8 June 2013

source and executable are available in the Download Section

See Tray menu for options.

Double click on his tray icon for restore the gui.

 

>zlib.au3, WinHttp.au3>WinAPIEx UDF are needed. ( Thanks to Ward, trancexx, Yashield )

Hope you 'll find it usefull ! :king:

Edited by wakillon
  • Like 2

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
pierrotm777

Thanks for this share !

Very cool job

Share this post


Link to post
Share on other sites
wakillon

Thanks for this share !

Very cool job

Thanks pierrotm777 ! :graduated:

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
Ju2fruits

Very good program, easy to use. Thanks Wakillon :)

edited : ok, drag and drop option, very cool, but maybe you could add possibility to choose file with mini hard drive explorer ? and eventually add more websites as imageshack ?

Edited by Ju2fruits

Share this post


Link to post
Share on other sites
wakillon

Very good program, easy to use. Thanks Wakillon :)

edited : ok, drag and drop option, very cool, but maybe you could add possibility to choose file with mini hard drive explorer ? and eventually add more websites as imageshack ?

Thanks Ju2fruits ! Posted Image

Choosing file with explorer is less easy that a quick drag and drop !

I wanted an image uploader based on simplicity for quickly get the uploaded file url,

so add more websites is not in my intentions and Imageshack is also very reliable !

Search on the forum, you'll find others image uploaders with more websites...Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
andygo

Very good program, easy to use. Thanks Wakillon :)

edited : ok, drag and drop option, very cool, but maybe you could add possibility to choose file with mini hard drive explorer ? and eventually add more websites as imageshack ?

with this tool, you can choose between 6 different hosters:

#RequireAdmin
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <ComboConstants.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <Timers.au3>
#Include <Misc.au3>
#include <Constants.au3>
#Include <ScreenCapture.au3>
#include <GDIPlus.au3>
#include <file.au3>
#include <IE.au3>
Break(0)
Opt("TrayAutoPause",0)
Opt("WinTitleMatchMode", 2)
FileInstall("dvbs-de.lng", @TempDir & "\dvbs-de.lng", 1)
FileInstall("dvbs-en.lng", @TempDir & "\dvbs-en.lng", 1)
$language = "deutsch"
if StringInStr("0409 0809 0c09 1009 1409 1809 1c09 2009 2409 2809 2c09 3009 3409", @OSLang) then
    $language = "english"
endif
Dim $interface
_FileReadToArray(@TempDir & "\dvbs-"&StringLeft($language, 2)&".lng",$interface)
SplashTextOn("LiveSnap", @CRLF & $interface[1], 250, 80)
FileInstall("curl.exe", @TempDir & "\curl.exe", 1)
$datei2 = @TempDir & "\09876.jpg"
Opt ("TrayIconHide", 1)
Opt("GuiOnEventMode", 1)
Global $s_right, $s_down, $newcurl, $waiting, $chars, $show, $ip, $i, $opt4, $Height2, $GUI_2, $s_left, $s_top, $s_width, $s_height, $Width2, $opt3, $fill
$maingui = GuiCreate("LiveSnap compact", 305, 135)
GUISetbkColor(0xe0e0e0)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$snip = GuiCtrlCreateButton("", 38, 4, 80, 20)
GUICtrlSetData($snip, "Desktop")
GUICtrlSetOnEvent($snip, "_snip")
$shack = GuiCtrlCreateButton("", 38, 30, 80, 20)
GUICtrlSetData($shack, $interface[9])
GUICtrlSetOnEvent($shack, "_shack")
$c09 = GuiCtrlCreateLabel($interface[29], 217, 116, 90, 14, $SS_CENTER);bereit anzeige
GUICtrlSetColor(-1, 0x008000)
$c08 = GUICtrlCreatelabel ("", 3, 115, 213, 17, $SS_CENTER);url anzeige
GUICtrlSetOnEvent(-1, "_directurl")
$c210 = GUICtrlCreatelabel ("", 154, 2, 149, 3)
GUICtrlSetBkColor(-1, 0x34a2ef)
$c211 = GUICtrlCreatelabel ("", 154, 85, 149, 3)
GUICtrlSetBkColor(-1, 0x34a2ef)
$c212 = GUICtrlCreatelabel ("", 154, 5, 3, 81)
GUICtrlSetBkColor(-1, 0x34a2ef)
$c213 = GUICtrlCreatelabel ("", 300, 5, 3, 81)
GUICtrlSetBkColor(-1, 0x34a2ef)
$oIEp = _IECreateEmbedded ()
$c21 = GUICtrlCreateObj($oIEp, 157, 5, 143, 80)
$oIEp.navigate("about:blank")
repic("empty", 144, 81, 1)
$c23 = GuiCtrlCreateinput("", 55, 60, 30, 17, $ES_NUMBER)
GUICtrlSetLimit (-1, 4)
GUICtrlSetTip ( $c23, $interface[192])
$c24 = GUICtrlCreateCombo ($interface[34], 125, 90, 176, 17, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1,"[img]URL[/img]|HTML")
$cl2 = GUICtrlCreateCombo ("abload.de", 2, 90, 120, 10, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1,"imagebanana.com|imageshack.us|img-teufel.de|directupload.net|pic-upload.de")
$dialog = @WindowsDir & "\"
SplashOff()
GuiSetState(@sw_show, $maingui)
$hi = WinGetHandle ("[ACTIVE]")
func repic($rp, $rp1, $rp2, $rp3)
    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile($rp)
    $Width = _GDIPlus_ImageGetWidth($hImage)
    $Height = _GDIPlus_ImageGetHeight($hImage)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()
    $i = $rp1
    $xa = $Width / $rp1
    $tip = ""
    if $Width <> $rp1 and $Height <> $rp2 then $tip = $Width&" * "&$Height&" Pixel"
    while $Height / $xa > $rp2
        $i -= 1
        $xa = $Width / $i
    wend
    $Width2 = $Width
    $Height2 = $Height
    if $Width > $rp1 or $Height > $rp2 then
        $Width2 = int($Width / $xa)
        $Height2 = int($Height / $xa)
    endif
    if $rp2 = 99999 Then
        $width2 = $rp1
        $height2 = int(($rp1/$width)*$height)
    Else
        $Width3 = 0
        $Height3 = 0
        if int(($rp1 - $Width2) / 2) > 1 then $Width3 = int(($rp1 - $Width2) / 2)
        if int(($rp2 - $Height2) / 2) > 1 then $Height3 = int(($rp2 - $Height2) / 2)
        if $rp = "empty" then
            $fill = ""
        Else
            $fill = "<img src =" & $rp & " width="&$Width2&" height="&$Height2&" alt='"&$tip&"'>"
        endif
        if $rp3 = 1 then $oIEp.document.write("<body oncontextmenu='return false' scroll='no' style='border:0;margin-top:"&$Height3&"px; margin-left:"&$Width3&"px;background-color:6479b0'>"&$fill&"</body>")
        $oIEp.refresh
    endif
endfunc
While 1
sleep(20)

If stringinstr (GUICtrlRead($snip), "Cancel") > 0 Then
    GUICtrlSetData($snip, "Desktop")
    if $waiting = 0 Then
        _dis()
        WinSetState ($hi, "", @SW_ENABLE  )
        _area($snip, "Cancel")
        GUIDelete($GUI_2)
        $timestamp = @MDAY & "." & @MON & "." & @YEAR & "--" & @HOUR & "-" & @MIN & "-" & @SEC
        $time2 = StringReplace (StringReplace ($timestamp, "--", "  "), "-", ":")
        if $s_width > 5 and $s_height > 5 then
            $hBitmap = _ScreenCapture_Capture($datei2, $s_left, $s_top, $s_right, $s_down, false)
            repic($datei2, 144, 81, 1)
        endif
        GUICtrlSetState ($snip, $GUI_ENABLE)
        If FileExists($datei2) Then
            _wmark()
            _d2()
            If FileExists (@TempDir & "\curl.txt") Then
                _load()
            else
                _lableer()
            endif
        Else
            _lableer()
        EndIf
        GUICtrlSetColor($c09, 0x008000)
        GUICtrlSetData ($c09, $interface[29])
        _en()
        $waiting = 0
        WinActivate ($hi, $interface[29])
    EndIf
    GUICtrlSetData($snip, "Desktop")
endif

If stringinstr (GUICtrlRead($shack), "Cancel") > 0 Then
    if $waiting = 0 Then
        $typ = "..jpg"
        $fehler = 0
        _dis()
        $datei4pre = FileOpenDialog("Browse...", $dialog, "Images (*.jpg;*.png;*.gif;*.bmp;*.tif)", 1 + 2 + 4)
        $4c2 = StringLeft ($datei4pre, stringinstr ($datei4pre, "|") - 1) & "\"
        $datei4pre = StringTrimLeft ($datei4pre, stringinstr ($datei4pre, "|"))
        $datei4 = $4c2 & $datei4pre
        if stringleft ($datei4, 1) = "\" then $datei4 = stringtrimleft ($datei4, 1)
        GUICtrlSetData($shack, "Cancel")
        $dialog = StringLeft($datei4, StringInStr ($datei4, "\", 0, -1))
        $typ4 = StringRight ($datei4, 3)
        $4log = $datei4
        If @error Then
            $fehler = 0
        elseif $typ4 <> "bmp" AND $typ4 <> "tif" AND $typ4 <> "jpg" AND $typ4 <> "png" AND $typ4 <> "gif" AND $typ4 <> "" then
            MsgBox(16,$interface[18], $interface[68])
            $fehler=1
        elseif StringLen ($datei4) > 0 then
            GUICtrlSetData ($c08, $datei4)
            if (StringLen ($datei4) - StringInStr ($datei4, "\", 0, -1)) > 20 OR StringInStr ($datei4, " ") > 0 then
                FileCopy ($datei4, @TempDir & "\ptmp." & $typ4, 1)
                $datei4 = @TempDir & "\ptmp." & $typ4
            endif
            if StringLen (GUICtrlRead($c08)) = 0 then
                MsgBox(16,$interface[18], $interface[69])
                $datei4 = ""
                $fehler=1
            endif
        else
            $fehler=1
        EndIf
        if $fehler=0 then
            FileDelete (@TempDir & "\curl.txt")
            $timestamp = @MDAY & "." & @MON & "." & @YEAR & "--" & @HOUR & "-" & @MIN & "-" & @SEC
            $time2 = StringReplace (StringReplace ($timestamp, "--", "  "), "-", ":")
            if $typ4 = "gif" then
                $datei5 = $datei2
                $datei2 = $datei4
                _curl($datei2)
                repic($datei2, 144, 81, 1)
            else
                FileCopy ($datei4, $datei2, 1)
                repic($datei2, 144, 81, 1)
                $typ4 = "jpg"
                If FileExists($datei2) Then
                    _wmark()
                endif
            endif
            GUICtrlSetState ($shack, $GUI_ENABLE)
            If FileExists($datei2) Then
                GUICtrlSetState ($shack, $GUI_ENABLE)
                $typ = ".jpg"
                _d2()
                If FileExists (@TempDir & "\curl.txt") Then
                    _load()
                else
                    _lableer()
                endif
            endif
            if $typ4 = "gif" then
                $datei2 = $datei5
                _curl($datei2)
            endif
            GUICtrlSetColor($c09, 0x008000)
            GUICtrlSetData ($c09, $interface[29])
        else
            $dialog = @WindowsDir & "\"
            _lableer()
            WinActivate ($hi, $interface[29])
        EndIf
        $typ = StringRight ($datei2, 4)
        _en()
        $typ4 = ""
        $waiting = 0
        $4log = 0
        WinActivate ($hi, $interface[29])
    EndIf
    GUICtrlSetData($shack, $interface[9])
EndIf
WEnd

Func _Quit()
    if msgbox(68,"LiveSnap",$interface[22]) = 6 then Exit
EndFunc

Func _snip()
    _tv($snip, "Desktop")
EndFunc

Func _shack()
    _tv($shack, $interface[9])
EndFunc

Func _tv($tv1, $tv2)
    Switch GUICtrlRead($tv1)
        Case $tv2
            $ip = 0
            if $tv1 = $snip or $tv1 = $shack then
                if int(guictrlread($c23)) > 2500 then msgbox(16,$interface[18], $interface[79])
                if int(guictrlread($c23)) <= 2500 and $waiting = 0 Then GUICtrlSetData($tv1, "Cancel")
            Else
                if $waiting = 0 Then GUICtrlSetData($tv1, "Cancel")
            endif
        Case else
            _exx()
            GUICtrlSetData($tv1, $tv2)
    EndSwitch
EndFunc

func _exx()
    $ip = -1
    $waiting = 0
    GUICtrlSetData ($c08, "")
    repic("empty", 144, 81, 1)
    FileDelete (@TempDir & "\curl.txt")
    GUICtrlSetData ($c09, $interface[86])
    _en()
endfunc

Func _curl($curl)
    Switch $opt3
        Case "imageshack.us"
            $newcurl = '-F fileupload=@"' & $curl & '" -H Expect: -o curl.txt --location-trusted --url "http://ufo.imageshack.us/"'
        Case "abload.de"
            $newcurl = '-F img0=@"' & $curl & '" -H Expect: -o curl.txt --url "http://www.abload.de/upload.php"'
        Case "imagebanana.com"
            $newcurl = '-F upload[]=@"' & $curl & '" -F send=Hochladen! -H  Expect: -o curl.txt --location-trusted --url "http://www.imagebanana.com/"'
        Case "pic-upload.de"
            $newcurl = '-F file=@"' & $curl & '" -F Submit=" Bild Hochladen" -H Expect: -o curl.txt --url "http://www.pic-upload.de/index.php?to=upload"'
        Case "directupload.net"
            $newcurl = '-F bilddatei=@"' & $curl & '" -H Expect: -o curl.txt --url "http://www.directupload.net/index.php?mode=upload"'
        Case "img-teufel.de"
            $newcurl = '-F upload_image=@"' & $curl & '" -H Expect: -o curl.txt --url "http://www.img-teufel.de/upload.html"'
        Case Else
            Exit MsgBox(16, $interface[18], $interface[97])
    EndSwitch
EndFunc

Func _wmark()
    if int(GUICtrlRead($c23)) > 0 then
        repic($datei2, int(GUICtrlRead($c23)), 99999, 0)
        _GDIPlus_Startup()
        $hBitmap1 = _WinAPI_CreateBitmap($Width2, $Height2, 1, 32)
        $hImage = _GDIPlus_ImageLoadFromFile($datei2)
        $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)
        $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
        _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, $Width2, $Height2)
        _GDIPlus_BitmapDispose($hImage)
        _GDIPlus_ImageSaveToFile($hImage1, $datei2)
        _GDIPlus_BitmapDispose($hImage1)
        _WinAPI_DeleteObject ($hBitmap1)
        _GDIPlus_Shutdown()
    endif
    repic($datei2, 144, 81, 1)
EndFunc

Func _d2()
    $skb = round(FileGetSize ($datei2) / 1024, 2)
    local $foo = Run(FileGetShortName(@TempDir) & "\"  &  "curl.exe " & $newcurl, FileGetShortName(@TempDir) & "\" , @SW_HIDE, $STDERR_CHILD), $line
    GUICtrlSetData ($c09, "uploading...")
    While $ip = 0 and ProcessExists ( "curl.exe")
        $line = StderrRead($foo)
        $line = StringRegExp($line, '\d+', 3)
        if NOT @error then
            if $line[0] = 100 then $line[0] = 99
            GUICtrlSetData ($c09, "uploading " & $line[0] & " %")
        endif
        sleep(50)
        if $waiting = 0 then exitloop
    Wend
    Processclose ( "curl.exe")
    GUICtrlSetData ($c09, "uploading 100 %")
EndFunc

func _load()
    $file = FileOpen(@TempDir & "\" &  "\curl.txt", 0)
    $chars = FileRead($file)
    FileClose($file)
    _filter()
    if stringlen ($chars) > 100 then $chars = "Error"
    $show = $chars
    if stringinstr ($show, ".jpg") > 0 or stringinstr ($show, ".gif") > 0 then
        GUICtrlSetData($c08, $interface[195])
        if GUICtrlRead($c24) = $interface[34] then ClipPut($show & @CRLF)
        if GUICtrlRead($c24) = "HTML" then ClipPut("<img src="""&$show&""">"& @CRLF)
        if stringinstr(GUICtrlRead($c24), "[img]") > 0 then ClipPut("[img]"&$show&"[/img]"& @CRLF)
    Else
        _lableer()
    endif
EndFunc

func _dis()
    $opt3 = GUICtrlRead($cl2)
    _curl($datei2)
    FileDelete ( @TempDir & "\curl.txt" )
    FileDelete ( $datei2 )
    $waiting = 1
    For $i = $snip to $c08
        GUICtrlSetState ($i, $GUI_DISABLE)
    next
    GUICtrlSetState ($c09, $GUI_ENABLE)
    GUICtrlSetColor($c09,0xff0000)
    GUICtrlSetData ($c09, "preparing upload...")
EndFunc

func _en()
    For $i = $snip to $c08
        GUICtrlSetState ($i, $GUI_ENABLE)
    next
    GUICtrlSetData ($c09, $interface[29])
EndFunc

func _filter()
    if $opt3 = "imageshack.us" then
        $result = StringInStr($chars, "url_image_path"" value=""")
        $chars = StringTrimLeft($chars, $result + 22)
        $result = StringInStr($chars, """")
        $res2 = StringLen ($chars)
        $chars = StringTrimRight($chars, $res2 - $result + 1)
        $result = StringInStr($chars, "/")
        $res2 = StringLeft ($chars, $result -1)
        $chars = "http://" & $res2 & ".imageshack.us/" & $chars
    elseif $opt3 = "abload.de" then
        $result = StringInStr($chars, "&quot;;}}")
        $res2 = StringLen ($chars)
        $chars = StringTrimRight($chars, $res2 - $result + 1)
        while StringInStr($chars, ":&quot;") > 0
            $res2 = StringInStr($chars, ":&quot;")
            $chars = StringTrimLeft($chars, $res2 + 6)
        wend
        $chars = "http://www.abload.de/img/" & $chars
    elseif $opt3 = "imagebanana.com" then
        $result = StringInStr($chars, "][IMG]")
        $chars = StringTrimLeft($chars, $result + 5)
        $result = StringInStr($chars, "[")
        $res2 = StringLen ($chars)
        $chars = StringReplace(StringTrimRight($chars, $res2 - $result + 1), "/thumb", "")
    elseif $opt3 = "pic-upload.de" then
        $result = StringInStr($chars, "[IMG]")
        $chars = StringTrimLeft($chars, $result + 4)
        $result = StringInStr($chars, "[/IMG]")
        $res2 = StringLen ($chars)
        $chars = StringTrimRight($chars, $res2 - $result + 1)
        $chars = StringReplace ($chars, "/thumb", "")
    elseif $opt3 = "directupload.net" then
        $result = StringInStr($chars, "[URL=http://www.directupload.net][IMG]")
        $chars = StringTrimLeft($chars, $result + 37)
        $result = StringInStr($chars, "[/IMG]")
        $res2 = StringLen ($chars)
        $chars = StringTrimRight($chars, $res2 - $result + 1)
    elseif $opt3 = "img-teufel.de" then
        $result = StringInStr($chars, "[IMG]http://www.img-teufel.de/uploads/")
        $chars = StringTrimLeft($chars, $result + 4)
        $result = StringInStr($chars, "[/IMG]")
        $res2 = StringLen ($chars)
        $chars = StringTrimRight($chars, $res2 - $result + 1)
    Else
        MsgBox(16, $interface[18], $interface[113])
        Exit
    EndIf
endfunc

Func _lableer()
    GUICtrlSetColor($c09, 0x008000)
    GUICtrlSetData ($c09, $interface[29])
    ClipPut ("")
    repic("empty", 144, 81, 1)
    GUICtrlSetData($c08, "")
    $show = ""
EndFunc

Func IsVisible($handle)
    If BitAnd(WinGetState($handle), 2) Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc

Func _directurl()
    if StringInStr ($show, "http://") > 0 Then
        if GUICtrlRead($c24) = $interface[34] then ClipPut($show & @CRLF)
        if GUICtrlRead($c24) = "HTML" then ClipPut("<img src="""&$show&""">"& @CRLF)
        if stringinstr(GUICtrlRead($c24), "[img]") > 0 then ClipPut("[img]"&$show&"[/img]"& @CRLF)
        GUICtrlSetData($c08, $interface[137])
        sleep(400)
        GUICtrlSetData($c08, $interface[195])
    endif
EndFunc

func _area($a1, $a2)
    $var = WinList()
    For $i = 1 to $var[0][0]
        If $var[$i][0] <> "" AND $var[$i][0] <> "start" AND IsVisible($var[$i][1]) Then WinSetState ($var[$i][0], "", @SW_DISABLE  )
    Next
    $GUI_2 = GUICreate("", 1, 1, -1, -1, 0x80000000 + 0x00800000, 0x00000008)
    GUISetBkColor(0x0c6eec)
    WinSetTrans($GUI_2, "", 130)
    local $s_left = "", $s_top = "", $s_width = "", $s_height = "", $mgp[2]
    $mpos = MouseGetPos()
    Local $hGUI_Cross = GUICreate("", 30, 30,  $mpos[0], $mpos[1], $WS_POPUP, $WS_DISABLED + $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
    GUISetState(@SW_SHOW, $hGUI_Cross)
    WinSetTrans($hGUI_Cross, "", 1)
    GUISetCursor(3)
    $x = WinGetPos($hi)
    $y = 0
    ToolTip($interface[199] & @CRLF & $interface[200] & @CRLF & @CRLF & $interface[201], $x[0]+160, $x[1]+35)
    $ii = GUICtrlRead($a1)
    $i = _Timer_Init()
    While Not _IsPressed(01)
        if _Timer_Diff($i) > 400 then
            GUICtrlSetData($a1, "")
        endif
        if _Timer_Diff($i) > 800 then
            $i = _Timer_Init()
            GUICtrlSetData($a1, $ii)
        endif
        $mgp = MouseGetPos()
        WinMove($hGUI_Cross, "", $mgp[0] - 15, $mgp[1] - 15)
        Sleep(20)
        if $y < 61 then $y += 1
        if $y = 15 or $y = 45 then ToolTip("")
        if $y = 30 or $y = 60 then ToolTip($interface[199] & @CRLF & $interface[200] & @CRLF & @CRLF & $interface[201], $x[0]+160, $x[1]+35)
        if _IsPressed("1B") then exitloop
    WEnd
    GUICtrlSetData($a1, $a2)
    WinMove($GUI_2, "", $mgp[0], $mgp[1], 1, 1)
    GUISetState(@SW_SHOW, $GUI_2)
    if _IsPressed(01) then
        While _IsPressed(01)
            $mgp_2 = MouseGetPos()
            If $mgp_2[0] > $mgp[0] And $mgp_2[1] > $mgp[1] Then
                local $s_left = $mgp[0], $s_top = $mgp[1], $s_width = $mgp_2[0] - $mgp[0], $s_height = $mgp_2[1] - $mgp[1], $s_right = $mgp_2[0], $s_down = $mgp_2[1]
            ElseIf $mgp_2[0] > $mgp[0] And $mgp_2[1] < $mgp[1] Then
                Local $s_left = $mgp[0], $s_top = $mgp_2[1], $s_width = $mgp_2[0] - $mgp[0], $s_height = $mgp[1] - $mgp_2[1], $s_right = $mgp_2[0], $s_down = $mgp[1]
            ElseIf $mgp_2[0] < $mgp[0] And $mgp_2[1] > $mgp[1] Then
                Local $s_left = $mgp_2[0], $s_top = $mgp[1], $s_width = $mgp[0] - $mgp_2[0], $s_height = $mgp_2[1] - $mgp[1], $s_right = $mgp[0], $s_down = $mgp_2[1]
            ElseIf $mgp_2[0] < $mgp[0] And $mgp_2[1] < $mgp[1] Then
                Local $s_left = $mgp_2[0], $s_top = $mgp_2[1], $s_width = $mgp[0] - $mgp_2[0], $s_height = $mgp[1] - $mgp_2[1], $s_right = $mgp[0], $s_down = $mgp[1]
            EndIf
            WinMove($GUI_2, "", $s_left, $s_top, $s_width, $s_height)
            ToolTip($s_width & "x" & $s_height)
            sleep(5)
        WEnd
    endif
    ToolTip("")
    GUIDelete($hGUI_Cross)
    GLOBAL $s_left = $s_left, $s_top = $s_top, $s_width = $s_width, $s_height = $s_height, $s_right = $s_right, $s_down = $s_down
    $var = WinList()
    For $i = 1 to $var[0][0]
        If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then WinSetState ($var[$i][0], "", @SW_ENABLE  )
    Next
endfunc

Posted Image

langfiles.rar

Share this post


Link to post
Share on other sites
JohnOne

Any Idea why this would not work on win7 32?

well it worked the first attempt but failed on all next attempts with "An error occurred" Msgbox, indicating a link to uploaded image not present in the _PicUpload() function.

Both drag and drop and mouse capture fail. Then it worked again, then it did not :)

Is there a time limit between uploading at that website? I didnt see anything in the TOS


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
wakillon

@JohnOne

Script updated, it must be better now ! Posted Image

I'm just annoyed with window capture and aero style, and animated gifs who become static gifs on ImageShack...

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
wakillon

Indeed it is, works every time now.

And nice new additions too :)

Thanks for sharing, and thanks for the update.

Thanks

Updated with new files server.

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
wakillon

Updated.


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
Negro

Thanks for this share !

Very cool job :mellow:


[font="'Times New Roman"]Everything will be fine[/font]

Share this post


Link to post
Share on other sites
wakillon

Updated.


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
wakillon

Due to ImageShack Api changes, Script updated and cleaned.


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
Newb

won't start:

C:UsersUserDesktoprereerwewd.au3(24,10) : ERROR: can't open include file <APIConstants.au3>

#Include <APIConstants.au3>

~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(25,10) : ERROR: can't open include file <WinAPIEx.au3>

#Include <WinAPIEx.au3>

~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(67,103) : WARNING: $WS_EX_ACCEPTFILES: possibly used before declaration.

@DesktopHeight - $_GuiHeight - _GetTaskbarHeight ( )- $_StatusBarHeight - 20, -1, $WS_EX_ACCEPTFILES )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(185,70) : WARNING: $OCR_NORMAL: possibly used before declaration.

_SetCursor ( @WindowsDir & 'cursorsviseur_16885.cur', $OCR_NORMAL )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(186,72) : WARNING: $OCR_IBEAM: possibly used before declaration.

_SetCursor ( @WindowsDir & 'cursorsviseur_16885.cur', $OCR_IBEAM )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(190,63) : WARNING: $WS_POPUP: possibly used before declaration.

$_MouseGui = GUICreate ( '', 1, 1, 1, 1, BitOR ( $WS_POPUP,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(190,75) : WARNING: $WS_BORDER: possibly used before declaration.

$_MouseGui = GUICreate ( '', 1, 1, 1, 1, BitOR ( $WS_POPUP, $WS_BORDER,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(190,94) : WARNING: $WS_CLIPSIBLINGS: possibly used before declaration.

$_MouseGui = GUICreate ( '', 1, 1, 1, 1, BitOR ( $WS_POPUP, $WS_BORDER, $WS_CLIPSIBLINGS )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(190,119) : WARNING: $WS_EX_TOPMOST: possibly used before declaration.

$_MouseGui = GUICreate ( '', 1, 1, 1, 1, BitOR ( $WS_POPUP, $WS_BORDER, $WS_CLIPSIBLINGS ), BitOR ( $WS_EX_TOPMOST,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(190,139) : WARNING: $WS_EX_WINDOWEDGE: possibly used before declaration.

$_MouseGui = GUICreate ( '', 1, 1, 1, 1, BitOR ( $WS_POPUP, $WS_BORDER, $WS_CLIPSIBLINGS ), BitOR ( $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(205,79) : WARNING: $SPI_SETCURSORS: possibly used before declaration.

DllCall ( 'user32.dll', 'int', 'SystemParametersInfo', 'int', $SPI_SETCURSORS,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(212,41) : WARNING: $WM_LBUTTONDOWN: possibly used before declaration.

Case $wParam == $WM_LBUTTONDOWN And

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(218,33) : WARNING: $WM_MOUSEMOVE: possibly used before declaration.

Case $wParam == $WM_MOUSEMOVE And

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(240,33) : WARNING: $WM_LBUTTONUP: possibly used before declaration.

Case $wParam == $WM_LBUTTONUP And

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(283,51) : WARNING: $STDERR_CHILD: possibly used before declaration.

$_Pid = Run ( $_Run, '', @SW_HIDE, $STDERR_CHILD +

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(283,67) : WARNING: $STDOUT_CHILD: possibly used before declaration.

$_Pid = Run ( $_Run, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(384,81) : WARNING: $ASSOCSTR_EXECUTABLE: possibly used before declaration.

$_DefaultBrowser = _WinAPI_AssocQueryString ( '.html', $ASSOCSTR_EXECUTABLE )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(440,57) : WARNING: $RGN_DIFF: possibly used before declaration.

_WinAPI_CombineRgn ( $hREG3, $hREG1, $hREG2, $RGN_DIFF )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(453,93) : WARNING: $SRCCOPY: possibly used before declaration.

_WinAPI_BitBlt ( $CompatibleDC, 0, 0, $IMGE_W, $IMGE_H, $DC, $IMGE_L, $IMGE_T, $SRCCOPY )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(491,24) : WARNING: $TRAY_UNCHECKED: possibly used before declaration.

Case $TRAY_UNCHECKED +

~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(491,38) : WARNING: $TRAY_ENABLE: possibly used before declaration.

Case $TRAY_UNCHECKED + $TRAY_ENABLE

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(494,22) : WARNING: $TRAY_CHECKED: possibly used before declaration.

Case $TRAY_CHECKED +

~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(630,44) : WARNING: $TRAY_EVENT_PRIMARYDOUBLE: possibly used before declaration.

TraySetOnEvent ( $TRAY_EVENT_PRIMARYDOUBLE,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(67,103) : ERROR: $WS_EX_ACCEPTFILES: undeclared global variable.

@DesktopHeight - $_GuiHeight - _GetTaskbarHeight ( )- $_StatusBarHeight - 20, -1, $WS_EX_ACCEPTFILES )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3(384,81) : ERROR: _WinAPI_AssocQueryString(): undefined function.

$_DefaultBrowser = _WinAPI_AssocQueryString ( '.html', $ASSOCSTR_EXECUTABLE )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:UsersUserDesktoprereerwewd.au3 - 4 error(s), 21 warning(s)


I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Share this post


Link to post
Share on other sites
AdamSwe

Very nice, haha just made a smiliar one myself, but working with my FTP and my webserver,

Drag 'n Drop box, grab screen and printscreen,

Then it resizes the image, shows it in a gui and asks if you want it uploaded.

And after upload it gives you the link using clipput()

Share this post


Link to post
Share on other sites
wakillon

Very nice, haha just made a smiliar one myself, but working with my FTP and my webserver,

Drag 'n Drop box, grab screen and printscreen,

Then it resizes the image, shows it in a gui and asks if you want it uploaded.

And after upload it gives you the link using clipput()

Thanks ! :)

Yes something similar...

Skinsharp Skins give it a good look, but I 'm annoyed for animated gifs that ImageShack transforms to statics gifs.

May be Imgur will be added.

@Newb

WinAPIEx UDF Topic link added to the first post. ;)


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
AdamSwe

Thanks ! ;)

Yes something similar...

Skinsharp Skins give it a good look, but I 'm annoyed for animated gifs that ImageShack transforms to statics gifs.

May be Imgur will be added.

Hmm, ImageShack does resize pictures right? if so it could possibly be that reason.

So find a site that does not resize the picture, tho im guessing most sites probably do it.

Share this post


Link to post
Share on other sites
wakillon

It's not right, Imgur resize pictures too, but animated gifs < 2Mo stay animated. ;)


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • TheAutomator
      By TheAutomator
      Is there a (simple) way to make your script using a picture-control to resize the gui?
      This would be useful for a transparant pop-up window with a custom made theme using picture controls:
      $Form = GUICreate('', 301, 173, 5, 5, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUICtrlCreatePic(@scriptdir & "\resize_win.bmp", 0, 73, 20, 51) ; some api call or code telling the os to use this picture as a resize border GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) GUISetState(@SW_SHOW) While True if GUIGetMsg() = $GUI_EVENT_CLOSE then Exit WEnd  
      EDIT: to make it more clear what i wanna do, if you go with the mouse arrow over the border of a re-sizable window the arrow changes to a "resize" arrow, you click and drag the border and then the window size adjusts to the mouse position until you release the mouse button.
      I want my picture control to be used the same way as the resize border to resize my window.
    • Rex
      By Rex
      Some time ago I needed a way to uploade images to imgur, from one of my programs, and took a look at there API.
      Don't know if anyone can/would use it, but here is my code
       
      #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; #INDEX# ======================================================================================================================= ; Title .........: IMGUR Curl udf ; AutoIt Version : 1.0 ; Description ...: Uploads files to imgur using curl, and returns imgur url, deletion key, imgsize ect. in an array ; Author(s) .....: Rex ; =============================================================================================================================== #include-once #include <curl.au3> ; By Ward #include <JSON.au3> ; by Ward ; #FUNCTION# ==================================================================================================================== ; Name...........: _Imgur ; Description ...: Allows the user to uploade images to Imgur, or delete an already uploaded image using the images DeleteHash ; Syntax.........: _Imgur($AuthKey, True/False, $vData) ; Parameters ....: $AuthKey - API key from Imgur ; $bImg_Up - If true an image uploade is expected, if False a DeleteHas is expected ; $vData - The image to uploade, or the DeleteHash that was returned from Imgur at Image uploade ; Return values .: Success - An Array containing: ID, Datetime, type, animated, width, height, size, deletehash and url ; Failur - Sets @Error to 1 if no AuthKey is provided ; Failur - Sets @Error to 2 if $bImg_Up = True but no Image data is provided ; Failur - Sets @Error to 3 if $bImg_Up = True but $vData isn't Binary ; Failur - Sets @Error to 4 if $bImg_Up = False but no DeleteHash is provided ; Failur - Sets @Error to 5 if the API returns 400 -> Bad Request ; Failur - Sets @Error to 6 if the API returns 403 -> Permission Denied ; Failur - Sets @Error to 7 if the API returns 413 -> Data to large ; Failur - Sets @Error to 8 if the API returns 415 -> Unsupported data ; Failur - Sets @Error to 9 if Curl returns no Curl ; Failur - Sets @Error to 10 and returns Curl error msg if Curl fails ; Failur - Sets @Error to 11 If StringRegExp failed on the header (no array) ; Author ........: Rex ; Modified.......: ; Remarks .......: Needs Curl, Json And BinaryCall by Ward - Base64Encode By Ward and _EPOCH_Decrypt by Trancexx ; Is includede in the UDF is self ; Related .......: ; Link ..........: ; Example .......: $dFile = FileOpenDialog('Open', @ScriptDir, 'Image Files (*.jpg;*.jpeg;*.png;*.bmp;*.gif)', 1) ; Browse image ; $hData = FileOpen($dFile, 16) ; Open as binary ; $dData = FileRead($hData) ; Read the data ; FileClose($hData) ; Close the FileHandle ; $aData = _Imgur('APIKEY', True, $dData) ; Uploade the Image ; ; $aDelete = _Imgur('APIKEY', False, 'DELETEHASH') ; ; =============================================================================================================================== Func _Imgur($sAuthKey, $bImg_Up = True, $vData = '') ; Performe some error checking Select Case $sAuthKey = '' ; If no authkey is provided Return SetError(1, 0, -1) ; We set error to 1 Case $vData = '' And $bImg_Up = True ; If no image data is sendt Return SetError(2, 0, -1) ; We sent error to 2 Case $vData <> '' And $bImg_Up = True And IsBinary($vData) = 0 ; If $vData isn't binary Return SetError(3, 0, -1) ; We sent error to 3 Case $vData = '' And $bImg_Up = False ; If no deleta hash was send Return SetError(4, 0, -1) ; We sent error to 4 EndSelect Local $aResult[9] ; Return array Local $ProgressCallback = DllCallbackGetPtr(DllCallbackRegister("ShowProgress", "int:cdecl", "ptr;uint64;uint64;uint64;uint64")) Local $Curl = Curl_Easy_Init() If Not $Curl Then Return SetError(9, 0, -1) Local $sHtml = $Curl Local $sHeader = $Curl + 1 ; any number as identify Local $sList = Curl_Slist_Append(0, "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:34.0) Gecko/20100101 Firefox/34.0") $sList = Curl_Slist_Append($sList, 'Referer: http://imgur.com/') $sList = Curl_Slist_Append($sList, 'Type: Base64') $sList = Curl_Slist_Append($sList, "Authorization: client-ID " & $sAuthKey) Curl_Easy_Setopt($Curl, $CURLOPT_HTTPHEADER, $sList) ; If $bImg_Up is true we uploads the image If $bImg_Up = True Then $dImage = _Base64Encode($vData) ; Convert the image to Base64 Curl_Easy_Setopt($Curl, $CURLOPT_URL, "https://api.imgur.com/3/upload/") ; If we wants to uploade an image Curl_Easy_Setopt($Curl, $CURLOPT_POST, 1) Curl_Easy_Setopt($Curl, $CURLOPT_COPYPOSTFIELDS, $dImage) Else ; If no img we expect a delete Curl_Easy_Setopt($Curl, $CURLOPT_URL, "https://api.imgur.com/3/image/" & $vData) ; If we wants to delete an image Curl_Easy_Setopt($Curl, $CURLOPT_CUSTOMREQUEST, 'DELETE') ; When we deletes an image EndIf ; Get header Curl_Easy_Setopt($Curl, $CURLOPT_HEADERFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_HEADERDATA, $sHeader) Curl_Easy_Setopt($Curl, $CURLOPT_FOLLOWLOCATION, 1) ; Checks use this to see the respons from server, and get img url/delete hash ect. Curl_Easy_Setopt($Curl, $CURLOPT_WRITEFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $sHtml) Curl_Easy_Setopt($Curl, $CURLOPT_TIMEOUT, 30) Curl_Easy_Setopt($Curl, $CURLOPT_SSL_VERIFYPEER, 0) Curl_Easy_Setopt($Curl, $CURLOPT_NOPROGRESS, 0) Curl_Easy_Setopt($Curl, $CURLOPT_XFERINFOFUNCTION, $ProgressCallback) Local $Code = Curl_Easy_Perform($Curl) If $Code <> $CURLE_OK Then Return SetError(10, 0, Curl_Easy_StrError($Code)) EndIf ;ConsoleWrite(@CRLF & 'HEADER: ' & BinaryToString(Curl_Data_Get($sHeader)) & @CRLF) ;ConsoleWrite(@CRLF & 'HTML RAW: ' & BinaryToString(Curl_Data_Get($sHtml)) & @CRLF) ; Check what the header returns $aHeader = StringRegExp(BinaryToString(Curl_Data_Get($sHeader)), 'HTTP/1.1 (400|403|413|415|200)', 1) If IsArray($aHeader) Then Select Case $aHeader[0] = 400 ; If 403 then Permission Denied Return SetError(5, 0, -1) Case $aHeader[0] = 403 ; If 403 then Permission Denied Return SetError(6, 0, -1) Case $aHeader[0] = 413 ; If 413 then the data is to large Return SetError(7, 0, -1) Case $aHeader[0] = 415 ; If 415 then the data is unsupported Return SetError(8, 0, -1) Case $aHeader[0] = 200 ; If 200 uploade/delete was a sucess ; Decode the json returned from imgur Local $sJson = Json_Decode(BinaryToString(Curl_Data_Get($sHtml))) ; If deleting an image we only needs to return Sucess - IMGUR returns Sucess If $bImg_Up = False Then ReDim $aResult[1] ; Slim down the array $aResult[0] = 'Success' Return $aResult EndIf ; If an image was uploaded then we need to return some data to the user $aResult[0] = Json_Get($sJson, '["data"]["id"]') ; Imgur image id ; Date time the image was uploaded, it's returned in unix timestamp, so we converts it to regular time stamp $aResult[1] = _EPOCH_Decrypt(Json_Get($sJson, '["data"]["datetime"]')) ; Type of uploaded image $aResult[2] = Json_Get($sJson, '["data"]["type"]') ; Was the image animated $aResult[3] = Json_Get($sJson, '["data"]["animated"]') ; Width of the image $aResult[4] = Json_Get($sJson, '["data"]["width"]') ; Height of the image $aResult[5] = Json_Get($sJson, '["data"]["height"]') ; Size of the image $aResult[6] = Json_Get($sJson, '["data"]["size"]') ; Delete hash of the image $aResult[7] = Json_Get($sJson, '["data"]["deletehash"]') ; Image link $aResult[8] = Json_Get($sJson, '["data"]["link"]') Curl_Easy_Cleanup($Curl) Curl_Data_Cleanup($Curl) Curl_Slist_Free_All($sList) Return $aResult EndSelect Else ; If the Regexp failed Return SetError(11, 1, -1) EndIf EndFunc ;==>_Imgur Func ShowProgress($Ptr, $dltotal, $dlnow, $ultotal, $ulnow) ProgressSet(Int($ulnow / $ultotal * 100), '% Sendt = ' & Int($ulnow / $ultotal * 100)) Return 0 EndFunc ;==>ShowProgress ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: _EPOCH_Decrypt ; Description ...: Converts Epoch Time to human time ; Syntax ........: _EPOCH_Decrypt(TIMESTAMP) ; Return values .: Convertede timestamp ; Author ........: Trancexx ; Modified ......: ; Remarks .......: ; =============================================================================================================================== Func _EPOCH_Decrypt($iEpochTime) ; By trancexx forum thread: https://www.autoitscript.com/forum/topic/83667-epoch-time/ Local $iDayToAdd = Int($iEpochTime / 86400) Local $iTimeVal = Mod($iEpochTime, 86400) If $iTimeVal < 0 Then $iDayToAdd -= 1 $iTimeVal += 86400 EndIf Local $i_wFactor = Int((573371.75 + $iDayToAdd) / 36524.25) Local $i_xFactor = Int($i_wFactor / 4) Local $i_bFactor = 2442113 + $iDayToAdd + $i_wFactor - $i_xFactor Local $i_cFactor = Int(($i_bFactor - 122.1) / 365.25) Local $i_dFactor = Int(365.25 * $i_cFactor) Local $i_eFactor = Int(($i_bFactor - $i_dFactor) / 30.6001) Local $aDatePart[3] $aDatePart[2] = $i_bFactor - $i_dFactor - Int(30.6001 * $i_eFactor) $aDatePart[1] = $i_eFactor - 1 - 12 * ($i_eFactor - 2 > 11) $aDatePart[0] = $i_cFactor - 4716 + ($aDatePart[1] < 3) Local $aTimePart[3] $aTimePart[0] = Int($iTimeVal / 3600) $iTimeVal = Mod($iTimeVal, 3600) $aTimePart[1] = Int($iTimeVal / 60) $aTimePart[2] = Mod($iTimeVal, 60) Return StringFormat("%.2d/%.2d/%.2d %.2d:%.2d:%.2d", $aDatePart[0], $aDatePart[1], $aDatePart[2], $aTimePart[0], $aTimePart[1], $aTimePart[2]) EndFunc ;==>_EPOCH_Decrypt ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: _Base64Encode ; Description ...: Encodes data into Base64 ; Syntax ........: _Base64Encode(Data, Linebreak) ; Return values .: Base64 Encodede string ; Author ........: Ward ; Modified ......: ; Remarks .......: ; =============================================================================================================================== Func _Base64Encode($Data, $LineBreak = 76) ; By Ward Local $Opcode = '0x5589E5FF7514535657E8410000004142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737' $Opcode &= '475767778797A303132333435363738392B2F005A8B5D088B7D108B4D0CE98F0000000FB633C1EE0201D68A06880731C083F901760C0FB6430125F0000000C1' $Opcode &= 'E8040FB63383E603C1E60409C601D68A0688470183F90176210FB6430225C0000000C1E8060FB6730183E60FC1E60209C601D68A06884702EB04C647023D83F' $Opcode &= '90276100FB6730283E63F01D68A06884703EB04C647033D8D5B038D7F0483E903836DFC04750C8B45148945FC66B80D0A66AB85C90F8F69FFFFFFC607005F5E' $Opcode &= '5BC9C21000' Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode) $Data = Binary($Data) Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]") DllStructSetData($Input, 1, $Data) $LineBreak = Floor($LineBreak / 4) * 4 Local $OputputSize = Ceiling(BinaryLen($Data) * 4 / 3) $OputputSize = $OputputSize + Ceiling($OputputSize / $LineBreak) * 2 + 4 Local $Ouput = DllStructCreate("char[" & $OputputSize & "]") DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _ "ptr", DllStructGetPtr($Input), _ "int", BinaryLen($Data), _ "ptr", DllStructGetPtr($Ouput), _ "uint", $LineBreak) Return DllStructGetData($Ouput, 1) EndFunc ;==>_Base64Encode I have added Wards curl, json and BinaryCall to the att. zip file.
       
      Cheers
      /Rex
      Includes.zip
    • nacerbaaziz
      By nacerbaaziz
      Hello Members of this best Forum
      i have a question please
      for example if i have a long string
      and i want to extract a text between two tag
      what i can do to make that?
      note :
      i know that there is a
      StringRegExp function
      it's do that work
      but it result is be as an array
      i want the result to be a string
      is there any function on autoit can do that?
      Thanks in advance.
    • therks
      By therks
      I'm trying to create a simple clock widget that automatically scales the text to the size of the window. I came up with the following method, but it doesn't work as well as I'd like. It especially has trouble scaling to the width of the window for some reason (in the example, try resizing the window to be narrow and tall).
      Does anyone have a better method?
      #include <Misc.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> #include <GDIPlus.au3> Opt('MustDeclareVars', 1) Global $_FONT_FAMILY = 'Arial', $_LB_TEXT Main() Func Main() _GDIPlus_Startup() Local $hGUI GUIRegisterMsg($WM_SIZE, WM_SIZE) $hGUI = GUICreate('', 300, 100, Default, Default, $WS_OVERLAPPEDWINDOW, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) $_LB_TEXT = GUICtrlCreateLabel('This is a string', 0, 0, 300, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont($_LB_TEXT, _MeasureString($hGUI, GUICtrlRead($_LB_TEXT), $_FONT_FAMILY), 0, 0, $_FONT_FAMILY, 5) GUISetState() Local $iGM While 1 $iGM = GUIGetMsg() Switch $iGM Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GDIPlus_Shutdown() EndFunc Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) GUICtrlSetFont($_LB_TEXT, _MeasureString($hWnd, GUICtrlRead($_LB_TEXT), $_FONT_FAMILY), 0, 0, $_FONT_FAMILY, 5) EndFunc Func _MeasureString($hWnd, $sString, $sFont = 'Arial') Local $iError, $aSize, $hGraphic, $hFormat, $hFamily, $tLayout, $iFontSize, $hFont, $aInfo If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) EndIf $aSize = WinGetClientSize($hWnd) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate($sFont) $tLayout = _GDIPlus_RectFCreate(0, 0, $aSize[0], $aSize[1]) $iFontSize = 0 Do If Not $hFamily Then $iError = 1 $iFontSize = 10 ExitLoop EndIf $iFontSize += 1 $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, 0) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) _GDIPlus_FontDispose($hFont) If $aInfo[1] = 0 Then ExitLoop Until DllStructGetData($aInfo[0], 3) >= $aSize[0] Or DllStructGetData($aInfo[0], 4) >= $aSize[1] $iFontSize -= 1 _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) Return SetError($iError, 0, $iFontSize) EndFunc
    • Ascer
      By Ascer
      Hello,
      Do you have any idea to resize Vector graphic using some maths trick?
      It's example to create Vector image 10x10px and write A
      Local $a10x10 = [ _ 1,1,1,1,1,1,1,1,1,1, _ 1,1,1,0,0,0,0,1,1,1, _ 1,1,0,0,1,1,0,0,1,1, _ 1,1,0,1,1,1,1,0,1,1, _ 1,1,0,1,1,1,1,0,1,1, _ 1,1,0,0,0,0,0,0,1,1, _ 1,1,0,1,1,1,1,0,1,1, _ 1,1,0,1,1,1,1,0,1,1, _ 1,0,0,0,1,1,0,0,0,1, _ 1,1,1,1,1,1,1,1,1,1 _ ] Local $oVector = ObjCreate("WIA.Vector.1") If Not IsObj($oVector) Then ConsoleWrite("+++ Error " & @error & " durning create a Vector.object." & @CRLF) Exit EndIf Local $iBlue = 0xFF0000FF ; ARGB color Local $iWhite = 0xFFFFFFFF ; adding pixels to vector For $i = 0 To UBound($a10x10) - 1 Local $iPixel = $a10x10[$i] Local $iColor = $iBlue If $iPixel = 0 Then $iColor = $iWhite $oVector.Add($iColor) Next ; create a img 10x10 px Local $oImg = $oVector.ImageFile(10, 10) ; path to file Local $sPath = @ScriptDir & "\Vector.bmp" ; delete previous file if exits. FileDelete($sPath) ; save img to script direction. $oImg.SaveFile($sPath) ; show result, you have to use 800% size to see effects. ShellExecute("Vector.bmp")  
×