Jump to content
Advert

Rad

Active Members
  • Posts

    402
  • Joined

  • Last visited

About Rad

  • Birthday 05/21/1989

Profile Information

  • Location
    Oregon
  • WWW
    http://radleygh.com

Rad's Achievements

Universalist

Universalist (7/7)

0

Reputation

  1. Weird, the upload must not have gone through. It doesn't matter though, that example you posted does exactly what I needed. Thanks!
  2. I'm using to upload a file to a server. After the upload the server returns a URL to that file. My program needs to give that URL to the user. libcURL is working fine and the upload is successful, and the HTML response needed is output to scite's console. I need the information put into the console to be stored in a variable, though, and I can't figure it out. I think I need to use stdout or stdread to do this. I have used these before when using a run() command but this library is using a dll (and is much cleaner than my previous version which used run commands). How do I record the output buffer of a DLL? (or whatever stdout is called). This attachment is what I'm testing it with, just open "playground.au3" and run it. It should spit a bunch of information to the console. The top listing of variables is all from curl_getdata(), the part with brackets and arrows is from my web server. I need the second part to be put into a variable. PS: The cURL process ID is stored as $__hcurl_process seangriffin's manages to accomplish this, it looks like the key is to use "DllCallbackRegister". I'm trying to plug this in to smartee's UDF but the two UDF's look like completely different languages. I don't think I will be able to figure this out on my own, but I'm going to keep trying. EDIT: You need to move the DLL's to the same folder as playground.au3, and edit "libcURL.au3" and change the #include to quotes instead of brackets. I packed it wrong.
  3. As someone who rarely uses autoit and doesn't understand how DLL's work, this made it much easier. I have this working with form fields and files which is all I need, but I'm wondering how do you get the data returned (currently prints to console) in a variable? The example "_curl_easy_getinfo.au3" requests an image, the return for that response is a bunch of binary data. I need everything after the "We recieved content-type: image/png" from this screenshot: http://screencast.com/t/NuIHoHRo920J EDIT: The answer lies within the dllcallback functionality, it's accomplished here: I do not have the ability to combine the two though.
  4. I am in need of a workaround, as the script does not support a few functions (especially _DeleteAllItems) if I use the classic function. I've searched for a UDF version of GUICtrlSetPos but couldn't find one. Google and autoit forum search didn't help. What can I do? Here is an example, clearly they both should move together: #include <GUIConstantsEx.au3> #include <GuiListView.au3> $gui = GUICreate("") $w = 50 $list1 = _GUICtrlListView_Create($gui, "Lol", 0, 0, $w, 50) $list2 = GUICtrlCreateListView("Lol", 0, 70, $w, 50) $btn1 = GuiCtrlcreatebutton("-", 0, 50, 20, 20) $btn2 = GuiCtrlcreatebutton("+", 20, 50, 20, 20) guisetstate() while 1 $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE then Exit if $msg = $btn1 then $w -= 10 GUICtrlSetPos($list1, 0, 0, $w, 50) GUICtrlSetPos($list2, 0, 70, $w, 50) EndIf if $msg = $btn2 then $w += 10 GUICtrlSetPos($list1, 0, 0, $w, 50) GUICtrlSetPos($list2, 0, 70, $w, 50) EndIf sleep(10) WEnd Also a video showing why this is so annoying! It appears to resize the control, but the visible frame is not resized. http://www.screencast.com/users/RadGH/folders/Jing/media/9dea81df-23ab-4b66-aea2-be2a8c7e80d5 EDIT: Same result with GUI resizing mode
  5. EDIT: Nevermind, I forgot a single line of code: $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) ...Where is the delete button I'm going off the _GUICtrlListView_Create() example, trying to copy some code out of it and get it to work with my current script. But it's really long and has a LOT of random variables like $tNMHDR and such. I do not know where to begin for debugging... ugh! I can't find a way to decide what element was double-clicked on. So, I copied pieces from the help file and it works. But the data returned by WM_NOTIFY is always the same. Here is the appropriate code for declaring my list view, although it's not generated exactly like this: $filetree = _GUICtrlListView_Create($GUI,'',28,28,450,450) $filetree_column = _GUICtrlListView_AddColumn($filetree, "", $width - $width * 0.1) $file_list[$i][2] = _GUICtrlListView_AddItem($filetree, $file_list[$i][0]) And here is what I've gathered from the help file: Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo ;~ Local $tBuffer $hWndListView = $filetree If Not IsHWnd($filetree) Then $hWndListView = GUICtrlGetHandle($filetree) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Local $tagNMHDR, $vEvent Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK consoleWrite("-->hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode & @LF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags") & @CRLF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc
  6. The ellipsis thing is really nice. I've tried recreating that before, I didn't know it was a style option! But it doesn't seem to work inside an input and if it did it would limit the ability to manually edit the input (I assume I could remove the style when the user grants it focus, but... that would be weird). I'll just use Brewman's option. It looks like it would work, surprised I didn't think of it. Even when I mentioned moving the caret position, lol. Thanks!
  7. I have a text input control which shows a directory, like: [C:\My Folder\File.exe ] If the directory is long, it cuts off from the right: [C:\My Folder\Fi] I would rather it cuts off from the left, because you rarely need to know what folder/drive you are accessing, but rather what the file is. This is what I would prefer: [y Folder\File.exe] Normally if you were typing this into the input, because you type left-to-right, you would end up with this as a result. But if the script adds the text when you are done with the file browse dialog it won't do it that way. If there is a way to set the caret position of a control without giving the control focus, I could use that also. (But again, I couldn't find a way to do this in the help file) Is there a way to make text "flow" from the right instead of the left? I don't know the proper term... But align-right does not solve the issue. It aligns right until the text is cut off, and then it shows the string from the left first. I could probably write a way to remove excess characters if they scroll off the edge, but not without complicating the ability to manually edit the text input. /shrug If there is a built in option that I can't find, that is what I am looking for. Thanks.
  8. I've had this working program for quite a while now, but bought a new laptop with Windows Seven x64 (home premium). At first, the program would completely lock the system when I took screenshots with the _ScreenCapture_Capture() function (It would save the image with the bottom ~200pixels rendered, and would stop on the same pixel every time). So I ran the source code, and that problem is gone. The program worked almost fine... But the logic to downgrade the quality of the image no longer works. I used FileGetSize() to see if the file is under a certain amount, and if not I would convert it to a PNG, then to a JPG and continually downgrade it from there. This all worked fine on XP x32, and works fine for my friend running Vista x32. The rest of the code works as intended. The file gets uploaded, all of the windows look normal. The only thing that doesn't work is FileGetSize(). From the source code: global $MaxFilesize = 1024*400 func save_image($f) $bmp = $f&".bmp" if Not fileexists($bmp) then debug("Image does not exist for conversion ["&$bmp&"]") Else if FileGetSize($f) < $MaxFileSize then debug("Image does not need to be converted ["&$bmp&"]") if FileGetSize($f) = 0 then debug ("ERROR: Image filesize could not be determined ["&@WORKINGDIR&"\"&$bmp&"]") return -1 EndIf return $bmp EndIf EndIf ... This basically says "Does the file exist? Then is it smaller than XXX? Let's make sure it's not 0!". Now you can see the debug lines, heres what gets output to my console: Line 014 [11:30:51] Image was saved as [radshot 3testexe_2010-165-23-30-51-84.bmp] Line 015 [11:30:51] Image exists [radshot 3testexe_2010-165-23-30-51-84.bmp] Line 016 [11:30:51] Image does not need to be converted [radshot 3testexe_2010-165-23-30-51-84.bmp] Line 017 [11:30:51] ERROR: Image filesize could not be determined [C:\Users\Radley's G73J\Documents\Radshot VERSION 2.0\radshot 3testexe_2010-165-23-30-51-84.bmp] I will keep messing around with this, but is this a known issue? Is there a workaround? What should I try next?
  9. Yeah, that is the same code that I linked before, except it's the total resolution of multiple monitors. The dll call's return arrays, they might include separate monitor information... Just a guess, but I can't test it with just one monitor. I will try to figure this out some time when he has free time, but would love to make some progress before hand.
  10. My second monitor has been dead for a few weeks, and a friend of mine is urging me to make my program work with his second monitor. I plan to add a hotkey for a single monitor and separate hotkey for each monitor individually, as well as the entire desktop - but I figured that out. I have done some searching but could only find how to get the entire screenspace of a desktop. And I do not understand DLL's so I am unsure if that users32.dll would have what I am looking for to get each monitor's information. It would be great to have this in a 2d-array formatted like so: $Monitors[0][0] = 3 ;Number of monitors $Monitors[1][0] = 1024 ;First monitor's width $Monitors[1][1] = 1280 ;First monitor's height $Monitors[1][2] = 0 ;First monitor's X-origin $Monitors[1][3] = 0 ;First monitor's Y-origin $Monitors[2][0] = 1400 ;Second monitor's width $Monitors[2][1] = 1050 ;Second monitor's height $Monitors[2][2] = -1400 ;Second monitor's X-origin $Monitors[2][3] = 0 ;Second monitor's Y-origin $Monitors[3][0] = 800 ;Third monitor's width $Monitors[3][1] = 600 ;Third monitor's height $Monitors[3][2] = 1024 ;First monitor's X-origin $Monitors[3][3] = 0 ;First monitor's Y-origin This example would be 3 monitors side by side, with the first one in the middle and second on the left. All of them would be aligned to the top of the first monitor. If this were lined up physically, you would have the right monitor stacked on a few books and the middle monitor sitting on a magazine, provided the base is the same height. If there is already a way to get these values, please let me know. Can't find anything in the helpfile, and I do not have another monitor available so this i'll have to hope the code is right and have him test it for me.
  11. Thanks for the reply, that seems to work and I am trying to fiddle with it. I don't understand why there is a need for graphics and also hbitmaps... Edit: Got it to work best using this function, haven't implemented the ability to change width and height yet but you should be able to figure it out with the $h and $w variables. Probably not an efficient way to do it, but it's actually a lot faster than the command line utility. Will tweak with it some more. I really think there should be GDI functions to just change the width height and quality. func image_quality($file, $quality, $name, $output) $hGUI3 = GUICreate("Scaled Down", 200, 150) GUISetState() _GDIPlus_Startup () $hImage = _GDIPlus_ImageLoadFromFile ($name) $h = _GDIPlus_ImageGetHeight($hImage) $w = _GDIPlus_ImageGetWidth($hImage) $sCLSID = _GDIPlus_EncodersGetCLSID ("JPG") $hGraphic3 = _GDIPlus_GraphicsCreateFromHWND ($hGUI3) $bitmap3 = _GDIPlus_BitmapCreateFromGraphics($w, $h, $hGraphic3) $image3 = _GDIPlus_ImageGetGraphicsContext($bitmap3) _GDIPlus_GraphicsDrawImageRectRect ($image3, $hImage, 0, 0, $w, $h, 0, 0, $w, $h) _GDIPlus_GraphicsDrawImageRect($hGraphic3, $bitmap3, 0, 0, $w, $h) $tParams = _GDIPlus_ParamInit (1) $tData = DllStructCreate("int Quality") DllStructSetData($tData, "Quality", 100) ;quality 0-100 $pData = DllStructGetPtr($tData) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) $pParams = DllStructGetPtr($tParams) _GDIPlus_ImageSaveToFileEx($bitmap3, $output, $sCLSID, $pParams) GUIDelete($hGUI3) _WinAPI_DeleteObject($bitmap3) _GDIPlus_GraphicsDispose($image3) _GDIPlus_GraphicsDispose ($hGraphic3) _GDIPlus_ImageDispose ($hImage) _GDIPlus_Shutdown () FileDelete($name) endfunc
  12. Use the Autoit Window Info tool, which gets placed in the start menu folder for autoit. Highlight the button and look under the "Control" tab, press CTRL+ALT+F. Now use the ID under the Control tab along with the window title in the function ControlClick ( "title", "text", controlID [, button [, clicks [, x [, y ]]]] ) Example: ControlClick("Calculator", "", 82)
  13. EDIT: Since there hasn't been a reply, I assume this functionality is unavailable in current release... or the thread become TLDR. Figured I should do the same as I did for uploading a form without IE, and find a command-line tool. I'm going to use G'MIC. I looked at imagemagick but it had an entire GUI thing and too many files to include. I just need to resize and change the quality I need two functions that should be simple, and I'm very surprised I don't see them in the help file. I just need this capability in it's most basic form, the quality function is very important, the scale is not but could add many features to my program. Maybe I have overlooked these, but if I knew enough to make these functions here is how I would use them: $hBMP = _ScreenCapture_Capture("") $hBMP = _GDIPlus_ImageResize($hBMP, 1024, 768, True) ;True would be for preserving aspect ratio, somehow _ScreenCapture_SaveImageQuality($hBMP, @scriptdir & "\file.jpg", 95) ; 95 being the image quality Now these might exist with a different name, but I don't see them. I used this function in the past but it's old code, there are a few errors when I try to compile and when I fix the errors the include file starts throwing more errors... Func __ScreenCapture_SaveImage($sFileName, $hBitmap, $fFreeBmp, $iQuality) Local $hClone, $sCLSID, $tData, $sExt, $hImage, $pParams, $tParams, $iResult, $iX, $iY If @error Then Return SetError(-1, -1, False) $sExt = StringUpper(_GDIPlus_ExtractFileExt($sFileName)) $sCLSID = _GDIPlus_EncodersGetCLSID($sExt) If $sCLSID = "" Then Return SetError(-2, -2, False) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) If @error Then Return SetError(-3, -3, False) Switch $sExt Case "BMP" $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iX, $iY, $giBMPFormat) _GDIPlus_ImageDispose($hImage) $hImage = $hClone Case "JPG", "JPEG" $tParams = _GDIPlus_ParamInit(1) $tData = DllStructCreate("int Quality") DllStructSetData($tData, "Quality", $iQuality) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, DllStructGetPtr($tData)) Case "TIF", "TIFF" $tParams = _GDIPlus_ParamInit(2) $tData = DllStructCreate("int ColorDepth;int Compression") DllStructSetData($tData, "ColorDepth", $giTIFColorDepth) DllStructSetData($tData, "Compression", $giTIFCompression) _GDIPlus_ParamAdd($tParams, $GDIP_EPGCOLORDEPTH, 1, $GDIP_EPTLONG, DllStructGetPtr($tData, "ColorDepth")) _GDIPlus_ParamAdd($tParams, $GDIP_EPGCOMPRESSION, 1, $GDIP_EPTLONG, DllStructGetPtr($tData, "Compression")) EndSwitch If IsDllStruct($tParams) Then $pParams = DllStructGetPtr($tParams) $iResult = _GDIPlus_ImageSaveToFileEx($hImage, $sFileName, $sCLSID, $pParams) _GDIPlus_ImageDispose($hImage) If $fFreeBmp Then _WinAPI_DeleteObject($hBitmap) Return SetError($iResult = False, 0, $iResult = True) EndFunc Trying another answer but keep getting the error Autoit3.exe has encountered an error... Is there something wrong with this code? No errors if I just save it as a jpg, only when I add params. $f = @scriptdir & "\file.jpg" $q = 75 $hBMP = _ScreenCapture_Capture("") _GDIPlus_Startup() $TParam = _GDIPlus_ParamInit(1) $Datas = DllStructCreate("int Quality") DllStructSetData($Datas, "Quality", $q) _GDIPlus_ParamAdd($TParam, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, DllStructGetPtr($Datas)) $clsid = _GDIPlus_EncodersGetCLSID("JPG") _GDIPlus_ImageSaveToFileEx($hBmp, $f, $clsid, DllStructGetPtr($TParam))
  14. I have some good news, but I wish it were cleaner. If you improve this please post the changes, I'm not very good at detecting errors... You can read in from stderr (using STDErrRead($result) where $result is the stream from the Run command. To do this you need to store the actual result from the request to a file (aka the source code of the website). And for that, you add -o curl.tmp to the command. I don't know why it's stderr and not stdin, though I don't really know the difference regardless. Now, after the Run() you can use StderrRead() to get the "progress" of the file. If you run the command line in a console you can see how this is formatted. I made this function to collect the data. You will likely need to mess with it, I found a few times when the arrays were incorrect and tried to prevent them. #cs ==================================================================================================== Description: Takes the default stderrread() data of a curl.exe command converts it to a usable format Parameters: curlGetProgress($sStdErr) Returnvalues: Array { 0: Total % 1: Total Bytes 2: Download % 3: Download Bytes 4: Upload % 5: Upload Bytes 6: Download Rate 7: Upload Rate 8: Estimated Time 9: Time Elapsed 10: Time Left 11: Current Speed (Upload or Download, I assume) } Author: Rad Notes: This is only enabled if your curl command outputs a progress meter (NOT progress "bar"). From the curl documentation: "If you want a progress meter for HTTP POST or PUT requests, you needto redirect the response output to a file, using shell redirect (>), -o [file] or similar." ==================================================================================================== #ce func curlGetProgress($stream) local $regexp = stringregexp($stream, "[0-9\:\-]{1,}[a-zA-Z\:]{0,}", 3) local $err = @error local $array[12] if $err > 0 then ;The regexp had an error, which is likely caused by the formatting of the stream. seterror($err+1) return $err+1 Else if isarray($regexp) Then for $i = 0 to 11 $array[$i] = $regexp[$i] Next return $array Else ;The regexp didn't catch an error, but there was only one match seterror(1) return -1 EndIf EndIf EndFunc
  15. Thanks for the suggestion! I was currently looking at wGet but I don't think it can do the 'send' portion. Your suggestion looks like what I need, but I'm not sure what to do with the source code. *snip* Edit: Using the cURL download wizard I was able to get a pre-compiled version of curl.exe, with SSL disabled (Not using it). I was able to upload my file AND include the username/password field using curl.exe -F "username=testuser" -F "password=testpass" -F "file=@C:\Documents and Settings\Administrator\My Documents\My Pictures\myimage.jpg" -F press=Upload http://url.com/submit.php Thanks for showing me this. I learned a bit and can finally finish my program without using a public ftp account. I also see potential for this cURL in my program for other things. It would be great if I could get a progress bar out of this. If I run it as a .bat, it displays transfer rate, amount transferred, percentage etc. It can also do a progress bar. Is there any way to make this (using RunWait()) to output this data in autoit-usable format? I will read the documentation some more, but you might already know...
×
×
  • Create New...