Jump to content

oapjr

Active Members
  • Posts

    24
  • Joined

  • Last visited

oapjr's Achievements

  1. I think this is the code to delete a picture: #include <WinHTTP.au3> #include <String.au3> #include <Array.au3> #include <zlib.au3> $sBoundary = '--' & _GenerateBoundary(30) ; login $sNickName = '' $sPassword = '' $sImageID = '' $hOpen = _WinHttpOpen() $hConnect = _WinHttpConnect($hOpen, 'www.imagebam.com') $sHtml = _WinHttpSimpleFormFill($hConnect, '/login', 'loginform2', 'name:nick', $sNickName, 'name:pw', $sPassword) $hRequest = _WinHttpOpenRequest($hConnect, 'POST', '/sys/browse/delete/', 'HTTP/1.1') _WinHttpAddRequestHeaders($hRequest, 'Accept-Encoding: gzip, deflate') _WinHttpAddRequestHeaders($hRequest, 'Content-Type: application/x-www-form-urlencoded') $sPost = 'images=' & $sImageID _WinHttpSendRequest($hRequest, $WINHTTP_NO_ADDITIONAL_HEADERS, $sPost, StringLen($sPost)) _WinHttpReceiveResponse($hRequest) If _WinHttpQueryDataAvailable($hRequest) Then $sReceivedData = Binary('') While 1 $sReceivedData &= _WinHttpReadData($hRequest, 2) If Not @extended Then ExitLoop WEnd $sReceivedData = BinaryToString( _ZLIB_GZUncompress($sReceivedData)) EndIf ConsoleWrite('$sReceivedData : ' & $sReceivedData & @CRLF) ; a8yayuxmxxxxxxxxxxbjekez4u518gOK _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)
  2. I found this the other day: http://regex.inginf.units.it/# It automatically creates regular expression pattern. It's not going to work every time but it might help
  3. I don't know how to use zip.au3 but you can try 7za http://www.dotnetperls.com/7-zip-examples
  4. It worked! Thank you everyone!
  5. You are good with WinHTTP! Do you know a good place where I can learn more about WinHTTP? To get the Gallery ID would be something like this? Func _GetGalleryID($sReceivedData) Local $sPattern = '"GID":"(\w++)"}' If StringRegExp($sReceivedData,$sPattern,0) Then Return StringRegExp($sReceivedData,$sPattern,1)[0] Else Return '' EndIf EndFunc gallery creation, deletion and upload to gallery are working fine
  6. I google the "х" from 1440х900 and I got this on Wikipedia: Character Х х Unicode name CYRILLIC CAPITAL LETTER HA CYRILLIC SMALL LETTER HA Encodings decimal hex decimal hex Unicode 1061 U+0425 1093 U+0445 UTF-8 208 165 D0 A5 209 133 D1 85 Numeric character reference &#1061; &#x425; &#1093; &#x445; KOI8-R and KOI8-U 232 E8 200 C8 Code page 855 182 B6 181 B5 Code page 866 149 95 229 E5 Windows-1251 213 D5 245 F5 ISO-8859-5 197 C5 229 E5 Macintosh Cyrillic 149 95 245 F5 ps: the file contain a bunch of wallpaper I downloaded on the internet and the ini I created on autoit
  7. My language is US and I didn't setup the inifile The exact example is that "3D-graphics1440x900" was written as "3D-graphics1440?900"
  8. Hi! I'm having problem with IniWrite function The problem is that if the returned string from _FileListToArrayRec contain something like "3D-graphics1440x900" the string that is written on the ini file is "3D-graphics1440?900". Does anyone know what I'm doing wrong? Edit: I know that if I rename the folder the functions work properly #include <File.au3> Local $iReturn Local $sPath, $sFile Local $aList $sPath = @UserProfileDir & '\Pictures' $iReturn = $FLTAR_FILES + $FLTAR_NOHIDDEN + $FLTAR_NOSYSTEM + $FLTAR_NOLINK $aList = _FileListToArrayRec($sPath, "*jpg;*.png||", $iReturn, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) $sFile = $aList[Random(1, $aList[0], 1)] IniWrite('test.ini','test','test',$sFile)
  9. Awesome!!! I'm going to retire my noob script: #include <Array.au3> #include <File.au3> $sFile1 = FileOpenDialog('File 1',"",'All (*.*)|Text files (*.txt)|Html (*.htm)') $sFile2 = FileOpenDialog('File 1',"",'All (*.*)|Text files (*.txt)|Html (*.htm)') $aFile1 = FileReadToArray($sFile1) $inf1 = UBound($aFile1) $aFile2 = FileReadToArray($sFile2) $inf2 = UBound($aFile2) For $iL1 = ($inf1-1) to 0 Step -1 For $iL2 = ($inf2-1) to 0 Step -1 If $aFile1[$iL1] == $aFile2[$iL2] Then $aFile1[$iL1] = '' $aFile2[$iL2] = '' EndIf Next Next For $iL1 = ($inf1-1) to 0 Step -1 if $aFile1[$iL1] == '' Then _ArrayDelete($aFile1,$iL1) Next For $iL2 = ($inf2-1) to 0 Step -1 if $aFile2[$iL2] == '' Then _ArrayDelete($aFile2,$iL2) Next $hFile = FileOpen('Result.txt',1) FileWrite($hFile,$sFile1 & ' ---------------------------------------------------------' & @CRLF) _FileWriteFromArray($hFile,$aFile1) FileWrite($hFile,@CRLF & $sFile2 & ' ---------------------------------------------------------' & @CRLF) _FileWriteFromArray($hFile,$aFile2) FileWrite($hFile,@CRLF & '---------------------------------------------------------' & @CRLF) FileClose($hFile)
  10. Nice work with TinyPicSharer! I created a UDF from your script but I was wondering if it is possible to upload to a specific user account on ImageBam? #include <WinHTTP.au3> #include <String.au3> #include <Array.au3> #include <zlib.au3> Local $sBoundary = '--' & _GenerateBoundary(30) ; #FUNCTION# ==================================================================================================================== ; Name...........: _ImagebamUpload ; Description ...: Upload image file to ImageBam. ; Syntax.........: _ImagebamUpload( $sPicPath ) ; Parameters ....: $sPicPath - Image path to upload ; Return values .: Success - Returns the link from ImageBam ; Failure - 0, sets @error: ; |1 - couldn't upload image ; |2 - couldn't get link ; Author ........: wakillon ; Modified.......: oapjr ; Remarks .......: ; Related .......: ; Link ..........; http://www.autoitscript.com/forum/topic/122168-tinypicsharer-v-1034-new-version-08-june-2013 ; Example .......; No ; =============================================================================================================================== Func _ImagebamUpload($sPicPath) $upload = _HostImagebamUpload($sPicPath) If @error Then SetError(1) Else $aLinks = _HostImagebamExtractLinks($upload) If @error Then SetError(2) Else Return $aLinks[0] EndIf EndIf Return 0 EndFunc ;==>_ImagebamUpload Func _HostImagebamUpload($sPicPath) Local $hOpen, $hConnect, $hRequest, $sHost, $sDataToSend, $sReceivedData, $iError, $sResponse, $sPostData, $sContentType Local $sUserAgent = '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; .NET4.0E)' $sHost = 'www.imagebam.com' $hOpen = _WinHttpOpen($sUserAgent) If @error Then SetError(1) Else $hConnect = _WinHttpConnect($hOpen, $sHost) If @error Then SetError(2) Else $hRequest = _WinHttpOpenRequest($hConnect, 'POST', '/sys/upload/save', 'HTTP/1.1') If @error Then SetError(3) Else _WinHttpSetTimeouts($hRequest, 10000, 60000, 90000, 90000) $sDataToSend = _HostImagebamSetDataToSend($sPicPath) _WinHttpAddRequestHeaders($hRequest, 'Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/x-silverlight, */*') _WinHttpAddRequestHeaders($hRequest, 'Referer: http://www.imagebam.com/basic-upload') _WinHttpAddRequestHeaders($hRequest, 'Accept-Encoding: gzip, deflate') _WinHttpAddRequestHeaders($hRequest, 'Connection: Keep-Alive') _WinHttpAddRequestHeaders($hRequest, 'Cache-Control: no-cache') $sContentType = 'Content-Type: multipart/form-data; boundary=' & StringTrimLeft($sBoundary, 2) _WinHttpSendRequest($hRequest, $sContentType, $WINHTTP_NO_REQUEST_DATA, StringLen($sDataToSend)) If @error Then SetError(4) Else _PicUploadProgress($hRequest, $sPicPath, $sDataToSend) If Not @error Then _WinHttpReceiveResponse($hRequest) If @error Then SetError(5) Else If _WinHttpQueryDataAvailable($hRequest) Then $sReceivedData = Binary('') While 1 $sReceivedData &= _WinHttpReadData($hRequest, 2) If Not @extended Then SetError(0) ExitLoop ;~ EndIf WEnd $sReceivedData = BinaryToString( _ZLIB_GZUncompress($sReceivedData)) If StringInStr($sReceivedData, 'box_error') Then SetError(6) ; The thumbnail for the file pic.jpg could not be created. Else SetError(7) EndIf EndIf Else SetError(8) EndIf EndIf EndIf EndIf EndIf $iError = @error If $hRequest Then _WinHttpCloseHandle($hRequest) If $hConnect Then _WinHttpCloseHandle($hConnect) If $hOpen Then _WinHttpCloseHandle($hOpen) Return SetError($iError, 0, $sReceivedData) EndFunc ;==>_HostImagebamUpload Func _HostImagebamExtractLinks($HtmlData) ;~ Return Links Array ;~ [0] Link only ( viewer only, not download link) ;~ [1] Thumb ;~ [2] BBCode ;~ [3] HTML $HtmlData = StringMid($HtmlData, StringInStr($HtmlData, 'dlinput_container', 0, 1) - StringLen('dlinput_container') - 1) Local $aRet = StringRegExp(StringReplace($HtmlData, @LF, ''), "(?s)(?i)dlinput_container(.*?)</div>", 3) If Not @error Then Local $aLinks[3], $aRet1 For $i = 0 To UBound($aRet) - 2 $aRet1 = StringRegExp($aRet[$i], "(?s)(?i)value='(.*?)>", 3) If Not @error Then $aRet1[0] = StringStripWS(StringTrimRight($aRet1[0], 1), 1 + 2) $aLinks[$i] = $aRet1[0] EndIf Next _ArrayReverse($aLinks) Local $sUrl = _StringBetween($aLinks[1], '[img]', '[/IMG]') If Not @error Then _ArrayInsert($aLinks, 1, $sUrl[0]) Else Return SetError(2) EndIf If $aLinks[UBound($aLinks) - 1] <> '' Then Return $aLinks Else Return SetError(3) EndIf Else Return SetError(1) EndIf EndFunc ;==>_HostImagebamExtractLinks 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 _HostImagebamSetDataToSend($sPicPath) Local $sData = _PicReadData($sPicPath) If @error Then Return SetError(1) Local $sImageName = _GetFullNameByFullPath($sPicPath) If @error Or $sImageName = '' Then Return SetError(2) Local $sContentType = _PicGetContentType($sPicPath) If @error Then Return SetError(3) Local $sCdfdn = 'Content-Disposition: form-data; name' Local $sCtaos = 'Content-Type: application/octet-stream' Local $sString = $sBoundary & @CRLF & _ $sCdfdn & '="file[]"; filename="' & $sImageName & '"' & @CRLF & _ $sContentType & @CRLF & @CRLF & $sData & @CRLF & $sBoundary & @CRLF For $i = 1 To 29 $sString &= $sCdfdn & '="file[]"; filename=""' & @CRLF & _ $sCtaos & @CRLF & @CRLF & @CRLF & $sBoundary & @CRLF Next $sString &= $sCdfdn & '="content_type"' & @CRLF & @CRLF & '0' & @CRLF & $sBoundary & @CRLF & _ $sCdfdn & '="thumb_size"' & @CRLF & @CRLF & '100' & @CRLF & $sBoundary & @CRLF & _ $sCdfdn & '="thumb_aspect_ratio"' & @CRLF & @CRLF & 'resize' & @CRLF & $sBoundary & @CRLF & _ $sCdfdn & '="thumb_file_type"' & @CRLF & @CRLF & 'jpg' & @CRLF & $sBoundary & '--' Return SetError(0, '', $sString) EndFunc ;==>_HostImagebamSetDataToSend Func _PicUploadProgress($hRequest, $sPicPath, $sDataToSend) If Not FileExists($sPicPath) Then Return SetError(-1) Local $sDatas = StringToBinary($sDataToSend) Local $iNumberOfBytesToSend = 2048 Local $Bin, $iPercent, $iStart = 1, $iExtended = 0 While 1 $Bin = BinaryMid($sDatas, $iStart, $iNumberOfBytesToSend) If BinaryLen($Bin) = 0 Then Return _WinHTTPWriteData($hRequest, $Bin, 1) If Not @error Then $iExtended += @extended $iPercent = Round(($iExtended) / (StringLen($sDataToSend)) * 100, 2) ConsoleWrite('-->-- [' & StringFormat('%03i', @ScriptLineNumber) & '][' & @HOUR & @MIN & @SEC & '] $iPercent : ' & $iPercent & @CRLF) If $iPercent > 97 Then $iPercent = 97 $iStart += $iNumberOfBytesToSend Else $Bin = 0 Return SetError(1) EndIf WEnd EndFunc ;==>_PicUploadProgress Func _PicGetContentType($sPicPath) If Not FileExists($sPicPath) Then Return SetError(-1) Local $sExt = _GetExtByFullPath($sPicPath) If @error Or $sExt = '' Then Return SetError(1) Local $sContentType Switch $sExt Case 'jpg', 'jpe', 'jpeg' $sContentType = 'Content-Type: image/jpeg' ; ie 'Content-Type: image/pjpeg' Case 'gif' $sContentType = 'Content-Type: image/gif' Case 'bmp' $sContentType = 'Content-Type: image/bmp' Case 'png' $sContentType = 'Content-Type: image/png' ; ie Content-Type: image/x-png Case 'tif', 'tiff' $sContentType = 'Content-Type: image/tiff' Case Else Return SetError(2) EndSwitch Return $sContentType EndFunc ;==>_PicGetContentType Func _PicReadData($sPicPath) If Not FileExists($sPicPath) Then Return SetError(-1) Local $hFile = FileOpen($sPicPath) If $hFile = -1 Then Return SetError(1) Local $sData = FileRead($hFile) If @error Then Return SetError(2) FileClose($hFile) Return $sData EndFunc ;==>_PicReadData Func _GetFullNameByFullPath($sFullPath) Local $aFileName = StringSplit($sFullPath, '\') If Not @error Then Return $aFileName[$aFileName[0]] Return SetError(1) EndFunc ;==>_GetFullNameByFullPath Func _GetExtByFullPath($sFullPath) Local $aFileName = StringSplit($sFullPath, '.') If Not @error Then Return $aFileName[$aFileName[0]] Return SetError(1) EndFunc ;==>_GetExtByFullPath
  11. HotKeySet('{ESC}','_Quit') While 1 Sleep(1000) WEnd Func _Quit() Exit EndFunc Or HotKeySet('{ESC}','_Quit') $bLoop = True While $bLoop Sleep(1000) WEnd Func _Quit() $bLoop = False EndFunc
  12. Found this =D '?do=embed' frameborder='0' data-embedContent>>
  13. Hi! I'm having a problem sorting array if I have array like this: 1test10 test19 test15 1test13 1test1 test3 1test2 test7 using _ArraySort from Array.au3 the result is: 1test1 1test10 1test13 1test2 test15 test19 test3 test7 but what i really want is something like this: 1test1 1test2 1test10 1test13 test3 test7 test15 test19 Can someone help me?
  14. Thank you! I found this: '?do=embed' frameborder='0' data-embedContent>>
  15. Hi, The problem is that I want to run a function inside a running script. I know that I could set a hotkey that trigger this function, but I'm looking for another option. I tried using CmdLine and passing parameter to the script, but it only run the function in another instance of the script. I thought of creating a gui and set it state to hidden, and then ControlClick some of its buttons, but it only work if the window is active. Can someone help? Edit: Global $iFreq = 500 While 1 Beep($iFreq,100) Sleep(1000) WEnd Func _IncFreq() $iFreq += 100 EndFunc Func _DecFreq() $iFreq -= 100 EndFunc
×
×
  • Create New...