Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/29/2019 in all areas

  1. mseidel, Disgraceful! Well, we are certainly not going to encourage such appalling behaviour - thread closed. And can we please have the name of your company to make sure we have nothing to do with it in the future. M23
    1 point
  2. My point is that I don't want to use _ArraySearch at all. I want to save the values directly in the Scripting.Dictonary object and search directly in the object. Scripting.Dictonary is implemented in a DLL file. When you are searching, it's done in compiled code. It'll be 1000 times faster than _ArraySearch (in a very round number). If Scripting.Dictonary is implemented in a UDF, it'll only be 100 times faster. Why should I be happy with 100 times faster code when I can get 1000 times faster code? If you're searching for Scripting.Dictonary in the forums you'll see that in many cases it is in fact used to optimize AutoIt code. AutoIt is pretty much a simple and easy to use language (probably also a little bit dirty, I certainly won't call it beautiful). At the same time, it contains all the techniques needed to create as complex code as you can ever imagine only limited by the skills of the coder. Why not take advantage of these techniques to make AutoIt even more useful but not least to make it more interesting and exciting for experienced coders?
    1 point
  3. Possibly just: ConsoleWrite(StringFormat('\r\n@CRLF before this\t@TAB before this\n')) Called escape sequence.
    1 point
  4. Python is a great language. I love it. Have fun!
    1 point
  5. GillesMaisonneuve, Even better - just use the MULTILINE style on its own: #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton("Execute " & @CRLF & " file 1", 100, 65, 60, 50, $BS_MULTILINE) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd But you appear to be using coloured buttons - which might be the root of your problem. There is a bug deep within AutoIt which means that colouring buttons leads to all sorts of problems, such as capturing the {ENTER} key and messing with the various styles. This bug is NOT going to be fixed so it is recommended NOT to use coloured buttons. Try removing the colour code and see if the vertical alignment works then - if so then you will have to choose which you want: colour or alignment. M23
    1 point
  6. UPDATE: i think the way i'm going to tackle this is on the python side, i'm going to process the text for AutoIt-compliant format before output. preliminary test suggest it is easier. trying it now...
    1 point
  7. If I can recommend, I always find it useful to use the YYYYMMDDHHmmss format. It sorts easily.
    1 point
  8. One way would be to append the date and time to the filename. Look at the Time and Date Macros page in your help file and let us know if you get stuck.
    1 point
  9. @LarsJ For me the beauty of AutoIt is that it is simple to create UDFs to wrap any slightly complex tasks (like handling objects) in a simple function call, performance doesn't really matter most of the time if you are using an interpreted language, and I don't agree that it matters in this instance... _ArraySearch would still take up a lot of time than the overhead of wrapper functions will ever take up @iamtheky I do remember your UDF, you bought it up in one of my topics about maps I have gone searching for that on several occasions, but it is elusive, never managed to find it when I needed it... It could be polished but it is usable in the current state
    1 point
  10. in case the answer is yes, i totally dove this rabbit hole
    1 point
  11. Scripting.Dictonary is also a good candidate for associating variables with strings, shame no one has made a proper UDF wrapping it yet (that I know of)...
    1 point
  12. Timestamps should be expressed in seconds elapsed since 01/01/1970 00:00:00 the timestamp number you presented seems to be espressed in milliseconds instead. If you have a look to the _DateAdd() function in the help, there is the exmple that you need. In short you have to add to the starting date of 01/01/1970 00:00:00 the number of seconds (not milliseconds) that you have, and you will have the target date, that is, the date you reach after all those seconds have elapsed since then. However, it seems that your timestamp (properly reduced to seconds) matches to 2018/04/04 and not 2018/03/28 as you indicated in OP #include <date.au3> Local $EpochSeconds = 1522847958 ; 000 MsgBox(0, '', _DateAdd('s', $EpochSeconds, "1970/01/01 00:00:00")) p.s. you can find some other formulas for conversions to / from other formats (also for AutoIt) at this link: https://www.epochconverter.com/
    1 point
  13. Your DLLs will remain stored in memory as long as your script is running. The problems you experience when a large number of repetitive function calls become slow have nothing to do with the DLLs not being constantly stored in memory. It's simply because AutoIt is an interpreted language that's not fast for a large number of repetitive tasks. The only solution to this kind of bottleneck problems is to replace the critical parts of the code with true compiled code. There are two ways you can do this in AutoIt. The absolute easiest way is to use C# or VB.NET code through the .NET framework. The other way is to create your own DLL with a language capable of creating DLLs.
    1 point
  14. You can also check the file hashes of the files, if they are the same, the file is the same. Here is a function to do that. #include <Crypt.au3> Func _SameFilesHashes($sTestFile1, $sTestFile2) ;Returns True if the same file hash, and False if they are not or an error occures. ;Get SHA1 hashes of the old and new files. _Crypt_Startup() Local $sFileHash1 = _Crypt_HashFile($sTestFile1, $CALG_SHA1) Local $iHashError1 = @error Local $sFileHash2 = _Crypt_HashFile($sTestFile2, $CALG_SHA1) Local $iHashError2 = @error _Crypt_Shutdown() ;Compare the hashes to see if they are the same, and check for errors. Select Case $sFileHash1 == $sFileHash2 And Not $iHashError1 And Not $iHashError2 Return True Case $iHashError1 Return SetError(1, $iHashError1, False) Case $iHashError2 Return SetError(2, $iHashError2, False) Case Else Return False EndSelect EndFunc Adam
    1 point
  15. I took the long way here but have arrived. I am trying to replicate map functions as I hunt for the most enjoyable way to play with INI style data (which is why the func names are all _map*). This is by no means complete but it is a working demo. As always feel free to improve this, and then post that. UDF ;_MapInit ;_MapAddKeyValuePair ;_MapReassignKey ;_MapAppendToKey ;_MapRemoveKey ;_MapGetValue ;_MapToString ;_MapToArray ;_MapTo2dArray ;_MapFrom2DArray ;_MapToIniSection ;_MapFromIniSection Func _MapInit() Local $map = ObjCreate("Scripting.Dictionary") If Not IsObj($map) Then Exit MsgBox(0, "Error", "Object not created") EndIf return $map EndFunc ;_MapInit Func _MapAddKeyValuePair($map , $key , $value) If $map.Exists($key) Then msgbox(0, 'Error' , '"' & $key & '"' & ' already exists with a value of ' & '"' & $map.Item($key) & '"') Else $map.Add($key, $value) EndIf EndFunc ;_MapAddKeyValuePair Func _MapReassignKey($map , $key , $value) If $map.Exists($key) Then $map.remove($key) $map.Add($key, $value) Else $map.Add($key, $value) EndIf EndFunc ;_MapReassignKey Func _MapAppendToKey($map , $key , $value) If $map.Exists($key) Then $sCurrent = $map.Item($key) $map.remove($key) $map.Add($key, $sCurrent & ";" & $value) Else $map.Add($key, $value) EndIf EndFunc ;_MapAppendToKey Func _MapRemoveKey($map , $key) $map.remove($key) EndFunc ;_MapRemoveKey Func _MapGetValue($map , $key) return $map.Item($key) EndFunc ;_MapGetValue Func _MapToString($map) local $sOut = "" for $key in $map.Keys $sOut &= $key & " = " & $map.Item($key) & @LF Next return stringreplace($sOut , @LF , "" , -1) EndFunc ;_MapToString Func _MapToArray($map) local $aArray[$map.count] $i = 0 for $key in $map.Keys $aArray[$i] = $key & " = " & $map.Item($key) $i += 1 Next return $aArray EndFunc ;_MapToArray Func _MapTo2dArray($map) local $aArray[$map.count][2] $i = 0 for $key in $map.Keys $aArray[$i][0] = $key $aArray[$i][1] = $map.Item($key) $i += 1 Next return $aArray EndFunc ;_MapTo2dArray Func _MapToIniSection($map , $section , $filepath , $fSort = 0) $aMap = _MapTo2dArray($map) _ArrayInsert($aMap , 0 , ubound($aMap) - 1) If $fSort = 1 Then _ArraySort($aMap) IniWriteSection($filepath , $section , $aMap) EndFunc ;MapToIniSection Func _MapFromIniSection($filepath , $section) $map = _MapInit() $aArray = IniReadSection($filepath , $section) for $i = 1 to ubound($aArray) - 1 $map.add($aArray[$i][0] , $aArray[$i][1]) Next return $map EndFunc Func _MapFrom2DArray($2Darray) Local $map = ObjCreate("Scripting.Dictionary") If Not IsObj($map) Then Exit MsgBox(0, "Error", "Object not created") EndIf for $i = 0 to ubound($2Darray) - 1 _MapAddKeyValuePair($map , $2Darray[$i][0] , $2Darray[$i][1]) Next return $map EndFunc ;_MapToArray Example: #include 'dictmap.au3' #include<array.au3> ;map initialize - MUST BE FIRST $myDictionary = _MapInit() ;map add key/value pairs _MapAddKeyValuePair($myDictionary , "KeyEntry0" , "ValueEntry0") ; adding key/value pairs _MapAddKeyValuePair($myDictionary , "KeyEntry1" , "ValueEntry1") _MapAddKeyValuePair($myDictionary , "KeyEntry2" , "ValueEntry2") _MapAddKeyValuePair($myDictionary , "KeyEntry3" , "ValueEntry3") _MapAddKeyValuePair($myDictionary , "KeyEntry4" , "ValueEntry4") _MapAddKeyValuePair($myDictionary , "KeyEntry5" , "ValueEntry5") ;map get value of key msgbox(0, "Value of KeyEntry1" , _MapGetValue($myDictionary , "KeyEntry1")) ;see single value ;map add duplicate failure _MapAddKeyValuePair($myDictionary , "KeyEntry1" , "ValueEntry1_replaced") ;duplicate test ;map reassign key _MapReassignKey($myDictionary , "KeyEntry1" , "ValueEntry1_replaced") ;Key exists so Reassign the value msgbox(0, "Value of reassigned KeyEntry1" , _MapGetValue($myDictionary , "KeyEntry1")) ;see changed entry ;map append to key _MapAppendToKey($myDictionary , "KeyEntry4" , "ValueEntry4_append") ; append stuff to keyentry4 ;map remove key _MapRemoveKey($myDictionary , "KeyEntry0") ; remove key 0 ;map to string msgbox(0, 'Map String - No Sort' , _MapToString($myDictionary)) ;entire Map To string ;map to array $aMyDictionary = _MapToArray($myDictionary) ;Entire Map To Array _ArraySort($aMyDictionary) _ArrayDisplay($aMyDictionary , "1D Sorted") ;Map to 2D array $a2DmyDictionary = _MapTo2dArray($myDictionary) ;Entire Map To 2D Array _ArraySort($a2DmyDictionary) _ArrayDisplay($a2DmyDictionary , "2D Sorted") ;map from array $MapFrom2D = _MapFrom2DArray($a2DmyDictionary) for $key in $MapFrom2D.keys msgbox(0, 'MapFromArray' , $key & @LF & $MapFrom2D.item($key)) Next ;map to ini _MapToIniSection($myDictionary , "TEST_SECTION_01_Unsorted" , @ScriptDir & "\TEST_SECTION.ini") ;unsorted _MapToIniSection($myDictionary , "TEST_SECTION_02_Sorted" , @ScriptDir & "\TEST_SECTION.ini" , 1) ;sorted ShellExecute(@ScriptDir & "\TEST_SECTION.ini") ;map from ini $MapFromIni = _MapFromIniSection( @ScriptDir & "\TEST_SECTION.ini" , "TEST_SECTION_01_Unsorted") $aMapFromIni = _MapToArray($MapFromIni) ;Entire Map To Array _ArraySort($aMapFromIni) _ArrayDisplay($aMapFromIni , "from INI")
    1 point
  16. Hi there, Try AdlibRegister. Cheers and welcome aboard
    1 point
  17. ravkr

    auto close program

    AdlibRegister('close', 4500000) ; run func every 1h 15m ; your code here While 1 ; or here ConsoleWrite('.') Sleep(1000) WEnd Func close() AdlibUnRegister('close') ; unregister func so it won't close program after next 1h 15m If ProcessExists("iexplore.exe") Then ProcessClose("iexplore.exe") EndIf EndFunc
    1 point
  18. Hi, Here is a way of doing it, have a TimerInit() before the start of the windows msg loop, check for it reaching a idle maximum duration as one of the cases, after any other case reset the timmer. i made a little example that has two button that will reset the timmer and a status to show the idle time in seconds. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> _Form1() Func _Form1() #Region ### START Koda GUI section ### Form= Local $Form1 = GUICreate("Form1", 196, 94, -1, -1) Local $hButton1 = GUICtrlCreateButton("Button1", 20, 24, 75, 25) Local $hButton2 = GUICtrlCreateButton("Button2", 100, 24, 75, 25) Local $hStatusBar1 = _GUICtrlStatusBar_Create($Form1) _GUICtrlStatusBar_SetSimple($hStatusBar1) _GUICtrlStatusBar_SetText($hStatusBar1, "Idle Time: ") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $iTimmer = TimerInit() Local $iTimmerDuraction = 20000 Local $sStatusText While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $hButton1 MsgBox(0, "Button1", "Idle timmer reset") $iTimmer = TimerInit() Case $nMsg = $hButton2 MsgBox(0, "Button2", "Idle timmer reset") $iTimmer = TimerInit() Case TimerDiff($iTimmer) >= $iTimmerDuraction MsgBox(0, "Times up", "Idle time limit reached") ExitLoop Case Else Local $sNewTimeText = "Idle Time: " & Round(TimerDiff($iTimmer) / 1000) If $sStatusText <> $sNewTimeText Then $sStatusText = $sNewTimeText _GUICtrlStatusBar_SetText($hStatusBar1, $sStatusText) EndIf EndSelect WEnd EndFunc ;==>_Form1
    1 point
  19. That does exacyly what deadbug is saying he wants to avoid. This adds to the edit without rewriting it all. #include <GUIConstants.au3> Guicreate ( "Example" , 200, 200) $button = guictrlcreatebutton ( "Send" , 1,1,30) $box = guictrlcreateinput ( "" , 1,30, 170, 30) $main = GUICtrlCreateedit ( "", 1, 70, 190, 120) GUISetState () While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE exitloop Case $msg = $button $boxread = guictrlread ( $box ) ;$mainread = guictrlread ( $main ) GUIctrlsetdata ( $main , $boxread & @CRLF,1 ) EndSelect Wend
    1 point
×
×
  • Create New...