lifesux Posted September 6, 2013 Share Posted September 6, 2013 (edited) Hi guys I am working on a script for my image host website that i can took photos,upload to ftp then take the link.I coded taking pic and save but i stuck at ftp and taking the link.Like LightShot programme.Its in turkish but i hope that u will understand it.Please test it before writing expandcollapse popup#NoTrayIcon #Include<ScreenCapture.au3> Opt("TrayMenuMode", 1) Opt("TrayOnEventMode", 1) If WinExists ("BulutResim.com V 1.0 Aracı") Then ProcessClose (WinGetProcess ("BulutResim.com V 1.0 Aracı")) AutoitWinSetTitle ("BulutResim.com V 1.0 Aracı") Global $sDataDump = @TempDir & "\BulutResim.com\" Global $sLog = @ScriptDir & "\kayit.ini" Global $nClick = 10 If Not FileExists ($sDataDump) Then DirCreate ($sDataDump) Global $hUser32 = DllOpen ("User32.dll") Global $hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, -2147483648, 136) MsgBox(0,"BulutResim.com Resim Çek-Paylaş Aracı V 1.0","Bu araç LifeSuxTR tarafından BulutResim.com için geliştirilmiştir") TraySetIcon ("C:\WINDOWS\system32\SHELL32.dll", 23) TraySetState () TraySetTooltip ("Pencere Kayıt Edici") TraySetClick (16) TrayCreateItem ("Ekranı Çek") TrayItemSetOnEvent (-1, "_cek") TrayCreateItem ("Pencereyi Çek") TrayItemSetOnEvent (-1, "_cekpenc") TrayCreateItem ("") TrayCreateItem ("Resimlerin Dizinini Aç") TrayItemSetOnEvent (-1, "_Ac") TrayCreateItem ("Tüm Resimleri Sil") TrayItemSetOnEvent (-1, "_Temizle") TrayCreateItem ("") TrayCreateItem ("İşlem Kayıtlarını Aç") TrayItemSetOnEvent (-1, "_Kayitac") TrayCreateItem ("İşlem Kayıtlarını Sil") TrayItemSetOnEvent (-1, "_Kayittemizle") TrayCreateItem ("") TrayCreateItem ("Çıkış") TrayItemSetOnEvent (-1, "_Cikis") TrayTip ("BulutResim.com Araci v 1.0", "CTRL+Orta mouse tuşunu kullanarak belirli bir alanı yada pencereyi seçiniz." & @CRLF & @CRLF & _ "Aynı fonksiyonlara menüdende ulaşabilirsiniz.", 5, 1) GUICtrlSetResizing (-1, 802) WinSetTrans ($hGUI, "", 100) While 1 If _basildi ("Ctrl") And _basildi ("Middle") Then $hWnd = WinGetHandle ("[active]", "") WinSetState ($hWnd, "", @SW_DISABLE) $aPos = _alansec () If ($aPos[2] - $aPos[0] < $nClick) Or ($aPos[3] - $aPos[1] < $nClick) Then $aPos = WinGetPos ($hWnd, "") $aPos[2] += $aPos[0] $aPos[3] += $aPos[1] EndIf WinSetState ($hWnd, "", @SW_ENABLE) $sFile = _GetFile () _ScreenCapture_Capture ($sFile, $aPos[0], $aPos[1], $aPos[2], $aPos[3], False) ClipPut ($sFile) _kayityaz ($sFile, 1) ElseIf _basildi ("Print") Then $sFile = _GetFile () _ScreenCapture_Capture ($sFile, 0, 0, @DesktopWidth, @DesktopHeight, False) ClipPut ($sFile) _kayityaz ($sFile, 2) EndIf Sleep (10) WEnd Func _GetFile () $i = 0 While 1 $i += 1 If Not FileExists ($sDataDump & $i & ".jpg") Then Return $sDataDump & $i & ".jpg" WEnd EndFunc Func _basildi ($key) Switch StringLower ($key) Case "Left" $iHex = "01" Case "middle" $iHex = "04" Case "ctrl" $iHex = "11" Case "print" $iHex = "2C" Case Else Return -1 EndSwitch $aIsbasildi = DllCall($hUser32, "int", "GetAsyncKeyState", "int", "0x" & $iHex) If @Error Or (BitAND ($aIsbasildi[0], 0x8000) <> 0x8000) Then Return 0 Return 1 EndFunc Func _alansec () Local $aPos = MouseGetPos (), $aLast[2] = [-1, -1], $aPosFirst = MouseGetPos (), $aRet[4] WinMove ($hGUI, "", $aPosFirst[0], $aPosFirst[1], 1, 1) GUISetState(@SW_SHOW, $hGUI) While _basildi ("Middle") $aPos = MouseGetPos () If ($aPos[0] <> $aLast[0]) Or ($aPos[1] <> $aLast[1]) Then $aRet[0] = $aPosFirst[0] $aRet[1] = $aPosFirst[1] $aRet[2] = $aPos[0] $aRet[3] = $aPos[1] If $aRet[0] > $aRet[2] Then $tmp = $aRet[0] $aRet[0] = $aRet[2] $aRet[2] = $tmp EndIf If $aRet[1] > $aRet[3] Then $tmp = $aRet[1] $aRet[1] = $aRet[2] $aRet[2] = $tmp EndIf WinMove ($hGUI, "", $aRet[0], $aRet[1], $aRet[2] - $aRet[0], $aRet[3] - $aRet[1]) $aLast = $aPos EndIf Tooltip ($aRet[2] - $aRet[0] & " x " & $aRet[3] - $aRet[1]) Sleep (10) WEnd Tooltip ("") GUISetState (@SW_HIDE, $hGUI) Return $aRet EndFunc Func _kayityaz ($sFile, $nType) IniWrite ($sLog, @MDAY & "." & @MON & "." & @YEAR, @MIN & ":" & @HOUR & "_" & $nType, StringRegExpReplace ($sFile, ".*\\", "")) Endfunc Func _cek () $sFile = _GetFile () _ScreenCapture_Capture ($sFile, 0, 0, @DesktopWidth, @DesktopHeight, False) ClipPut ($sFile) _kayityaz ($sFile, 3) Endfunc Func _cekpenc () WinSetTrans ($hGUI, "", 1) WinMove ($hGUI, "", 0, 0, @DesktopWidth, @DesktopHeight) GUISetCursor (3, 1, $hGUI) GUISetState (@SW_SHOW, $hGUI) While Not _basildi ("Left") WEnd GUISetState (@SW_HIDE, $hGUI) GUISetCursor (1, 1, $hGUI) MouseClick ("") $aPos = WinGetPos ("[active]") WinSetTrans ($hGUI, "", 100) $aPos[2] += $aPos[0] $aPos[3] += $aPos[1] $sFile = _GetFile () _ScreenCapture_Capture ($sFile, $aPos[0], $aPos[1], $aPos[2], $aPos[3], False) ClipPut ($sFile) _kayityaz ($sFile, 4) Endfunc Func _Kayitac () ShellExecute ($sLog) EndFunc Func _Kayittemizle () FileDelete ($sLog) EndFunc Func _Ac () ShellExecute ($sDataDump) EndFunc Func _Temizle () Dirremove ($sDataDump, 1) DirCreate ($sDataDump) _kayityaz ("\temizlenmis resim", 5) EndFunc Func _Cikis () Exit EndFunc Edited September 6, 2013 by lifesux Link to comment Share on other sites More sharing options...
lifesux Posted September 7, 2013 Author Share Posted September 7, 2013 no one tested my code ? As you see it saves pictures like 1-2-3-4-5... names.I want to make it random for example xd345dg54aasd23 like that... Link to comment Share on other sites More sharing options...
abberration Posted September 7, 2013 Share Posted September 7, 2013 (edited) no one tested my code ? As you see it saves pictures like 1-2-3-4-5... names.I want to make it random for example xd345dg54aasd23 like that... I don't know what you want tested, but to answer the question posed in this quote, try this code: $randomSeq = "" For $i = 1 to 12 $rNum = Random(48, 122, 1) If $rNum < 58 OR $rNum > 96 Then $randomSeq = Chr($rNum) & $randomSeq Else $i -= 1 EndIf Next MsgBox(0, "", $randomSeq) What it does is creates a 12 character string of random lowercase letters and numbers (to create shorter or longer ones, just modify how many times to loop the For...Next statement). The ASCII range of numbers is 48-57 and lowercase letters is 97-122. As you can see, the random function generates numbers between 48-122, but the loop only uses random numbers that fall into the ranges we want. Edited September 7, 2013 by abberration Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
lifesux Posted September 8, 2013 Author Share Posted September 8, 2013 I don't know what you want tested, but to answer the question posed in this quote, try this code: $randomSeq = "" For $i = 1 to 12 $rNum = Random(48, 122, 1) If $rNum < 58 OR $rNum > 96 Then $randomSeq = Chr($rNum) & $randomSeq Else $i -= 1 EndIf Next MsgBox(0, "", $randomSeq) What it does is creates a 12 character string of random lowercase letters and numbers (to create shorter or longer ones, just modify how many times to loop the For...Next statement). The ASCII range of numbers is 48-57 and lowercase letters is 97-122. As you can see, the random function generates numbers between 48-122, but the loop only uses random numbers that fall into the ranges we want. Thanks so much i did it.Only ftp upload left Link to comment Share on other sites More sharing options...
wakillon Posted September 9, 2013 Share Posted September 9, 2013 You PM me for help pointing on http://hitleselim.com/Resim/ but in your script i see http://lifesuxtrmap.tk/ and http://bulutresim.com/ So to which one do you want upload your images ? AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
wakillon Posted September 9, 2013 Share Posted September 9, 2013 (edited) For http://hitleselim.com/Resim/ the image hosting website, try this example >zlib.au3 is needed. expandcollapse popup#Region ;************ Includes ************ #include <WinHTTP.au3> #include <Array.au3> #include <zlib.au3> #EndRegion ;************ Includes ************ OnAutoItExitRegister ( '_OnAutoItExit' ) Global $sHeader, $sFilePath, $sBoundary, $iFileSize $sBoundary = '--' & _GenerateBoundary ( 10 ) $sFilePath = 'YourPicturePath.JPG' ; set the path of your pic ! $iFileSize = FileGetSize ( $sFilePath ) If $iFileSize < ( 1024*1024 ) Then $sCookies = _WinHttpGetCookies ( 'http://hitleselim.com/Resim/' ) ConsoleWrite ( '$sCookies : ' & $sCookies & @Crlf ) $sXmlDatas = _HitleselimUpload ( $sFilePath, $sCookies ) If @error Then ConsoleWrite ( '@error HitleselimUpload : ' & @error & @Crlf ) ;~ ConsoleWrite ( '$sXmlDatas : ' & $sXmlDatas & @Crlf ) Else Local $aPicLinks = _HitleselimExtractLinks ( $sXmlDatas ) If @error Then ConsoleWrite ( '@error HitleselimExtractLinks : ' & @error & @Crlf ) ElseIf UBound ( $aPicLinks ) -1 > 0 Then ;~ _ArrayDisplay ( $aPicLinks ) ConsoleWrite ( 'Direct Link is : ' & $aPicLinks[0] & @Crlf ) ShellExecute ( $aPicLinks[0] ) EndIf EndIf Else ConsoleWrite ( '! File is too large !' & @Crlf ) EndIf Exit Func _GenerateBoundary ( $iLen ) Local $sString = '' Do Switch Random ( 1, 3, 1 ) Case 1 $sString &= Chr ( Random ( 48, 57, 1 ) ) ; 0 to 9 Case 2 $sString &= Chr ( Random ( 65, 90, 1 ) ) ; A to Z Case 3 $sString &= Chr ( Random ( 97, 122, 1 ) ) ; a to z EndSwitch Until StringLen ( $sString ) = $iLen Return $sString EndFunc ;==> _GenerateBoundary () Func _GetContentType ( $sFilePath ) Local $sExt = _GetExtByFullPath ( $sFilePath ) If @error Or $sExt = '' Then Return SetError ( 1 ) ;~ ConsoleWrite ( '$sExt : ' & $sExt & @Crlf ) Local $sContentType Switch $sExt Case 'jpg', 'jpe', 'jpeg' $sContentType = 'Content-Type: image/jpeg' Case 'gif' $sContentType = 'Content-Type: image/gif' Case 'bmp' $sContentType = 'Content-Type: image/bmp' Case 'png' $sContentType = 'Content-Type: image/png' Case 'tif', 'tiff' $sContentType = 'Content-Type: image/tiff' Case Else Return SetError ( 2 ) EndSwitch Return $sContentType EndFunc ;==> _GetContentType () Func _GetExtByFullPath ( $sFullPath ) Local $aFileName = StringSplit ( $sFullPath, '.' ) If Not @error Then Return $aFileName[$aFileName[0]] Return SetError ( 1 ) EndFunc ;==> _GetExtByFullPath () Func _GetFullNameByFullPath ( $sFullPath ) Local $aFileName = StringSplit ( $sFullPath, '\' ) If Not @error Then Return $aFileName[$aFileName[0]] Return SetError ( 1 ) EndFunc ;==> _GetFullNameByFullPath () Func _GetPicData ( $sFilePath ) Local $hFile = FileOpen ( $sFilePath ) If $hFile = -1 Then Return SetError ( 1 ) Local $sData = FileRead ( $hFile ) If @error Then Return SetError ( 2 ) FileClose ( $hFile ) Return $sData EndFunc ;==> _GetPicData () Func _UploadProgress ( $hRequest, $sFilePath, $sDataToSend ) Local $sDatas = StringToBinary ( $sDataToSend ) Local $sDataSize = BinaryLen ( $sDatas ) Local $iNumberOfBytesToSend = 2048 Local $sImageName = _GetFullNameByFullPath ( $sFilePath ) ProgressOn ( 'Uploading', $sImageName, '', Default, Default, 16 ) Local $Bin, $iPercent, $iStart = 1, $iExtended = 0 While 1 $Bin = BinaryMid ( $sDatas, $iStart, $iNumberOfBytesToSend ) If BinaryLen ( $Bin ) = 0 Then ExitLoop _WinHTTPWriteData ( $hRequest, $Bin, 1 ) If Not @error Then $iExtended += @extended $iPercent = Round ( ( $iExtended ) / ( StringLen ( $sDataToSend ) ) * 100, 2 ) ProgressSet ( $iPercent, $iPercent & '%' ) $iStart += $iNumberOfBytesToSend Else SetError ( 5 ) ExitLoop EndIf WEnd If Not @error Then ProgressSet ( 100, 'Done', 'Complete' ) Else Return SetError ( @error, '', '' ) EndIf EndFunc ;==> _UploadProgress () Func _HitleselimExtractLinks ( $HtmlData ) ;~ [0] Direct link ;~ [1] medium size ;~ [2] thumb $HtmlData = StringReplace ( StringReplace ( $HtmlData, '[', 'µ' ), ']', 'µ' ) Local $aLinks = StringRegExp ( $HtmlData, '(?s)(?i)µIMGµ(.*?)µ/IMGµ', 3 ) If Not @error Then _ArrayReverse ( $aLinks ) Return $aLinks EndIf EndFunc ;==> _HitleselimExtractLinks () Func _HitleselimSetDataToSend ( $sFilePath ) Local $sData = _GetPicData ( $sFilePath ) If @error Then Return SetError ( 1 ) Local $sImageName = _GetFullNameByFullPath ( $sFilePath ) If @error Or $sImageName = '' Then Return SetError ( 2 ) Local $sContentType = _GetContentType ( $sFilePath ) If @error Then Return SetError ( 3 ) ;~ ConsoleWrite ( '$sContentType : ' & $sContentType & @Crlf ) Local $sDescription = StringReplace ( StringReplace ( StringTrimRight ( $sImageName, 4 ), '-', '' ), '_', '' ) Local $sCdfdn = 'Content-Disposition: form-data; name' Local $sCtaos = 'Content-Type: application/octet-stream' $sString = $sBoundary & @CRLF & _ $sCdfdn & '="MAX_FILE_SIZE"' & @CRLF & @CRLF & 1024*1024 & @CRLF & $sBoundary & @CRLF & _ $sCdfdn & '="imgUrl"' & @CRLF & @CRLF & @CRLF & $sBoundary & @CRLF & _ $sCdfdn & '="fileName[]"' & @CRLF & @CRLF & $sFilePath & @CRLF & $sBoundary & @CRLF & _ $sCdfdn & '="file[]"; filename="' & $sImageName & '"' & @CRLF & _ $sContentType & @CRLF & @CRLF & $sData & @CRLF & $sBoundary & @CRLF & _ $sCdfdn & '="alt[]"' & @CRLF & @CRLF & $sDescription & @CRLF & $sBoundary & @CRLF & _ $sCdfdn & '="new_height[]"' & @CRLF & @CRLF & @CRLF & $sBoundary & @CRLF & _ $sCdfdn & '="new_width[]"' & @CRLF & @CRLF & @CRLF & $sBoundary & @CRLF & _ $sCdfdn & '="submit"' & @CRLF & @CRLF & 'Upload' & @CRLF & $sBoundary & '--' Return SetError ( 0, '', $sString ) EndFunc ;==> _HitleselimSetDataToSend () Func _OnAutoItExit () DllClose ( $hWINHTTPDLL__WINHTTP ) EndFunc ;==> _OnAutoItExit () Func _HitleselimUpload ( $sFilePath, $sCookies='' ) Local $hOpen, $hConnect, $hRequest, $hRequest2, $sHost, $sDataToSend, $sReceivedData, $iError $sHost = 'hitleselim.com' $hOpen = _WinHttpOpen ( 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET CLR 1.1.4322)' ) If @error Then $iError = 1 Else _WinHttpSetOption ( $hOpen, $WINHTTP_OPTION_REDIRECT_POLICY, $WINHTTP_OPTION_REDIRECT_POLICY_NEVER ) $hConnect = _WinHttpConnect ( $hOpen, $sHost ) If @error Then $iError = 2 Else $hRequest = _WinHttpOpenRequest ( $hConnect, 'POST', '/Resim/upload.php', 'HTTP/1.1' ) If @error Then $iError = 3 Else _WinHttpSetTimeouts ( $hRequest, 0, 5000, 120000, 120000 ) $sDataToSend = _HitleselimSetDataToSend ( $sFilePath ) _WinHttpAddRequestHeaders ( $hRequest, 'Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, */*' ) _WinHttpAddRequestHeaders ( $hRequest, 'Referer: http://hitleselim.com/Resim/' ) _WinHttpAddRequestHeaders ( $hRequest, 'Accept-Language: fr-FR' ) _WinHttpAddRequestHeaders ( $hRequest, 'Accept-Encoding: gzip, deflate' ) _WinHttpAddRequestHeaders ( $hRequest, 'Connection: Keep-Alive' ) _WinHttpAddRequestHeaders ( $hRequest, 'Cache-Control: no-cache' ) If $sCookies <> '' Then _WinHttpAddRequestHeaders ( $hRequest, 'Cookie: ' & $sCookies ) $sContentType = 'Content-Type: multipart/form-data; boundary=' & StringTrimLeft ( $sBoundary, 2 ) _WinHttpSendRequest ( $hRequest, $sContentType, $WINHTTP_NO_REQUEST_DATA, StringLen ( $sDataToSend ) ) If @error Then $iError = 4 Else _UploadProgress ( $hRequest, $sFilePath, $sDataToSend ) If Not @error Then _WinHttpReceiveResponse ( $hRequest ) If @error Then $iError = 5 Else If _WinHttpQueryDataAvailable ( $hRequest ) Then $sReceivedData = '' While 1 $sReceivedData &= _WinHttpReadData ( $hRequest ) If Not @extended Then ExitLoop WEnd $hRequest2 = _WinHttpOpenRequest ( $hConnect, 'GET', '/Resim/thumbnail.php', 'HTTP/1.1' ) _WinHttpAddRequestHeaders ( $hRequest2, 'Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, */*' ) _WinHttpAddRequestHeaders ( $hRequest2, 'Referer: http://hitleselim.com/Resim/' ) _WinHttpAddRequestHeaders ( $hRequest2, 'Accept-Encoding: gzip, deflate' ) _WinHttpAddRequestHeaders ( $hRequest2, 'Connection: Keep-Alive' ) _WinHttpAddRequestHeaders ( $hRequest2, 'Accept-Language: fr-FR' ) _WinHttpAddRequestHeaders ( $hRequest2, 'Cache-Control: no-cache' ) If $sCookies <> '' Then _WinHttpAddRequestHeaders ( $hRequest2, 'Cookie: ' & $sCookies ) _WinHttpSendRequest ( $hRequest2 ) _WinHttpReceiveResponse ( $hRequest2 ) If _WinHttpQueryDataAvailable ( $hRequest2 ) Then $sReceivedData = Binary ( '' ) While 1 $sReceivedData &= _WinHttpReadData ( $hRequest2, 2 ) If Not @extended Then ExitLoop WEnd $sReceivedData = BinaryToString ( _ZLIB_GZUncompress ( $sReceivedData ) ) EndIf Else $iError = 7 EndIf EndIf Else $iError = 8 EndIf EndIf EndIf EndIf EndIf ProgressOff () If $hRequest2 Then _WinHttpCloseHandle ( $hRequest2 ) If $hRequest Then _WinHttpCloseHandle ( $hRequest ) If $hConnect Then _WinHttpCloseHandle ( $hConnect ) If $hOpen Then _WinHttpCloseHandle ( $hOpen ) Return SetError ( $iError, 0, $sReceivedData ) EndFunc ;==> _HitleselimUpload () Func _WinHttpGetCookies ( $sUrl ) Local $hOpen = _WinHttpOpen ( 'Mozilla/4.0 (compatible; MSIE 8.0)' ) Local $aCrackedUrl = _WinHttpCrackUrl ( $sUrl ) Local $sHostName = $aCrackedUrl[2] Local $sFileName = $aCrackedUrl[6] Local $sExtra = $aCrackedUrl[7] Local $hConnect = _WinHttpConnect ( $hOpen, $sHostName ) Local $hRequest = _WinHttpOpenRequest ( $hConnect, 'GET', $sFileName & $sExtra, 'HTTP/1.1' ) _WinHttpSendRequest ( $hRequest ) _WinHttpReceiveResponse ( $hRequest ) Local $iHeaderIndex=0, $sCookie, $sSpace While 1 $sCookie &= $sSpace & _WinHttpQueryHeaders ( $hRequest, $WINHTTP_QUERY_SET_COOKIE, $WINHTTP_HEADER_NAME_BY_INDEX, $iHeaderIndex ) If Not @error And $sCookie Then $sSpace = ' ' Else ExitLoop EndIf $iHeaderIndex +=1 WEnd _WinHttpCloseHandle ( $hRequest ) _WinHttpCloseHandle ( $hConnect ) _WinHttpCloseHandle ( $hOpen ) Return StringStripWS ( $sCookie, 1+2 ) EndFunc ;==> _WinHttpGetCookies () Edited September 9, 2013 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now