TheDcoder Posted August 28, 2019 Share Posted August 28, 2019 3 hours ago, jchd said: Also be aware that the Map datatype is deprecated. What!? When? Why? Was there any official annoucement? EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Developers Jos Posted August 28, 2019 Developers Share Posted August 28, 2019 (edited) 8 minutes ago, TheDcoder said: What!? When? Why? Was there any official annoucement? Quote from a statement made by Jon in a private forum: Quote Well IIRC Map is fundamentally broken due to the way variables work in AutoIt. So he won't be including it as it is, but it did stay in Beta for the moment. Don't hold your breath though to get this fixed and included. Jos Edited August 28, 2019 by Jos TheDcoder 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
TheDcoder Posted August 28, 2019 Share Posted August 28, 2019 3 hours ago, BrewManNH said: Use a scripting.dictionary instead for future proofing I agree @Inpho You may wrap scripting.dictionary like BrewManNH has suggested, you can use these functions as inspiration: _Map_DictObjectToMap _Map_MapToDictObject Inpho 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
TheDcoder Posted August 28, 2019 Share Posted August 28, 2019 @Jos Such a shame... oh well, AutoIt is already good enough with the current data types Definitely adding this to the ToDo list of my implementation of AutoIt for sure though. EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
BrewManNH Posted August 28, 2019 Share Posted August 28, 2019 Everything that can be done in Maps can be done in Scripting.Dictionary with the right wrappers. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
TheDcoder Posted August 28, 2019 Share Posted August 28, 2019 1 minute ago, BrewManNH said: Everything that can be done in Maps can be done in Scripting.Dictionary with the right wrappers. Agreed... still, having native support in the language would be a great feature to have EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Deye Posted September 8, 2019 Share Posted September 8, 2019 (edited) For kicks : #include <WinAPISysWin.au3> _UntrapGhostSysTrayIcons() Func _UntrapGhostSysTrayIcons() Local $aMPos = MouseGetPos(), $x = 1 Local $h = ControlGetHandle(_WinAPI_FindWindow('Shell_TrayWnd', ''), "", "[Class:SysPager]") Local $apos = WinGetPos($h) MouseMove($apos[0] + $apos[2], $apos[1] + 10, 0) Local $iRange = $apos[2] / 10 Do MouseMove($apos[0] + $apos[2] - $iRange, $apos[1] + 10, 11 - $x) $apos = WinGetPos($h) $x += 1 $iRange = ($apos[2] / 10) * $x Until $x > 10 MouseMove($apos[0] + $apos[2], $apos[1] + 10) MouseMove($aMPos[0], $aMPos[1], 0) EndFunc Edited September 8, 2019 by Deye Link to comment Share on other sites More sharing options...
argumentum Posted December 17, 2019 Share Posted December 17, 2019 (edited) #include <Date.au3> Func _StringFormatMs($ms, $bRetMs = False) ; based on https://www.autoitscript.com/forum/topic/163621-convert-ms-to-dayhourminsec/?do=findComment&comment=1192334 Local $sRetMs = "", $day = "", $hour, $min, $sec _TicksToTime($ms, $hour, $min, $sec) If $hour >= 24 Then $day = Int($hour / 24) $hour = Mod($hour, 24) EndIf If $bRetMs Then $sRetMs = "." & StringRight($ms, 3) Switch StringLen($day) Case 0 Return StringFormat("%02i:%02i:%02i", $hour, $min, $sec) & $sRetMs Case 1, 2, 3 Return StringFormat("%03i %02i:%02i:%02i", $day, $hour, $min, $sec) & $sRetMs Case Else Return $day & " " & StringFormat("%02i:%02i:%02i", $hour, $min, $sec) & $sRetMs EndSwitch EndFunc ;==>_StringFormatMs Millisecond to nice readable format. Edited December 17, 2019 by argumentum better code Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
argumentum Posted January 14, 2020 Share Posted January 14, 2020 ConsoleWrite(_GetTimeSinceLogon() & " seconds since Logon." & @CRLF) Func _GetTimeSinceLogon($sTimeDiffType = "s", $sUserName = @UserName, $sComputerName = @ComputerName) ; no AD, just local user Local $aRet = DllCall("netapi32.dll", "long", "NetUserGetInfo", "wstr", $sComputerName, "wstr", $sUserName, "dword", 11, "ptr*", 0) If @error Or $aRet[0] Then Return SetError(1, 0, False) Local $sSeconds = DllStructGetData(DllStructCreate("ptr;ptr;ptr;ptr;dword;dword;dword;ptr;ptr;dword;dword;dword;dword;ptr;dword;ptr;dword;dword;byte;dword", $aRet[4]), 10) DllCall("netapi32.dll", "long", "NetApiBufferFree", "ptr", $aRet[4]) Local $slastLogon = _DateAdd('s', Number($sSeconds), "1970/01/01 00:00:00") Local $aLastLogon = StringSplit($slastLogon, "/ :") ; take the UTC to local time Local $tSystem = _Date_Time_EncodeSystemTime($aLastLogon[2], $aLastLogon[3], $aLastLogon[1], $aLastLogon[4], $aLastLogon[5], $aLastLogon[6]) Local $tLocal = _Date_Time_SystemTimeToTzSpecificLocalTime($tSystem) $slastLogon = _Date_Time_SystemTimeToDateTimeStr($tLocal, 1) Local $sTimeDiff = _DateDiff($sTimeDiffType, $slastLogon, _NowCalc()) Return $sTimeDiff EndFunc ;==>_GetTimeSinceLogon (add #include as needed) Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Colduction Posted February 28, 2020 Share Posted February 28, 2020 Link to comment Share on other sites More sharing options...
Deye Posted March 2, 2020 Share Posted March 2, 2020 (edited) About a 9 times faster than using the ArrayUnique method for getting a Unique delimited: single digit\Chr string (2- 3 notations between delimits will go fast , 4 notations and above will go slower and slower ..) Edit: reaching the limit of 100 Unique elements with the above mentioned limit and ArrayUnique will perform just the same Not recommended for using with _ArrayToString for a ready made array as _ArrayToString will go slow for large arrays note: The ArrayUnique method will fail for any 8 and above digit (long) loop string process : Not sure what is the limit when using StringUnique_Delim but will probably do 8 and above .. fixed: on going from here (where it was leaving an extra duplicate in some cases ..) #include <File.au3> #include <Timers.au3> $s = "" For $i = 1 To 100000 $s &= "||" & Random(0, 10, 1) ; 8- 9 times faster ;~ $s &= "||" & Round(Random(0, 10), 1) ;a bit faster ;~ $s &= "||" & Round(Random(0, 10), 2) ;significantly slower Next $hTimer = _Timer_Init() $sOutput = StringUnique_Delim($s, "|") ConsoleWrite("1D : " & _Timer_Diff($hTimer) & @CRLF) _ArraySort($sOutput, 0, 1) _ArrayDisplay($sOutput, "StringUnique") $hTimer = _Timer_Init() $a = _ArrayUnique(StringSplit($s, "|", 3)) ConsoleWrite("1D : " & _Timer_Diff($hTimer) & @CRLF) _ArraySort($a, 0, 1) _ArrayDisplay($a, "_ArrayUnique") Func StringUnique_Delim($sString = "", $delim = ",", $bUBound = True) Local $sDelim = "\" & $delim Return StringSplit(StringTrimLeft(StringRegExpReplace($delim & $sString & $delim, $sDelim & '(?=' & $sDelim & ')|(' & $sDelim & '[^' & $sDelim & ']+)(?=' & $sDelim & ')(?=.*?\1' & $sDelim & ')|(' & $sDelim & '$)', ""), 1), $delim, $bUBound ? "" : 3) EndFunc ;==>StringUnique_Delim Edited March 2, 2020 by Deye Link to comment Share on other sites More sharing options...
Dan_555 Posted April 6, 2020 Share Posted April 6, 2020 Hi, this closes the main Gui window with a slow double click, instead of immediate closing: expandcollapse popup#include <GUIConstantsEx.au3> ;Opt("GUICloseOnESC", 0) ; disable closing the gui with escape Global $closingdelay = 1000, $closecounter = 0, $TimeHandle = TimerInit(), $TimeDiff = TimerDiff($TimeHandle) Global $formTitle = "My Testing App" $Form1 = GUICreate($formTitle, 616, 440, 208, 165) GUISetState(@SW_SHOW) While 1 CloseGuiOnDoubleClick("loop") $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE CloseGuiOnDoubleClick("button") EndSwitch WEnd Func CloseGuiOnDoubleClick($typ) ;; Global variables: ;Global $closingdelay = 1000, $closecounter = 0, $TimeHandle = TimerInit(), $TimeDiff = TimerDiff($TimeHandle) ;Global $formTitle = "My Testing App" ;; ;CloseGuiOnDoubleClick("loop") ;Insert in the main loop ;CloseGuiOnDoubleClick("button") ;insert instead of exit in the $GUI_EVENT_CLOSE check, in the main loop $typ = StringLower($typ) Select Case $typ = "button" If $closecounter = 1 And TimerDiff($TimeHandle) <= $closingdelay Then GUIDelete() Exit EndIf If $closecounter = 0 Then $closecounter = 1 $TimeHandle = TimerInit() WinSetTitle($Form1, "", "Slow doubleclick to close") EndIf Case $typ = "loop" If $closecounter = 1 And TimerDiff($TimeHandle) > $closingdelay Then $closecounter = 0 WinSetTitle($Form1, "", $formTitle) EndIf EndSelect EndFunc ;==>CloseGuiOnDoubleClick Some of my script sourcecode Link to comment Share on other sites More sharing options...
Deye Posted June 4, 2020 Share Posted June 4, 2020 (edited) Perhaps, for replacing doubled empty lines + more > to one line spacing $s = "" For $i = 1 To 5 $s &= Random(100, 1000, 1) $s &= @LF & Random(100, 1000, 1) For $j = 1 To 10 $s &= @CRLF Next Next MsgBox(0, "Original", $s) MsgBox(0, "Result", StringRegExpReplace($s, '(\n[^\n]+)(?=\n)(?=.*?\1)', "")) Edit: or as jchd suggests (Thanks) StringRegExpReplace($s, "\n\R{2,}", @CRLF) Edited June 4, 2020 by Deye Link to comment Share on other sites More sharing options...
jchd Posted June 4, 2020 Share Posted June 4, 2020 In AutoIt regexp implementation \R means @CR or @LF or @CRLF. Thus we can just do: StringRegExpReplace($s, "\R{2,}", @CRLF) Deye 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Deye Posted June 4, 2020 Share Posted June 4, 2020 (edited) jchd , Using the \R switch instead of \n leaves an extra line feed .. ( if i had to replace all \n with my example ) also note that the result posted with mine needs to leave 1 empty line untouched as done with the example so we need to keep that empty 1 line perhaps StringRegExpReplace($s, "\n\R{2,}", @CRLF) Edited June 4, 2020 by Deye Link to comment Share on other sites More sharing options...
Colduction Posted June 6, 2020 Share Posted June 6, 2020 On 6/4/2020 at 10:39 PM, Deye said: StringRegExpReplace($s, "\n\R{2,}", @CRLF) And can be this, i think this will be complete: StringRegExpReplace("TEST TEXT", "(\r\n|\r|\n){2,}", "") Link to comment Share on other sites More sharing options...
Dan_555 Posted June 13, 2020 Share Posted June 13, 2020 (edited) Hi, here is a small function, which i wrote to avoid the StringSplit and its array usage. It searches (directional search - from Left or Right) a String for the delimiter, and returns the remainder of the String with direction (left side/right side) including or excluding the delimiter char. The delimiter is limited to 1 char. expandcollapse popup;Example is at the bottom ! Func _StringSearchSplit($str, $delimiter, $dir = "L", $ret = "R", $incdel = -1) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringSearchSplit ; Description ...: Search for the first delimiter in a string, with searching direction, Case Sensitive search ; Syntax ........: _StringSearchSplit( $String, $delimiter [, $dir ] [, $ret ] [, $incdel ]) ; Parameters ....: $String - String to be checked. ; $delimiter - 1 char delimiter, has to be defined ; $dir - Search from direction (Left/Right), use "L" or "R" - Left is default ; The first letter will be used for direction, if multiple letters are entered e.g "Lab" = "L" ; $ret - Return side, Left or Right - Right is default. see above for valid entries. ; $incdel - Include delimiter 0 = No, 1 = Yes ; ; Return values .: Success - String ; ; e.g. 1: _StringSearch("c:\bat\test.bb","\","L","L") returns "c:" ; e.g. 2: _StringSearch("c:\bat\test.bb","\","L","L",1) returns "c:\" ; e.g. 3: _StringSearch("c:\bat\test.bb","\","L","R") returns "bat\test.bb" ; e.g. 4: _StringSearch("c:\bat\test.bb","\","L","R",1) returns "\bat\test.bb" ; e.g. 5: _StringSearch("c:\bat\test.bb","\","R","R") returns "test.bb" ; e.g. 6: _StringSearch("c:\bat\test.bb","\","R","R",1) returns "\test.bb" ; ; Failure - Empty string and @error flag as follows: ; @error : 1 - Empty String ; 2 - Delimiter should have a length of 1 char ; 3 - Should not happen, but if it does, search the PANIC button ! ; Author ........: Dan_555 (Autoitscript.com forum) ; =============================================================================================================================== Local $y Local $tmptxt = "" $dir = StringLeft(StringUpper($dir),1) $ret = StringLeft(StringUpper($ret),1) SetError(0) If StringLen($str) = 0 Then SetError(1) ;empty string Return "" EndIf If (StringInStr($str, $delimiter) = 0) Or (StringLen($delimiter) <> 1) Then SetError(2) ;invalid delimiter Return "" EndIf If $dir <> "L" And $dir <> "R" Then $dir = "L" ;Set default values If $ret <> "L" And $ret <> "R" Then $ret = "R" If $dir = "L" Then $y = StringInStr($str, $delimiter, 1) ;Search for the delimiter If $dir = "R" Then $y = StringInStr($str, $delimiter, 1, -1) If $incdel = 0 Then $incdel = -1 ;Tricky calculations ;) If $incdel <> -1 Then $incdel = 0 If $ret = "L" Then Return StringMid($str, 1, $y + $incdel) ;DisAssemble the string If $ret = "R" Then Return StringMid($str, $y - $incdel) SetError (3) Return "" EndFunc ;==>_StringSearchSplit ;~ ;Example ;~ $tmptxt = "c:\bAt\man\mobile.cAll" ;~ $s1 = "a" ;~ $s2 = "\" ;~ $s3="-----------------------------------" ;~ CW("Search string: " & $tmptxt) ;~ CW($s3 & "<") ;~ CW("LL" & $s1 & "0 " & _StringSearchSplit($tmptxt, $s1, "L", "L")) ;~ CW("LL" & $s1 & "1 " & _StringSearchSplit($tmptxt, $s1, "L", "L", 1)) ;~ CW($s3 & "<") ;~ CW("LR" & $s1 & "0 " & _StringSearchSplit($tmptxt, $s1, "L", "R")) ;~ CW("LR" & $s1 & "1 " & _StringSearchSplit($tmptxt, $s1, "L", "R", 1)) ;~ CW($s3 & "<") ;~ CW("RR" & $s1 & "0 " & _StringSearchSplit($tmptxt, $s1, "R", "R")) ;~ CW("RR" & $s1 & "1 " & _StringSearchSplit($tmptxt, $s1, "R", "R", 1)) ;~ CW($s3 & "<") ;~ CW("RL" & $s1 & "0 " & _StringSearchSplit($tmptxt, $s1, "R", "L")) ;~ CW("RL" & $s1 & "1 " & _StringSearchSplit($tmptxt, $s1, "R", "L", 1)) ;~ CW($s3 & "<" & " Second Example :") ;~ CW("LL" & $s2 & "0 " & _StringSearchSplit($tmptxt, $s2, "L", "L")) ;~ CW("LL" & $s2 & "1 " & _StringSearchSplit($tmptxt, $s2, "L", "L", 1)) ;~ CW($s3 & "<") ;~ CW("LR" & $s2 & "0 " & _StringSearchSplit($tmptxt, $s2, "L", "R")) ;~ CW("LR" & $s2 & "1 " & _StringSearchSplit($tmptxt, $s2, "L", "R", 1)) ;~ CW($s3 & "<") ;~ CW("RR" & $s2 & "0 " & _StringSearchSplit($tmptxt, $s2, "R", "R")) ;~ CW("RR" & $s2 & "1 " & _StringSearchSplit($tmptxt, $s2, "R", "R", 1)) ;~ CW($s3 & "<") ;~ CW("RL" & $s2 & "0 " & _StringSearchSplit($tmptxt, $s2, "R", "L")) ;~ CW("RL" & $s2 & "1 " & _StringSearchSplit($tmptxt, $s2, "R", "L", 1)) ;~ Func CW($txt) ;~ ConsoleWrite(" > " & $txt & @CRLF) ;~ EndFunc ;==>CW ;~ ;- End of the example Edited June 13, 2020 by Dan_555 TheDcoder 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
TheDcoder Posted June 14, 2020 Share Posted June 14, 2020 @Dan_555 Nice function, reminds me of a similar function (strseg) that I wrote, but in C It basically does the same thing, search for the next delimiter and return the string. It doesn't have support for the different directions though! Dan_555 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
DutchCoder Posted July 9, 2020 Share Posted July 9, 2020 (edited) Wait for Mouse to move (two ways) Normally when you have a GUI you can use this: Func _MouseWaitMove() Do Sleep(100) Until GuiGetMsg() = -11 EndFunc But sometimes you don't have a GUI. This one always works: Func _MouseWaitMove() $_old = MouseGetPos() Do Sleep(100) $_new = MouseGetPos() Until ($_new[0] - $_old[0]) Or ($_new[1] - $_old[1]) EndFunc Edited February 27 by DutchCoder Inpho and Colduction 2 Link to comment Share on other sites More sharing options...
Inpho Posted July 9, 2020 Share Posted July 9, 2020 (edited) 2 hours ago, DutchCoder said: Func _MouseWaitMove() Local $_start = _MouseInit() While $_start == _MouseInit() Sleep(100) WEnd EndFunc Func _MouseInit() Local $_get = MouseGetPos() Return $_get[0] & $_get[1] EndFunc Doesn't detect when I move the mouse from 1,12 to 11,2. Fixed for my use: Func _MouseInit() Local $_get = MouseGetPos() Return $_get[0] & ";" & $_get[1] EndFunc Edited July 9, 2020 by Inpho Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now