Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/17/2017 in all areas

  1. Greg-H, I see you did not read those rules to which I linked very carefully - you missed the part that says: "Do not repost the same question if the previous thread has been locked - particularly if you merely reword the question to get around one of the prohibitions listed above" However, as this question does have some wider application (pun intended) I am prepared to let it run this time. But please do read those rules carefully and stick to them in future. M23
    2 points
  2. I had a need, and so I developed. Before I did that though, I did a quick search of the forum, and found a few things, but none seemed to suit what I really wanted ... though to be honest, I did not investigate them deeply or search extensively. In any case, I am not very good at modifying the code of others, nor do I enjoy doing so, so in the end I decided it was best to start from scratch ... re-inventing the wheel perhaps, but a wheel I feel a certain degree of comfort with. I also thought about Maps, but don't know enough. _IniString Functions (was Ini_InMem) Ini in memory Settings INI - Read/Write once to the disk INI File Processing Functions ... sure to be others. As with all my stuff, feel free to use (no guarantees) or modify ... just give me credit where due. I always go for the quick & simple approach, as those who know me here, are well aware, so without a doubt, my code could be improved - sped up, RegExp used, etc. So feel free to do that, and convert into a proper UDF, if you want, following best practices etc, as I am sure others will appreciate it. Recently, I have come upon a need to extract data from an approximately 50 Mb downloaded Index file, just extracting the few elements I need, and storing them in an INI file. It is quite a time consuming process, especially on my underpowered Netbook, which is where I am using the program I built. I have been considering ways to speed up things. Two good sounding methods, out of several possibles, have come to mind - 1) RAM Disk and 2) Virtual INI processing. That last being a better option, when sharing code (program) with others. Another method, which I am currently using, that did give me some measurable benefit, was to download the almost 50 Mb Index file in Stages (i.e. 30 x 1.4 Mb roughly), extracting data from each in turn. I have also considered extracting to 10 (or 11) separate INI files, rather than the single large INI file (4~5 Mb), as things noticeably slow up as the INI file increases in size ... obviously due to writing time. I can't really speed up the extraction process, but that last method may speed up the writing stage. However, it would require significant program changes, and perhaps not gain me much benefit. To complicate things, there are too many Section names (Index ID's) for the IniReadSectionNames command, so I have had to split them off into their own (read/write) line-by-line index file, and create code to deal with duplicates. When read, Index ID's and Titles populate a Listbox control in a user GUI. So at this point in time, it seems best to use the Virtual INI approach to gain a significant reduction in time taken. For my own specific use, with my slow Netbook, I may also use a RAM Disk. Due to the aforementioned INI issues, and lack of available specific data, probably because it is always program concentric, I have created an ASCII Checker program, which I guess you can say, is AutoIt concentric. Because others may also find it handy, I am providing it here. NOTE - As yet, I am only aware that Escape characters exist, but have not investigated or catered for them in any way. ASCII Checker.zip The Virtual_INI_UDF is still a work in progress, though I have done most of the functions now, with the working but incomplete _Ini_Test function, still requiring changes etc from the information gleaned by the ASCII Checker program. Here's something to play with meanwhile. Updated files (24th February 2017) Virtual_INI_UDF.au3 NEW Example.au3 (23rd February 2017) All pretty basic, but managed to load my 4 Mb INI file (seemingly ok, but took a few seconds) ... though I have only worked with much smaller testing ones so far. P.S. While I have done a fair amount of testing, it has been pretty basic, and mostly limited to the examples provided. Testing has definitely not been extensive.
    1 point
  3. water

    Map Array Read

    You need to extract the array, modify it and then re-assign it to the map: Local $json[] Local $map[] $map['test'] = 'hello' Local $array[5] = [1, 2, 3, 4, 5] $json["data"] = $map $json["data"]["arr"] = $array ConsoleWrite(($json["data"]["arr"])[1] & @CRLF) $aTemp = $json.data.arr $aTemp[1] = "X" $json.data.arr = $aTemp ConsoleWrite(($json["data"]["arr"])[1] & @CRLF)
    1 point
  4. water

    Map Array Read

    This works: Local $json[] Local $map[] $map['test'] = 'hello' Local $array[5] = [1, 2, 3, 4, 5] $json["data"] = $map $json["data"]["arr"] = $array ConsoleWrite(($json["data"]["arr"])[1] & @CRLF)
    1 point
  5. Try: Run(@ComSpec & ' /c start "" "ms-windows-store:"', '', @SW_HIDE)
    1 point
  6. Subz

    bin to dec help

    $sBin = '100001101110011111010011111000' MsgBox(0,'', _BinaryToDec($sBin)) Func _BinaryToDec($strBin) Local $Return Local $lngResult Local $intIndex If StringRegExp($strBin,'[0-1]') then $lngResult = 0 For $intIndex = StringLen($strBin) to 1 step -1 $strDigit = StringMid($strBin, $intIndex, 1) Select case $strDigit="0" ; do nothing case $strDigit="1" $lngResult = $lngResult + (2 ^ (StringLen($strBin)-$intIndex)) case else ; invalid binary digit, so the whole thing is invalid $lngResult = 0 $intIndex = 0 ; stop the loop EndSelect Next $Return = $lngResult Return $Return Else MsgBox(0,"Error","Wrong input, try again ...") Return EndIf EndFunc
    1 point
  7. water

    Select an Excel

    Welcome to AutoIt and the forum, You could use FileFindFirstFile and FileFindNextFile or _FileListToArray to get this information. Both support wildcards.
    1 point
  8. trancexx

    Subrogation

    You shouldn't. DllMain is always stdcall.
    1 point
  9. I made some tests on my computer to re-assign com1 to com2. I managed to do it though the registry. I understand how it works now, here is my explanation (I hope it will be clear enough). First, you have to get sufficient rigths in some registry keys (like HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter because you don't have enough rights to write in the key, even if you use an administrator account). In the above registry key, the value ComDB contains the list of the COM ports used by the system. On my computer its value is 0x0500000000000000000000000000000000000000000000000000000000000000 The binary value is made like this : - the first byte represents the state of use for COM1 To COM8 : on my computer, the value is 05 (or 0x05). In real binary it's equal to 00000101 (COM3 and COM1 used) - the next byte represents COM9 to COM16 and so on... So the first thing to do is to check if the desired port is used or not using this value : Local $ComDB = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter", "ComDB") Local $iLen = BinaryLen($ComDB) Local $iByte, $iPortNum, $iDec For $i = 1 To $iLen $iByte = BinaryMid($ComDB, $i, 1) For $j = 1 To 8 $iPortNum = ($i - 1) * 8 + $j $iDec = 1 * 2 ^ ($j - 1) If BitAND($iByte, $iDec) Then ConsoleWrite("Port " & $iPortNum & " used " & @CRLF) Next Next Next you will have to calculate the new ComDB value : set the old port number as not used and the new port number as used. For example, if you want to set COM2 and COM3 as used and COM1 as not used, the value in real binary will be 00000110 = 0x06. So the new ComDB value to write will be 0x0600000000000000000000000000000000000000000000000000000000000000 After that, you have to remove the registry value corresponding to the old port and add the new one in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports - add the COM2 value and set its value to the same than COM1 - remove the COM1 value if not used Next you will have to apply changes in - HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM\ : \Device\Serial0 - \Device\Serial0 - HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\ACPI\PNP0501\1 : FriendlyName (it's the PNDDeviceID found with the WMI query) - HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\ACPI\PNP0501\1\Device Parameters : PortName This is not trivial...
    1 point
  10. Hi All - Thanks for all the posts with code fixes and updates. I am looking to use this code again and I want to incorporate some of your suggestions, they look pretty good! I am going to try to use git and github to work on this code that way we can work on things together or when I am slacking off (which can happen for awhile) some one else can fork it and run with it. Below is the link. I just upload and compiled it to make sure it all works. I also post older version in case anybody wants those, but I have not tried compiling those yet, maybe I'll get to it this weekend. https://github.com/joeyb1275/ID3_UDF
    1 point
  11. zone97

    Self Update Module

    Here is a simple function I use to update my application loader. It looks for a file at 2 locations, if one is unavailable it uses a backup. Then creates a batch file, downloads the new file with a different name, loads the batch, ends the process of the original file, renames and reloads. All pretty seamless. Doesn't offer a progress bar, but happens so fast you wouldn't see it anyway. I'm sure it needs clean up and consolidation, but it works, so I've left it as is. Func Self_Update() If Not IsDeclared("update_path") Then Global $Path1 = FileGetShortName("\\network\path\to\updated\exe") Global $Path2 = FileGetShortName("c:\alernate\location\for\update\if\network\unavailable") If Not FileExists($Path1 & "\Application loader.exe") Then If Not FileExists($Path2 & "\Application loader.exe") Then MsgBox(48, "Update Error!", "Unable to locate an update file!") Else $Update_Path = $Path2 EndIf Else $Update_Path = $Path1 EndIf $NewVersion = FileGetVersion($Update_Path & "\Application loader.exe") $OldVersion = FileGetVersion(@ScriptFullPath) $Results = _StringCompareVersions($OldVersion, $NewVersion) If $Results = "-1" Then SplashTextOn("Updating Loader", "Please wait... This may take a few moments.", "400", "100", "-1", "-1", 50, "", "", "") Sleep(1000) FileCopy($Update_Path & "\Application loader.exe", @ScriptFullPath & ".new") Local $BatchPath = @ScriptDir & '\update.bat' $FileData = "@echo off" & @CRLF & _ "ping localhost -n 2 > nul" & @CRLF & _ ":loop" & @CRLF & _ 'del /Q "' & @ScriptFullPath & '"' & @CRLF & _ 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF & _ 'move "' & @ScriptFullPath & '.new" "' & @ScriptFullPath & '"' & @CRLF & _ 'start /B "Loading" "' & @ScriptFullPath & '"' & @CRLF & _ 'del /Q "' & $BatchPath & '"' & @CRLF & _ "exit" FileWrite($BatchPath, $FileData) FileSetAttrib($BatchPath, "+H") Run($BatchPath, "", @SW_HIDE) SplashOff() Write2Log("Updated Application to version " & $NewVersion) ; - write to log file, remove if you don't need this. Exit EndIf EndIf EndFunc ;==>Self_Update You will also need the attached UDF by @PeteF to make the version compare I use work. StringCompareVersions.au3
    1 point
  12. [NEW VERSION] - 16 Feb 17 Added: Ability to use a user-defined sort function in place of the standard _ArraySort when sorting columns - see _GUIListViewEx_UserSort. Changed: More edit modes possible - now can have standard text, numeric values with an UpDown control, a combo (either editable or read-only), a date picker, or if all these are not enough a user-defined function. See the _SetEditStatus function header to see how these are set. More options added to the _LoadHdrData function - but the size of the default array the function expects has increased as explained in the function header. Detecting the various events within the ListView has become easier with the introduction of the _EventMonitor function. This is placed in the idle loop and allows the user to detect edit, drag/drop and sort events which may need action. Additionally the function checks for redrawing events (very important if the ListViews are coloured) and shows any tooltips initiated by the UDF. Check out the examples to see how you need to structure the function and interpret its returns. The Guide file has been rewritten to explain all the new and amended functionalities - please take a moment to read through it as amending old scripts is not difficult but does require an understanding of what to change and how to change it. New UDF, examples and Guide file in the zip in the first post. M23
    1 point
  13. If you apply the multipliers, then you have to set #AutoIt3Wrapper_Res_HiDpi to "Y" and add _Metro_EnableHighDPIScaling() to the script so that Windows doesn't try to rescale the program as you would be doing that yourself. If you want to let Windows scale everything, then you just remove _Metro_EnableHighDPIScaling() and #AutoIt3Wrapper_Res_HiDpi=Y (or put it to N) from your code.
    1 point
  14. 1 point
  15. Version 4.0.1 - Changelog: Fixed bugs: Fullscreen toggle sends the GUI only to the first monitor and not the monitor that the window is on at the moment. Fullscreen toggle will cause the screen to not refresh properly on Windows 7. Windows 7 basic theme makes the GUI look strange with rounded corners on top. Windows 7 basic and classic theme will cause the first GUIs non-client arena(controlbar) to show up when a second GUI is minimized. Fullscreen toggle buttons arrow lines are not straight when using different DPI settings. Starting the script from within Scite Portable version will cause hover to not work anymore. Download: Let me know if you find any other bugs
    1 point
  16. http://sourceforge.net/projects/tvshowcountdown/
    1 point
  17. Thanks for this great work i have been looking for a proper JSON library for 2 days before i found this one! To show my thanks heres a little helper function addition, its purpose is to enable to query the json object in an easier way like "key1.key2", i hope this helps someone =) #include <Array.au3> #include "JSON.au3" #include "JSON_Translate.au3" ; examples of translator functions, includes JSON_pack and JSON_unpack Func _JSONGet($json, $path, $seperator = ".") Local $seperatorPos,$current,$next,$l $seperatorPos = StringInStr($path, $seperator) If $seperatorPos > 0 Then $current = StringLeft($path, $seperatorPos - 1) $next = StringTrimLeft($path, $seperatorPos + StringLen($seperator) - 1) Else $current = $path $next = "" EndIf If _JSONIsObject($json) Then $l = UBound($json, 1) For $i = 0 To $l - 1 If $json[$i][0] == $current Then If $next == "" Then return $json[$i][1] Else return _JSONGet($json[$i][1], $next, $seperator) EndIf EndIf Next ElseIf IsArray($json) And UBound($json, 0) == 1 And UBound($json, 1) > $current Then If $next == "" Then return $json[$current] Else return _JSONGet($json[$current], $next, $seperator) EndIf EndIf return $_JSONNull EndFunc ;create an json object to test Local $json = _JSONDecode('{"test":{"x":[11,22,{"y":55}]}}') ;query this object Local $result = _JSONGet($json, "test.x.2") ;query the previous result $result = _JSONGet($result, "y") ;output the result ConsoleWrite(_JSONIsNull($result) & @CRLF) ConsoleWrite($result & @CRLF & @CRLF) _ArrayDisplay($result) ;query this object using another seperator $result = _JSONGet($json, "test->x->2->y", "->") ;output the result ConsoleWrite(_JSONIsNull($result) & @CRLF) ConsoleWrite($result & @CRLF & @CRLF) ;query this object $result = _JSONGet($json, "test.x.2") ;output the result ConsoleWrite(_JSONIsNull($result) & @CRLF & @CRLF) _ArrayDisplay($result) ;query this object $result = _JSONGet($json, "test.non.existent.key") ;output the result ConsoleWrite(_JSONIsNull($result) & @CRLF) ConsoleWrite($result & @CRLF & @CRLF)
    1 point
×
×
  • Create New...