Jump to content

Izebize

Active Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by Izebize

  1. Thanks for sharing! I recommend jennico's _Borders.au3 UDF for those, who don't want to use constant border size, or _WinAPI_GetSystemMetrics.
  2. Hi all! I wrote a simple downloader with a gui. #include <INet.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $hGUI_DL, $guiDL_CloseLabel, $guiDL_CurrentFile, $guiDL_CurrentLabel, $guiDL_MinimizeLabel, $guiDL_Progress, $guiDL_Size, $guiDL_Speed, $guiDL_Status Opt("GUIOnEventMode", 1) Opt("WinTitleMatchMode", 4) $hGUI = GUICreate("TEST", 100, 24) GUISetOnEvent(-3, "_Quit") GUISetOnEvent(-7, "_DragWindow") GUICtrlCreateButton(" OK ", 30, 0, 40) GUICtrlSetOnEvent(-1, "DOWNLOAD") GUISetState() While 1 Sleep(20) WEnd Func DOWNLOAD() $sURL = "http://www.hardwired.hu/bigdl/3/10/Batman_Arkham_Asylum_PC_muvi_gadgets.wmv" $hGUI_DL = GUICreate("Download", 400, 120, Default, Default, 0x80080000, Default, $hGUI) GUISetOnEvent(-3, "_Quit") GUISetOnEvent(-7, "_DragWindow") GUICtrlCreateLabel("Download", (400 - 72) / 2, 1, 72) GUICtrlSetFont(-1, 10, 800, 0, "Verdana") $guiDL_CloseLabel = GUICtrlCreateLabel("r", 400 - 26, 0, 20, 20, 0x01) GUICtrlSetOnEvent(-1, "_Quit") GUICtrlSetFont(-1, 12, 600, 0, "Webdings") $guiDL_Size = GUICtrlCreateLabel("0.0/0.0 MB (0.0%)", 154, 30, 400 - 164, 20, 0x02) $guiDL_CurrentFile = GUICtrlCreateLabel("", 10, 50, 380, 20) $guiDL_Progress = GUICtrlCreateProgress(10, 70, 380, 20) $guiDL_Speed = GUICtrlCreateLabel("Speed: 0 kB/s", 290, 96, 100, 20, 0x02) $guiDL_Status = GUICtrlCreateLabel("Status: Waiting for link... (0 seconds remaining)", 10, 96, 280, 20) GUISetState() _SimpleDownloader($sURL, "C:\Downloads") GUIDelete($hGUI_DL) EndFunc ;==>DOWNLOAD #Region _Quit() Func _Quit() Exit EndFunc ;==>_Quit #EndRegion _Quit() Func _DragWindow() DllCall("user32.dll", "int", "SendMessage", "hWnd", WinGetHandle("[ACTIVE]"), "int", 0xA1, "int", 2, "int", 0) ;$WM_NCLBUTTONDOWN, $HTCAPTION EndFunc ;==>_DragWindow #Region _SimpleDownloader($sURL, $sDownloadDir) Func _SimpleDownloader($sURL, $sDownloadDir) If StringRight($sDownloadDir, 1) <> "\" Then $sDownloadDir &= "\" GUICtrlSetData($guiDL_Status, "Status: Downloading...") InetGet($sURL, $sDownloadDir & StringRegExpReplace($sURL, "http://.*/(.*)", "$1"), 0, 1) $iSize = InetGetSize($sURL) Local $iSpeed, $iLastSpeed While @InetGetActive $iSpeed = @InetGetBytesRead ;Download GUI Code ;ConsoleWrite(@HOUR&":"&@MIN&":"&@SEC&"."&@MSEC&" > "&$iSpeed&@CR) GUICtrlSetData($guiDL_Size, StringFormat("%.2f/%.2f MB (%.1f%%)", $iSpeed / 1024 / 1024, $iSize / 1024 / 1024, $iSpeed / $iSize * 100)) GUICtrlSetData($guiDL_Progress, $iSpeed / $iSize * 100) GUICtrlSetData($guiDL_Speed, "Speed: " & StringFormat("%.0f kB/s", ($iSpeed - $iLastSpeed) / 1024)) $iLastSpeed = $iSpeed Sleep(1000) WEnd EndFunc ;==>_SimpleDownloader #EndRegion _SimpleDownloader($sURL, $sDownloadDir) But if I click on the close button, or try to move the child gui (using onevent functions) it only reacts at the end of the download. I know the reason is because of the "While @InetGetActive" loop but I have no idea how to make it work within the loop. Any suggest?
  3. Hi all! I've got a script like this: #include <GDIPlus.au3> $hGUI = GUICreate("IMGTEST") GUISetState() _GDIPlus_Startup() InetGet("http://www.google.com/enterprise/images/star.jpg", @TempDir&"\izethumb.jpg") $hBitmap = _GDIPlus_BitmapCreateFromFile(@TempDir&"\izethumb.jpg") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hBitmap) _WinAPI_DeleteObject($hBitmap) FileDelete(@TempDir&"\izethumb.jpg") _GDIPlus_Shutdown() Do Until GUIGetMsg() = -3 How can I make it work without saving the picture to the disk? I supposed to use _INetGetSource() but I have no idea, how to display it as an image.
  4. Look for DllCall in the help file or try this.
  5. It will return only the first window, because if you use Return statment then it exits from the function, and gives back the result wich is $list[1][0].
  6. Try this:#include <Array.au3> Local $aArray = PixelSearch(712, 465, 714, 467, 0x55574D) _ArrayDisplay($aArray)
  7. If you use the Window Info tool then you can just double click on Mouse/Color, and it will copy the value to the clipboard. I suggest the Freeze (Ctrl+Alt+F) mode, and use the "Finder Tool", it's much easier.
  8. How did you get that pixel color? Default PixelGetColor gives you a decimal integer, you have to convert it to a 6 digit hex integer, if you want to use it as a hex. Here's a sample: Local $PixelColor = PixelGetColor(10, 10) ConsoleWrite("Default pixel color: " & $PixelColor & @CR) ConsoleWrite("Hex based pixel color: " & Hex($PixelColor,6) & @CR) Local $aTemp = PixelSearch(1, 1, 20, 20, $PixelColor) ConsoleWrite("PixelSearch X coord: " & $aTemp[0] &@CR) ConsoleWrite("PixelSearch Y coord: " & $aTemp[1] &@CR)
  9. Thanks for your help! I used StringInStr as you suggested, but now I figured out how to make it work with RegExp: $fFile = "X:\Folder\Archive.part1.rar" ConsoleWrite(StringRegExpReplace($fFile, ".*\\(.*)(?:\.part1)\.rar", "$1") &@CR);Old one ConsoleWrite(StringRegExpReplace($fFile, ".*\\(.*?)(?:\.part1)?\.rar", "$1") &@CR);Working one"?" is very important in these cases.
  10. $fFile = "X:\Folder\Archive.part1.rar" ConsoleWrite(StringRegExpReplace($fFile, ".*\\(.*)(?:\.part1)\.rar", "$1")&@CR) ;Works fine ConsoleWrite(StringRegExpReplace($fFile, ".*\\(.*)(?:\.part1)?\.rar", "$1")&@CR);keeps "part1" I want to set the ".part1" section may or may not appear. I thought this is the correct syntax, but It doesn't works.
  11. Maybe this would help you: #Include <GuiListView.au3> _GUICtrlListView_Create($hGUICreate, "item", 0, 0, 150, 150, BitOR($LVS_REPORT,$LVS_SHOWSELALWAYS))
  12. Sounds good, thanks! I also tryin to do it with xml, but for this I have to learn it a bit.
  13. If you use InetGet with IE UDF then you should know that it doesn't copies the header, just creates a new one. Thats the reason why it throws the login page. I personally recommend the WinHTTP UDF, but it takes time till you work out your IE script to WinHTTP.
  14. Hi! I want to create a script to download programs from the internet via the given link to it. I've created a "directory structure file" to arrange files (links) into folders, so it would be more see through. The structure looks like this (filestruct.txt): DirectoryName .SubDirName ..FileName ...-link ...-mirror ..FileName ...-link DirectoryName2 .FileName ..-link .SubDirName ..FileName ...-link I jump through the lines with FileReadLine. I use StringRegExp, to determinate the type of the current line (dir,subdir,file,link). But I have no idea how can I store it in a dinamical array. If I want to store it in an array, then I need at least a 5D array. I afraid that if I would use ReDim for every line, after some it would be slower and slower, if I add more and more files to it. Anyone knows another method for this, or to keep it fast? Maybe an already existing method to store a structure like this? And here is a simple 5D array declaration error: Dim $a1[1][1][1][1] = [[[[1]]]] ;Good Dim $a2[1][1][1][1][1] = [[[[[1]]]]] ;syntax & wrong nesting error
  15. Finally I got the solution. I used DllStruct like this: $fFile = "100MBfile.bin" ;Contains 0x00 -> i have to use raw mode $hFile = FileOpen($fFile, 4) ;Open raw mode $sStringB = "StringBEGIN" $sStringE = "StringEND" $tBuffer = DllStructCreate("byte["&StringLen($sStringB)&"];byte["&FileGetSize($fFile)&"];byte["&StringLen($sStringE)&"]") DllStructSetData($tBuffer, 1, $sStringB) DllStructSetData($tBuffer, 2, FileRead($hFile, FileGetSize($fFile))) DllStructSetData($tBuffer, 3, $sStringE) FileClose($hFile) FileWrite($fNew, DllStructGetData($tBuffer, 1) & _ DllStructGetData($tBuffer, 2) & _ DllStructGetData($tBuffer, 3))
  16. @SmOke_N: Thanks! It looks good, I'll check it right now. @water: That probably works, but with this method I have to copy the big file once more every time, and that takes too much time if I want to work with hundreds of big files.
  17. I've also read the help file. I have to add string before, and after the file. I also have to use raw mode, because it contains 0x00 char, and if i open it a regular way it stops after 4 chars, because of the 0x00 char (null-terminated string). As I said before, I can read the file. The only problem is I can't add any string to it.
  18. You can see in my snippet, that I just read the file. I use write on "output.txt". I could use ConsoleWrite, or MsgBox instead of FileWrite, but if you run it in Scite like most of us do, then your computer would not response to anything for a couple of days
  19. Hi! I'm working on an uploader. It uploads files throu PHP. For this I have to read a file and add some string to it. But if that file is too big, then it exits with this message: "Error allocating memory". AU3 Snippet to illustrate my prob: $fFile = "100MBfile.bin" ;Contains 0x00 -> i have to use raw mode $hFile = FileOpen($fFile, 4) ;Open raw mode $sFile = FileRead($hFile, FileGetSize($fFile)) ;Reads properly FileWrite("output.txt", "StringBegin"&@CRLF& _ $sFile&@CRLF& _ 'StringEnd'&@CRLF ;Fails with allocating memory error FileClose($hFile) It reads the file properly, but if I add some string to it then it fails. If you run this code with a file thats big enough then you will get the same message. How can I add a string to big files without modifying the file itself?
  20. Hi! I've been using these functions a while, but now i stucked. I created a script for my web page, to get some stuff from it, but now I try to send some message to it. My problem is when I send the POST message with the given data it sends in an other packet. My browser doesn't splits this data apart from the header, and it sends almost the same http code as my script. Is it possible not to split this data? My script sends these: Packet #1: POST /index.php? HTTP/1.1 Referer: http://www.mypage.com Accept: Content-Type: multipart/form-data; boundary=FGOPPTuB Content-Length: 167 Referer: http://www.mypage.com/index.php?act=post User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 Host: www.mypage.com Connection: Keep-Alive Cookie: session_id=c43e25e5c25c12907d8f90aea6e05f16 Packet #2: --FGOPPTuB Content-Disposition: form-data; name="User" Admin --FGOPPTuB Content-Disposition: form-data; name="Message" Some message comes here --FGOPPTuB-- My browser sends this (FF v3.5): POST /index.php? HTTP/1.1 Host: www.mypage.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://www.mypage.com/index.php?act=post Cookie: session_id=769f31985d8cf428643a62c9b802de51 Content-Type: multipart/form-data; boundary=---------------------------12052273501150 Content-Length: 266 -----------------------------12052273501150 Content-Disposition: form-data; name="User" Admin -----------------------------12052273501150 Content-Disposition: form-data; name="Message" Some message comes here -----------------------------12052273501150-- Part of my script: Const $BOUNDARY = _RandomString() $Data = '--' & $BOUNDARY & @CRLF & _ 'Content-Disposition: form-data; name="User"' & @CRLF & _ '' & @CRLF & _ 'Admin' & @CRLF & _ '--' & $BOUNDARY & @CRLF & _ & @CRLF & _ 'Content-Disposition: form-data; name="Message"' & @CRLF & _ '' & @CRLF & _ 'Some message comes here' & @CRLF & _ '--' & $BOUNDARY & '--' & @CRLF $sHeaders = "Content-Type: multipart/form-data; boundary=" & _RandomString() & @CRLF $sHeaders &= "Content-Length: " & StringLen($Data) & @CRLF $sHeaders &= "Referer: http://www.mypage.com/index.php?act=post" _WinHttpSendRequest($hRequest, $sHeaders, $Data, StringLen($Data)) I'm not sure if this is the problem, but i tried to replace the headers to the same as the browsers, but without any success. I appreciate any other advices!
  21. Hi! I wrote a little script to demonstrate my problem: #include <Array.au3> $sString = "Blablalba" & @CRLF & _ "Something goes here: coolstuff" & @CRLF & _ "Blablabla" & @CRLF & _ "Something goes here: else" & @CRLF & _ "Blablabla" $aSRE = StringRegExp($sString, "(?:Something goes here: ([a-z]*))+", 1) _ArrayDisplay($aSRE) It creates an array ["coolstuff"]. How can I make it to recognize the other string, so the result would be ["coolstuff", "else"] ?
  22. It's within local area, and I don't have firewall for it. I use firewall only for WAN. I'm sure it can reach the php. I will check the sended packets with Wireshark and after I compared I'll post the differences.
  23. _INetGetSource doesn't work. How can I add header?
×
×
  • Create New...