Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/22/2015 in all areas

  1. wakillon

    PostStampBuilder

    Create Postage Stamp from any images. Transparency is preserved around serrated edges for permit to paste stamp. Downloads are available in the download section Hope you like it ! Edit : The glue is not supplied with the stamp!
    2 points
  2. The map data type is available in many popular programming languages, and has certain uses that traditional arrays aren't quite as suited-for, especially in an interpreted language such as AutoIt. You can emulate maps using traditional arrays without too much hassle, but in interpreted languages, performance can suffer quite a bit. Comparing the performance of arrays to maps is a bit of an apples-to-oranges comparison, as a traditional array can't do things maps can do. Because of this, I've written a little benchmark that runs on the latest beta version of AutoIt (3.3.15.0 at the time of writing). It uses a 2d array to create a case-sensitive key/value store. If you add data to a key that does not exist, that key is created with the data it was supposed to be assigned. Basically, it's using 2d arrays to create fakes of the new native map type. Native maps can usually handle enormous amounts of key/value pairs and still be very fast at modifying or reading the data in them. AutoIt's new maps are no exception, either! CLARIFICATION: Please understand that this benchmark is NOT comparing the performance of arrays to the performance of maps. The two serve different purposes, and if you put arrays versus maps in a fair benchmark, arrays will be faster. This is true for pretty much any programming language. This benchmark is comparing the methods available for doing a native, dynamically-sized, in-memory key/value store. In the current stable release of AutoIt, the only way to do this without relying on external COM objects (Scripting.Dictionary) is to use a dynamically-sized two-dimensional array. (Or two one-dimensional dynamically-sized arrays, but we'll not get into that as there's not really a good reason to do that over a two-dimensional one.) In the current beta of AutoIt, the map type allows for exactly that, without all of the boilerplate code needed to implement them, as well as a huge speed increase to them since the heavy lifting is being done internally in the interpreter as opposed to being done in AutoIt. One of the key features of this data type is that the amount of things it can store is not a fixed size. This means the more stuff you want to add, the bigger it will grow. The more things you delete from it, the smaller it shrinks. If you need to iterate over a map, it won't have to waste time running through, for example, 9,975 blank entries just to read the 25 populated entries like you would with a 10,000-element fixed-size array. For those saying that this benchmark is not fair to arrays and that there's a more efficient way to do it so they end up doing much better in the benchmark: I know, this isn't meant to be "arrays vs. maps", it's meant to be "fake maps vs. native maps". There's also some optimization that can be done with my FakeMap code, because ReDim is actually pretty slow, but adding that would make the example code harder to read while the end result would still be the same. The benchmark creates a specified number of elements randomly, and sets their values to a random number as well. It then creates one last element and reads that last element's data and prints it into the console. It also prints out the times that each step took, in milliseconds. So, here is the result of these basic benchmarks: 1000+1 elements: Fake map population time (1000 random elements): 1251.122ms Fake map new element 1001 time: 2.022ms Read data: Hello, World! Fake map read element 1001 time: 1.12ms Real map population time (1000 random elements): 2.489ms Real map new element 1001 time: 0.01ms Read data: Hello, World! Real map read element 1001 time: 0.01msSo from here, you can see that with only 1000 elements, the fake map took over 1.2 seconds to create 1000 new elements, 2ms to add the 1001st element, and then another 1ms to read that 1001st element. The native map only took about 2.5ms to create the first 1000 elements, and 0.1ms to create and read the 1001st. Wow! Here's that same benchmark, but instead of 1,000, we'll bump it up to 10,000! Fake map population time (10000 random elements): 123555.641ms Fake map new element 10001 time: 21.328ms Read data: Hello, World! Fake map read element 10001 time: 11.637ms Real map population time (10000 random elements): 27.36ms Real map new element 10001 time: 0.014ms Read data: Hello, World! Real map read element 10001 time: 0.014msTwo minutes for 10,000 new elements in the fake map? Yikes! As you can also see, although the fake map gets exponentially slower with each order of magnitude we go up, the native maps stay fairly consistent still, even at 10,000. At this scale, the amount of time calls to Random() take starts to show. But what if we go further? Let's say... 1,000,000 elements. For obvious reasons, I won't run the fake map code with this many elements, otherwise we'd be here until this time next year waiting for the results... But here is what happens when we have a 1-million-element map, and add one more on to it, then read it back: Real map population time (1000000 random elements): 24357.752ms Real map new element 1000001 time: 0.063ms Read data: Hello, World! Real map read element 1000001 time: 0.029msAs we can see, the two million calls made to Random() certainly did a number on that run time, weighing in at just over 24 seconds. We can safely assume that most of that 24 seconds was spent just generating random numbers because... Adding another element on top of that, then reading it back, is still incredibly fast, given how much data there is, at around 60 microseconds (that's 1/1000th of one millisecond!) to add a new value, and around 30 microseconds to read it back. Even more wow! The code used for this back-of-the-napkin basic benchmark: Global $FakeMap = MapCreate() Global $Map[] Global $t Global $TestSize = 1000 #Region Fake map benchmarking $t = TimerInit() For $i = 1 To $TestSize MapSet($FakeMap, Random(1, 1000000, 1), Random(1, 1000000, 1)) Next ConsoleWrite("Fake map population time (" & $TestSize & " random elements): " & Round(TimerDiff($t), 3) & "ms" & @CRLF) $t = TimerInit() MapSet($FakeMap, "asdf", "Hello, World!") ConsoleWrite("Fake map new element " & ($TestSize + 1) & " time: " & Round(TimerDiff($t), 3) & "ms" & @CRLF) $t = TimerInit() ConsoleWrite("Read data: " & MapRead($FakeMap, "asdf") & @CRLF) ConsoleWrite("Fake map read element " & ($TestSize + 1) & " time: " & Round(TimerDiff($t), 3) & "ms" & @CRLF) #EndRegion #Region Real/native map benchmarking $t = TimerInit() For $i = 1 To $TestSize $Map[Random(1, 1000000, 1)] = Random(1, 1000000, 1) Next ConsoleWrite("Real map population time (" & $TestSize & " random elements): " & Round(TimerDiff($t), 3) & "ms" & @CRLF) $t = TimerInit() $Map["asdf"] = "Hello, World!" ConsoleWrite("Real map new element " & ($TestSize + 1) & " time: " & Round(TimerDiff($t), 3) & "ms" & @CRLF) $t = TimerInit() ConsoleWrite("Read data: " & $Map["asdf"] & @CRLF) ConsoleWrite("Real map read element " & ($TestSize + 1) & " time: " & Round(TimerDiff($t), 3) & "ms" & @CRLF) #EndRegion #Region Wrapper functions to emulate map support for this test Func MapCreate() Local $aMap[1][2] $aMap[0][0] = 0 Return $aMap EndFunc Func MapRead($aMap, $sKey) For $i = 1 To UBound($aMap, 1) - 1 If $aMap[$i][0] == $sKey Then Return $aMap[$i][1] Next Return SetError(1, 0, "") EndFunc Func MapSet(ByRef $aMap, $sKey, $vVal) For $i = 1 To UBound($aMap, 1) - 1 If $aMap[$i][0] == $sKey Then $aMap[$i][1] = $vVal Return EndIf Next Local $iSize = UBound($aMap, 1) ReDim $aMap[$iSize + 1][2] $aMap[$iSize][0] = $sKey $aMap[$iSize][1] = $vVal $aMap[0][0] = $iSize EndFunc #EndRegion
    2 points
  3. What is NetFlare Web Server? NetFlare is a standalone web server written in pure AutoIt3 with some features: Virtual Hosts Server-side scripting For testing virtual host capability, editing etchosts file is required in most cases. File: C:WindowsSystem32driversetchosts 127.0.0.1 this.is.my.dom 127.0.0.1 private.mycompany.com Souce code (Daemon Main): #include "./Lib/Net/Http/HttpServer.au3" #include "./Lib/IO/Console.au3" _Main() Func _Main() HttpServer_SetPort(80) HttpServer_RegisterHost("this.is.my.dom") HttpServer_RegisterHost("private.mycompany.com", @ScriptDir & "\WebRoot\custompath\deeper\private.mycompany.com") ConsoleWrite("NetFlare Web Server 0.2, By Dhilip89" & @CRLF & @CRLF) ConsoleWrite("Registered virtual hosts: " & @CRLF) $HostList = HttpServer_GetRegisteredHosts() For $i = 0 To HttpServer_CountRegisteredHosts() - 1 ConsoleWrite("[" & $i+1 & "] " & $HostList[$i] & @CRLF) Next HttpServer_Start() ConsoleWrite(@CRLF & "Server is running..." & @CRLF) While 1 Sleep(1000) WEnd EndFunc - Screenshots (0.2): Screenshots (0.3): Animated GIF (Stress testing, using meta refresh): <= Click or download to view Download Links: (Version 0.1): http://www.mediafire.com/download/an1gngni6qeh5x9/NetFlare_v0.1.zip (Version 0.2): http://www.mediafire.com/download/3a88m1sgyrth48a/NetFlare_v0.2.zip (Version 0.3): http://www.mediafire.com/download/q3prydlbkygl7jd/NetFlare_v0.3.zip
    1 point
  4. This may be a question for @Jos ... I added some user functions to Scite with the User CallTip Manager (very awesome by the way). Everything works great. However, I have a regrettably large list of parameters for some functions (unavoidable because it is an integration to another tech). Because the list is so long I can't see it all in the auto-complete tooltip, Is there a way to wrap that tooltip text?
    1 point
  5. Just add a \n at the place you want a newline to show. Jos
    1 point
  6. mikell

    Script exits immediatly.

    Except patience... please be patient ASAP
    1 point
  7. ctrl + t Tides code and appends function names. tidy.exe does it.
    1 point
  8. iamtheky

    Help with xcopy

    in the 'working example' they dont have a trailing backslash. try it with run("cmd /k xcopy " .....) and see if we can get an output?
    1 point
  9. Bowmore

    Help with xcopy

    This is the way to do it. #include <Process.au3> ;Makes sure that you can use _RunDos statements $FolderA = @AppDataDir & "\Microsoft\FolderA\" $FolderB = @AppDataDir & "\Microsoft\FolderB\" _RunDOS("xcopy " & $FolderA & " " & $FolderB & " /E /I")
    1 point
  10. czardas

    _ArrayUniqueR

    Good result for Liverpool on Saturday!
    1 point
  11. JohnOne

    _ArrayUniqueR

    Nope, I live next door to the beatles.
    1 point
  12. trancexx

    _ArrayUniqueR

    ...Yea, obviously you aren't from Manchester.
    1 point
  13. trancexx

    _ArrayUniqueR

    JohnOne, he's not checking if the $sName is or isn't declared. He's checking if the value held by $sName is declared.
    1 point
  14. You have to specify the name of the include file regardless if the path is absolute or relative, both of which are allowed.
    1 point
  15. Why not work with HotKeySet() in your script in stead of using the SciTE interrupt ? Jos
    1 point
  16. Did you try #include "..\Script-to-be-included.au3"
    1 point
  17. UEZ

    PostStampBuilder

    For me the transparency is working properly. You are replacing the color with transarent color using regex which takes "a long time" for bigger images. I added a way which takes some milliseconds using _GDIPlus_ImageAttributesSetRemapTable()Example: Func _PostStampCreateRoundSerration ( $hImage ) Local Const $hBmp = _GDIPlus_BitmapCreateFromScan0( $iGuiWidth, $iGuiHeight ) Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext( $hBmp ) ;~ _GDIPlus_GraphicsClear( $hCtxt, $SerratedEdgeColor ) _GDIPlus_GraphicsFillRect( $hCtxt, 0, 0, $iGuiWidth, $iGuiHeight, $hTexture_Paper ) Local $hBrush = _GDIPlus_BrushCreateSolid ( 0xFFABCDEF ) Local $hPath = _GDIPlus_PathCreate() For $i = 0 To $iHCount -1 ; top & bottom _GDIPlus_PathAddArc ( $hPath, $iHWidth*( 1+3*$i )/2, -$iHWidth/2, $iHWidth, $iHWidth, 0, 180 ) ; _GDIPlus_PathAddArc or _GDIPlus_PathAddPie _GDIPlus_PathCloseFigure ( $hPath ) _GDIPlus_PathAddArc ( $hPath, $iHWidth*( 1+3*$i )/2, $iGuiHeight -$iHWidth/2, $iHWidth, $iHWidth, 180, 180 ) _GDIPlus_PathCloseFigure ( $hPath ) _GDIPlus_GraphicsFillPath ( $hCtxt, $hPath, $hBrush ) Next For $i = 0 To $iVCount -1 ; Left & right _GDIPlus_PathAddArc ( $hPath, -$iVWidth/2, $iVWidth*( 1+3*$i )/2, $iVWidth, $iVWidth, 270, 180 ) _GDIPlus_PathCloseFigure ( $hPath ) _GDIPlus_PathAddArc ( $hPath, $iGuiWidth -$iVWidth/2, $iVWidth*( 1+3*$i )/2, $iVWidth, $iVWidth, 90, 180 ) _GDIPlus_PathCloseFigure ( $hPath ) _GDIPlus_GraphicsFillPath ( $hCtxt, $hPath, $hBrush ) Next Local Const $hIA = _GDIPlus_ImageAttributesCreate() Local $aRemapTable[2][2] $aRemapTable[0][0] = 1 $aRemapTable[1][0] = 0xFFABCDEF $aRemapTable[1][1] = 0x00000000 _GDIPlus_ImageAttributesSetRemapTable($hIA, 1, True, $aRemapTable) _GDIPlus_GraphicsDrawImageRectRect ( $hGfx_Buffer, $hBmp, 0, 0, $iGuiWidth, $iGuiHeight, 0, 0, $iGuiWidth, $iGuiHeight, $hIA ) _GDIPlus_GraphicsDrawImageRectRect ( $hGfx_Buffer, $hImage, 0, 0, $iImageWidth, $iImageHeight, $iHWidth, $iVWidth, $iImageWidth, $iImageHeight ) _GDIPlus_PathDispose ( $hPath ) _GDIPlus_BrushDispose ( $hBrush ) _GDIPlus_ImageAttributesDispose( $hIA ) _GDIPlus_GraphicsDispose( $hCtxt ) _GDIPlus_BitmapDispose( $hBmp ) EndFunc ;==> _PostStampCreateRoundSerration()And as I said you can add an option to switch to color instead of texture background mode which should give a paper look rather than a flat white. If you comment out _GDIPlus_GraphicsFillRect( $hCtxt, 0, 0, $iGuiWidth, $iGuiHeight, $hTexture_Paper )and enable _GDIPlus_GraphicsClear( $hCtxt, $SerratedEdgeColor )the serrated edges color again. Here the result of an image which has transparency:
    1 point
  18. The default is: #define the number of backup files you want to keep 0=none backup.files=0 A versioncontrol option is build-in into AutoIt3wrapper including the explanation how to set it up in the helpfile. There should not be much stopping you from using it. Realize it is "water under the bridge" for this file though. Jos
    1 point
  19. STaufa

    PDF password protect

    Thank you for the help. I've managed to do it in C#, I just had to include PDFSharp library http://pdfsharp.com/PDFsharp/ Here's what I did (It worked perfectly) static void Main(string[] args) { FileSystemWatcher watcher = new FileSystemWatcher(); watcher.Path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\documents\"; watcher.Filter = "*.pdf"; watcher.IncludeSubdirectories = true; watcher.Created += new FileSystemEventHandler(fw_Created); watcher.EnableRaisingEvents = true; System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite); } static void fw_Created(object sender, FileSystemEventArgs e) { string path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\documents"; PdfDocument document = PdfReader.Open(path + "\\" + e.Name, ""); PdfSecuritySettings securitySettings = document.SecuritySettings; // Setting one of the passwords automatically sets the security level to // PdfDocumentSecurityLevel.Encrypted128Bit. //securitySettings.UserPassword = "yourUserPassword"; securitySettings.OwnerPassword = "yourOwnerPassword"; // Don't use 40 bit encryption unless needed for compatibility reasons //securitySettings.DocumentSecurityLevel = PdfDocumentSecurityLevel.Encrypted40Bit; // Restrict some rights. securitySettings.PermitAccessibilityExtractContent = false; securitySettings.PermitAnnotations = false; securitySettings.PermitAssembleDocument = false; securitySettings.PermitExtractContent = false; securitySettings.PermitFormsFill = false; securitySettings.PermitFullQualityPrint = false; securitySettings.PermitModifyDocument = false; securitySettings.PermitPrint = false; // Save the document... document.Save(path + "\\" + e.Name); }
    1 point
  20. JohnOne

    PDF password protect

    Show how you do it once.
    1 point
  21. #include <IE.au3> Const $ie_new_in_tab=0x0800 $oIE = _IECreate("http://www.autoitscript.com") $oIE.Navigate("http://www.autoitscript.com/forum/", $ie_new_in_tab) $oIE2 = _IEAttach("http://www.autoitscript.com/forum/", "url") _IEQuit($oIE2)
    1 point
  22. If you just want it to save, and you don't need the stupid file dialog, you can say: InetGet(TheURLofTheSite, AFilenameYouSaveItAs) J
    1 point
×
×
  • Create New...