Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/27/2016 in all areas

  1. Jon

    Display Name Changes

    I'm turning off the ability for user's to change their own display names at the end of today. After that you can request a name change from a moderator. Just to prevent confusion, messing about, etc.
    2 points
  2. #include <Array.au3> If @Compiled Then Exit Global Enum $FUNC_OUTER, $FUNC_NAME, $FUNC_PARAM, $FUNC_INNER _Example() Func _Example() Local $sIncludeDir = StringTrimRight(@AutoItExe, StringLen('AutoIt3.exe')) & 'Include\' Local $aOuterArray = _GetFunctionsToArray($sIncludeDir & 'Color.au3') If Not @error Then For $iOuter_idx = 0 To UBound($aOuterArray) - 1 _ArrayDisplay($aOuterArray[$iOuter_idx], ($aOuterArray[$iOuter_idx])[$FUNC_NAME]) Next EndIf EndFunc ;==>_Example Func _GetFunctionsToArray($sUDF_FileFullPath) Local $sUDFContent = FileRead($sUDF_FileFullPath) Local $aResult = StringRegExp($sUDFContent, '(?is)\RFunc (.*?)\((.*?)\)\v\R(.*?)\REndFunc', $STR_REGEXPARRAYGLOBALFULLMATCH) Return SetError(@error, @extended, $aResult) EndFunc ;==>_GetFunctionsToArray
    1 point
  3. I hope @Melba23 will be back online as soon as possible .
    1 point
  4. error471, Great - nice to see a satisfied customer! And it was a fun few days getting it all to work, so thanks to you too. I will polish the code a bit more over the next few days (i.e. making the default for the *ColSpec functions the rightmost column) - so keep an eye on the main UDF thread for a new release. M23
    1 point
  5. Just my input, I always do batch image processing with IrfanView, it has batch processing built right in, but when you want to automate or integrate further it has cmd parameters for everything make it easy to use with Autoit. Probably one of the larger benefits is that it supports more image types than GDIPlus. BTW: Tested UEZ code above and it worked really well.
    1 point
  6. @AutoBert @PPI try this: #include <File.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> _GDIPlus_Startup() Global Const $hGUI = GUICreate("Test", 384, 120) Global Const $iBtn_Path = GUICtrlCreateButton("Path", 10, 10, 70, 40) Global Const $iInput_Path = GUICtrlCreateInput("", 90, 20, 160, 20) GUICtrlSetState(-1, $GUI_DISABLE) Global Const $iCombo_Ext = GUICtrlCreateCombo("JPG", 270, 20, 100, 21) GUICtrlSetData($iCombo_Ext, "BMP|PNG", "JPG") Global Const $iLabel_X = GUICtrlCreateLabel("X:", 20, 80, 20, 10) Global Const $iInput_X = GUICtrlCreateInput("0", 40, 76, 30, 20, $ES_NUMBER) Global Const $iLabel_Y = GUICtrlCreateLabel("Y:", 80, 80, 20, 10) Global Const $iInput_Y = GUICtrlCreateInput("0", 100, 76, 30, 20, $ES_NUMBER) Global Const $iLabel_W = GUICtrlCreateLabel("W:", 140, 80, 20, 10) Global Const $iInput_W = GUICtrlCreateInput("0", 160, 76, 30, 20, $ES_NUMBER) Global Const $iLabel_H = GUICtrlCreateLabel("H:", 200, 80, 20, 10) Global Const $iInput_H = GUICtrlCreateInput("0", 220, 76, 30, 20, $ES_NUMBER) Global Const $iBtn_Start = GUICtrlCreateButton("Start", 290, 60, 70, 40) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() Global $sPath, $aFiles, $i, $iX, $iY, $iW, $iH While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GDIPlus_Shutdown() GUIDelete() Exit Case $iBtn_Path $sPath = FileSelectFolder("Select a path with images", "", 0, $hGUI) If @error Then MsgBox($MB_ICONWARNING, "Warning", "Operation has been aborted", 20, $hGUI) ContinueLoop EndIf GUICtrlSetState($iBtn_Start, $GUI_ENABLE) GUICtrlSetData($iInput_Path, $sPath) Case $iBtn_Start $aFiles = _FileListToArray($sPath, "*." & GUICtrlRead($iCombo_Ext), $FLTA_FILES, True) If @error Then MsgBox($MB_ICONWARNING, "Warning", "Operation has been aborted", 20, $hGUI) ContinueLoop EndIf $iX = GUICtrlRead($iInput_X) $iY = GUICtrlRead($iInput_Y) $iW = GUICtrlRead($iInput_W) $iH = GUICtrlRead($iInput_H) If BitOR($iW = 0, $iH = 0) Then MsgBox($MB_ICONWARNING, "Warning", "Please check width / height", 20, $hGUI) ContinueLoop EndIf For $i = 1 To $aFiles[0] Crop_Images($iX, $iY, $iW, $iH, $aFiles[$i]) Next MsgBox($MB_ICONINFORMATION, "Done", "Please check out provided folder for the results", 0, $hGUI) EndSwitch WEnd Func Crop_Images($iX, $iY, $iW, $iH, $sFilename) If FileExists($sFilename) Then Local $hImage = _GDIPlus_ImageLoadFromFile($sFilename) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsDrawImageRectRect($hGfx, $hImage, $iX, $iY, $iW, $iH, 0, 0, $iW, $iH) _GDIPlus_ImageSaveToFile($hBitmap, StringTrimRight($sFilename, 4) & "_cropped.jpg") _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_ImageDispose($hImage) Return True EndIf Return False EndFunc
    1 point
  7. @UEZ: I know you are answering like this. @PPI: I'm wondering you haven't tools your are needing for work. Or is this a small, private virtual ATC?
    1 point
  8. Your task can be easily done using GDIPlus rather than automating MS Paint. Give me some minutes to write a basic version.
    1 point
  9. No when the image you searching isn't on screen ImageSearch could find it because there is no image.
    1 point
  10. @mrubin: bit of a late rejoinder on my part, because these days I tend to catch up with forum discussions mainly during extended breaks from work (which is part of the point I'd like to make. From your remarks so far I get the impression that your interpretation of how this community works is a little off (which is totally understandable, of course, since you've only just joined). I know the Boost template libraries; I use them myself, and I have the greatest respect for its systematic approach and rigorous testing cycles. But that's just not the way things work around here. We have about 65K members in the English-language forum alone (with partial overlap in other-language AutoIt forums), with a huge diversity in skills and expertise. Moreover, some of the most gifted and/or productive contributors are not necessarily professional software engineers at all, but maybe work in music production, or graphic design, or academia, or turn out to be teenagers still in school. Part of what makes this environment so stimulating, surprising, multi-faceted, and (at times) inspiring is that broad mix of talents and backgrounds. But you simply cannot expect people that have day jobs completely unrelated to their voluntary software-developmental activiities in their spare time to be subjected to the kind of versioning control, unit testing, refactoring, and repository maintenance regimes that you propose. New (versions of) particular UDFs will appear if and when people discover/fix bugs, or require new functionality themselves, or just because it can be done, or it seems like a fun or cool challenge, but not because the latest compiler for platform X suddenly throws a fit, or UDF A by member B does not play nice with UDF C by member D. Everybody can make their own building blocks that may or may not be useful to others; some are ten lines long, some are ten thousand. When I write a dll, I do provide the source, but other people may not, and that's okay, because it's up to other users to decide whether they want to go the provided route or use something else, or develop their own ideas, or take existing ones in new directions (check out how many different IPC solutions have been proposed by various people, for example). My point is, that freedom of how and when and where to contribute (if at all) is very much part of the appeal, and also helps to create an unusually generous atmosphere among many members. Spend some time on the example scripts forum, and you'll see many posts by first-time comtributors saying something like: "I wanted to give something back." If you were to subject that impulse to stringent formatting and compatibility requirements, I reckon you'd get a mere fraction of the breadth of contributions we now see. UDF standards are available for those that want theirs to become part of the AutoIt core (e.g., Yashied's phenomenal _WInAPIex contributions, for example), but personally, I wouldn't have made any contribution myself if I'd have to comply with those standards, yet I know my (somewhat idiosyncratic) codes are useful to some, and positive feedback is part of what makes it worthwhile. None of this is to be taken as criticism of your point of view, but I wanted to highlight that the my perspective from here is a little different from the Boost environment one. If you stick around, you may come to enjoy it too.
    1 point
  11. Thanks Manadar for your replay well, here a very primitive attempt (primitive but at least it works) to achieve the purpose (just a proof of concept). in short: added a new "Case" to the Switch $sFileType to catch .ha3 filetypes added _parseSource() at bottom added _ExecuteScript() at bottom For who wants to try: Save the modified server script and the 2 "web pages" in the same directory, run the server open a web browser and enter as address the IP of the machine where the server is running (a very basic page will open) click on the only link and a second page with embedded Autoit code will be parsed on the server and opened on the client. modified Basic_Server save it as Server.au3 #cs Resources: Internet Assigned Number Authority - all Content-Types: http://www.iana.org/assignments/media-types/ World Wide Web Consortium - An overview of the HTTP protocol: http://www.w3.org/Protocols/ Credits: Manadar for starting on the webserver. Alek for adding POST and some fixes Creator for providing the "application/octet-stream" MIME type. #ce ; // OPTIONS HERE // Local $sRootDir = @ScriptDir ; & "\www" ; The absolute path to the root directory of the server. Local $sIP = @IPAddress1 ; ip address as defined by AutoIt Local $iPort = 80 ; the listening port Local $sServerAddress = "http://" & $sIP & ":" & $iPort & "/" Local $iMaxUsers = 15 ; Maximum number of users who can simultaneously get/post Local $sServerName = "ManadarX/1.1 (" & @OSVersion & ") AutoIt " & @AutoItVersion ; // END OF OPTIONS // Local $aSocket[$iMaxUsers] ; Creates an array to store all the possible users Local $sBuffer[$iMaxUsers] ; All these users have buffers when sending/receiving, so we need a place to store those For $x = 0 To UBound($aSocket) - 1 ; Fills the entire socket array with -1 integers, so that the server knows they are empty. $aSocket[$x] = -1 Next TCPStartup() ; AutoIt needs to initialize the TCP functions $iMainSocket = TCPListen($sIP, $iPort) ;create main listening socket If @error Then ; if you fail creating a socket, exit the application MsgBox(0x20, "AutoIt Webserver", "Unable to create a socket on port " & $iPort & ".") ; notifies the user that the HTTP server will not run Exit ; if your server is part of a GUI that has nothing to do with the server, you'll need to remove the Exit keyword and notify the user that the HTTP server will not work. EndIf ConsoleWrite("Server created on " & $sServerAddress & @CRLF) ; If you're in SciTE, While 1 $iNewSocket = TCPAccept($iMainSocket) ; Tries to accept incoming connections If $iNewSocket >= 0 Then ; Verifies that there actually is an incoming connection For $x = 0 To UBound($aSocket) - 1 ; Attempts to store the incoming connection If $aSocket[$x] = -1 Then $aSocket[$x] = $iNewSocket ;store the new socket ExitLoop EndIf Next EndIf For $x = 0 To UBound($aSocket) - 1 ; A big loop to receive data from everyone connected If $aSocket[$x] = -1 Then ContinueLoop ; if the socket is empty, it will continue to the next iteration, doing nothing $sNewData = TCPRecv($aSocket[$x], 1024) ; Receives a whole lot of data if possible If @error Then ; Client has disconnected $aSocket[$x] = -1 ; Socket is freed so that a new user may join ContinueLoop ; Go to the next iteration of the loop, not really needed but looks oh so good ElseIf $sNewData Then ; data received $sBuffer[$x] &= $sNewData ;store it in the buffer If StringInStr(StringStripCR($sBuffer[$x]), @LF & @LF) Then ; if the request has ended .. $sFirstLine = StringLeft($sBuffer[$x], StringInStr($sBuffer[$x], @LF)) ; helps to get the type of the request $sRequestType = StringLeft($sFirstLine, StringInStr($sFirstLine, " ") - 1) ; gets the type of the request If $sRequestType = "GET" Then ; user wants to download a file or whatever .. $sRequest = StringTrimRight(StringTrimLeft($sFirstLine, 4), 11) ; let's see what file he actually wants If StringInStr(StringReplace($sRequest, "\", "/"), "/.") Then ; Disallow any attempts to go back a folder ;;~ _HTTP_SendError($aSocket[$x]) ; sends back an error _HTTP_SendFileNotFoundError($aSocket[$x]) ; sends back an error Else If $sRequest = "/" Then ; user has requested the root $sRequest = "/index.html" ; instead of root we'll give him the index page EndIf $sRequest = StringReplace($sRequest, "/", "\") ; convert HTTP slashes to windows slashes, not really required because windows accepts both If FileExists($sRootDir & "\" & $sRequest) Then ; makes sure the file that the user wants exists $sFileType = StringRight($sRequest, 4) ; determines the file type, so that we may choose what mine type to use Switch $sFileType ; -- just a pre alpha "proof of concept" ----------------------------------------- Case ".ha3" ; just for example extension .ha3 could be used -> (h)tml (a)utoit(3) $hFile = FileOpen($sRootDir & "\" & $sRequest);, 16) ; read file of web page $bFileData = FileRead($hFile) FileClose($hFile) ; now use _parseSource() to extract and execute embedded AutoIt code ; and then send result to client's browser _HTTP_SendData($aSocket[$x], _parseSource($bFileData), "text/html") ; ---------------------------------------------------------------------------- Case "html", ".htm" ; in case of normal HTML files _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "text/html") Case ".css" ; in case of style sheets _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "text/css") Case ".jpg", "jpeg" ; for common images _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "image/jpeg") Case ".png" ; another common image format _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "image/png") Case Else ; this is for .exe, .zip, or anything else that is not supported is downloaded to the client using a application/octet-stream _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "application/octet-stream") EndSwitch Else _HTTP_SendFileNotFoundError($aSocket[$x]) ; File does not exist, so we'll send back an error.. EndIf EndIf EndIf $sBuffer[$x] = "" ; clears the buffer because we just used to buffer and did some actions based on them $aSocket[$x] = -1 ; the socket is automatically closed so we reset the socket so that we may accept new clients EndIf EndIf Next Sleep(10) WEnd Func _HTTP_ConvertString(ByRef $sInput) ; converts any characters like %20 into space 8) $sInput = StringReplace($sInput, '+', ' ') StringReplace($sInput, '%', '') For $t = 0 To @extended $Find_Char = StringLeft(StringTrimLeft($sInput, StringInStr($sInput, '%')), 2) $sInput = StringReplace($sInput, '%' & $Find_Char, Chr(Dec($Find_Char))) Next EndFunc ;==>_HTTP_ConvertString Func _HTTP_SendHTML($hSocket, $sHTML, $sReply = "200 OK") ; sends HTML data on X socket _HTTP_SendData($hSocket, Binary($sHTML), "text/html", $sReply) EndFunc ;==>_HTTP_SendHTML Func _HTTP_SendFile($hSocket, $sFileLoc, $sMimeType, $sReply = "200 OK") ; Sends a file back to the client on X socket, with X mime-type Local $hFile, $sImgBuffer, $sPacket, $a ConsoleWrite("Sending " & $sFileLoc & @CRLF) $hFile = FileOpen($sFileLoc, 16) $bFileData = FileRead($hFile) FileClose($hFile) _HTTP_SendData($hSocket, $bFileData, $sMimeType, $sReply) EndFunc ;==>_HTTP_SendFile Func _HTTP_SendData($hSocket, $bData, $sMimeType, $sReply = "200 OK") $sPacket = Binary("HTTP/1.1 " & $sReply & @CRLF & _ "Server: " & $sServerName & @CRLF & _ "Connection: close" & @CRLF & _ "Content-Lenght: " & BinaryLen($bData) & @CRLF & _ "Content-Type: " & $sMimeType & @CRLF & _ @CRLF) TCPSend($hSocket, $sPacket) ; Send start of packet While BinaryLen($bData) ; Send data in chunks (most code by Larry) $a = TCPSend($hSocket, $bData) ; TCPSend returns the number of bytes sent $bData = BinaryMid($bData, $a + 1, BinaryLen($bData) - $a) WEnd $sPacket = Binary(@CRLF & @CRLF) ; Finish the packet TCPSend($hSocket, $sPacket) TCPCloseSocket($hSocket) EndFunc ;==>_HTTP_SendData Func _HTTP_SendFileNotFoundError($hSocket) ; Sends back a basic 404 error Local $s404Loc = $sRootDir & "\404.html" If (FileExists($s404Loc)) Then _HTTP_SendFile($hSocket, $s404Loc, "text/html") Else _HTTP_SendHTML($hSocket, "404 Error: " & @CRLF & @CRLF & "The file you requested could not be found.") EndIf EndFunc ;==>_HTTP_SendFileNotFoundError ; --- new pre alpha test functions --------------- ; ; following function grabbed from AuCGI.au3 ; from here: http://www.autoitscript.com/forum/topic/111133-autoit-cgi-handler-aucgi/ ; by Erik Pilsits (wraithdu), and Josh Rowe (JRowe) ; original author Matt Roth (theguy0000) <theguy0000@gmail.com> ; (slightly modified by me) ; ; parse source for <?au3 ?> code Func _parseSource($source) Local $idx = 1, $idx2, $lastidx = 1, $parsed = "", $chunk = "" Do ; get first code snippet $idx = StringInStr($source, "<?au3", 0, 1, $idx) ; position of "<?au3" in $idx If $idx Then If $idx > $lastidx Then ; we have html $chunk = StringMid($source, $lastidx, $idx - $lastidx) ; get it (get html) $parsed &= $chunk ;~ _splitHTML($chunk) ; write it to $parsed EndIf $idx += 5 ; start of code ; get end of code tag $idx2 = StringInStr($source, "?>", 0, 1, $idx) If $idx2 Then ; found end of code --------------------------------------------------------------+ $chunk = StringMid($source, $idx, $idx2 - $idx) ; get it (portion of AutoIt code) | ; --- execute autoit code and get back result --- | $chunk = _ExecuteScript($chunk) ; | $parsed &= $chunk & @CRLF ; | $lastidx = $idx2 + 2 ; new $lastidx value, set to position after end-code tag | $idx = $lastidx ; next search start location -------------------------------------+ Else ; parse error, get out ConsoleWrite("Error parsing source.") EndIf Else ; no code sections or last section of html $chunk = StringMid($source, $lastidx) ; get it (html) If $chunk Then $parsed &= $chunk ;~ _splitHTML($chunk) ; check we actually have something this time, write it EndIf Until Not $idx Return $parsed EndFunc ;==>_parseSource ; following function is by trancexx (slightly modified by me) ; from here: http://www.autoitscript.com/forum/topic/82461-how-to-get-access-for-a3x-encoded-files/?p=590906 Func _ExecuteScript($code) Local $return Local $TypeLib = ObjCreate("Scriptlet.TypeLib") Local $tmp = @TempDir & "\~" & $TypeLib.Guid & "tempexec.tmp" Local $hwnd = FileOpen($tmp, 26) FileWrite($hwnd, $code) FileClose($hwnd) $pid = Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $tmp & '"', "", "", 0x2) ; 0x2 ($STDOUT_CHILD) Do $return = StdoutRead($pid) Sleep(50) Until $return <> "" FileDelete($tmp) Return $return ; EndFunc ;==>_ExecuteScript First html page, save it in the same directory of the server as index.html <!DOCTYPE html> <html> <body> <a href="index.ha3">Try a web page with AutoiT code embedded!</a> </body> </html> Second html page with AutoIt code embedded. Save it in the same directory of the server as index.ha3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <?au3 $echo = "<br></br>" $echo &= "Hello World - from Manadar's web Server" $echo &= "<br></br>" $echo &= "Sever hosted on " & @ComputerName $echo &= "<br></br>" $echo &= "Server architecture is:" & "<br></br>" $echo &= "CPUArch: " & @CPUArch & "<br></br>" $echo &= "OSArch: " & @OSArch & "<br></br>" $echo &= "OSType: " & @OSType & "<br></br>" $echo &= "OSVersion: " & @OSVersion & "<br></br>" ConsoleWrite($echo) ?> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>Test</title> </head> <body> <?au3 $echo = "<br></br>" $echo &= "Server date is " & @MON & "/" & @MDAY & "/" & @YEAR $echo &= "<br></br>" $echo &= "Server Time is " & @HOUR & ":" & @MIN & ":" & @SEC ConsoleWrite($echo) ?> </body> </html>
    1 point
  12. Cue

    Swap mouse buttons

    Thats what I searched for and got alot of threads I skimmed through most that sounded relavent and didt find anything. Nevermind
    1 point
×
×
  • Create New...