Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/17/2021 in all areas

  1. Shut the front door! I have been using AutoIt for 14 odd years and initially was frustrated at losing my sessions until I learned to never click on an .au3 file. I am perplexed that this mysterious hidden feature is remmed out by default when intuitively this is the behaviour one would expect from an editor. Fourteen years too late but this may help me in the future. Thanks for asking @lee321987 and Jos for answering.
    2 points
  2. ... as you can see from other posts, there are also other pedissequo ...simpler ways to achieve the same result, anyway, if you are interested on how to use that array functions, I've added some comments to the list. #include <array.au3> Local $aResultFromExcelFile[][] = _ [['Marky', '07:30'], _ ['Ricky', '07:30'], _ ['Danny', '08:00'], _ ['Terry', '08:15'], _ ['Mikey', '08:15'], _ ['Davey', '08:15'], _ ['Timmy', '08:30'], _ ['Tommy', '08:30'], _ ['Joey', '08:30'], _ ['Robby', '08:30'], _ ['Johnny', '13:30'], _ ['Brian', '14:30']] ; the $aGroups array will contain all the different times repeated only one time ; i.e. the 08:30 will appear only one time in this array even if there are more. ; so we know how many groups we need (one group for each different hour) Local $aGroups = _ArrayUnique($aResultFromExcelFile, 1) ; find unique Times ; _ArrayDisplay($aGroups) ; debug ; we create a new array that will contain all our meetings groupped by same time ; this array must have the same number of rows as the $aResultFromExcelFile array ; and one more column to hold the group number with the same time, 3 columns instead of 2 ; The $aOut array: ; 0 1 2 ; +---+---+---+ ; | | | | ; +---+---+---+ ; | | | | ; ^ ^ ^ ; | | | ; | | +-- column 2 ...][2] will contain the time ; | | ; | +------ column 1 ...][1] will contain the name ; | ; +---------- column 0 ...][0] will contain the number of the group ; Local $aOut[UBound($aResultFromExcelFile)][3] ; create a new array with a new column "Group" ; 2 variables used as pointers Local $iGroup = 0, $iIndex = 0 ; here we loop for each time group ; element $aGroups[0] contains the number of elements contained in the array For $i = 1 To $aGroups[0] ; the _ArrayFindAll() function is a nice function ; it will return you the indices (row numbers) where are located ; the elements that you are looking for into the $aResultFromExcelFile array $aSameTime = _ArrayFindAll($aResultFromExcelFile, $aGroups[$i], 0, 0, 0, 0, 1) ; find all indices (rows) with same time ; _ArrayDisplay($aSameTime) ; debug ; in this loop we get all the rows with the same time from the $aResultFromExcelFile array ; and copy them to our final array ; group number in column [0] ; name in column [1] ; time in column [2] For $iSameTime = 0 To UBound($aSameTime) - 1 ; scan all persons with the same time $aOut[$iIndex][0] = $iGroup $aOut[$iIndex][1] = $aResultFromExcelFile[$aSameTime[$iSameTime]][0] ; column 0 contains the name $aOut[$iIndex][2] = $aResultFromExcelFile[$aSameTime[$iSameTime]][1] ; column 1 contains the time ; ----------------- --------------------- --------------------- ; ^ ^ ^ ; | | | row where is the next person ; | | +-- with the same time ; | | ; | | we read the data from the array ; | +------------------------ $aResultFromExcelFile ; | ; +-------------------------------------------- we populate the 3 columns of the output $iIndex += 1 ; we pass to the next person with the same time Next $iGroup += 1 ; we pass to the next group Next _ArrayDisplay($aOut)
    2 points
  3. I like salt on mice but not in coffee Edit : #include <Array.au3> #include <Excel.au3> Local $sFilePathExcel = @ScriptDir & "\Data For Appointments.xlsx" Local $oExcel = _Excel_Open(false) Local $oWorkbook = _Excel_BookOpen($oExcel, $sFilePathExcel) Local $aResult = _Excel_RangeRead($oWorkbook, Default, Default) _ArrayColDelete($aResult, 1) _ArrayColDelete($aResult, 1) ; it is NOT stuttering _ArraySwap($aResult, 0, 1, true) Local $i = 0, $u = Ubound($aResult) Local $res[$u][2] $res[0][0] = $aResult[0][0] $res[0][1] = $aResult[0][1] For $n = 1 To $u - 1 If $aResult[$n][0] = $aResult[$n-1][0] Then $res[$i][1] &= ", " & $aResult[$n][1] Else $i += 1 $res[$i][0] = $aResult[$n][0] $res[$i][1] = $aResult[$n][1] EndIf Next ReDim $res[$i+1][2] _ArrayDisplay($res) BTW the number of the 'group' is the index of the row
    1 point
  4. Yes it is! I’m embarrassed that I didn’t upvote 💟 it ‘til just now!
    1 point
  5. @argumentum Thanks for sharing, however I don't think I see any code which we could use for this issue.
    1 point
  6. Hi Musashi Unfortunately this sentence is wrong since AutoIt release 3.3.14.3 as illustrated in this post. Maybe it works at your place because you're using an older AutoIt version. Sometimes I give old AutoIt versions a personalized name in my AutoIt history folder ... autoit-v3.3.10.0 (invasion of Yashied WinApiEx func).zip ... autoit-v3.3.12.0 (musashi).zip ... autoit-v3.3.14.3 (no more big WinAPI.au3).zip ... As Jpm sent the fix to Jon 9 months ago, then it still doesn't work in beta 3.3.15.3 which was released 1 year ago (re-tested just now) . Patience, it will work again one of these days.
    1 point
  7. Just use _DebugArrayDisplay instead of _ArrayDisplay, you'll find 2 copy buttons that will copy the results in the Clipboard * Results are whole columns if no row is selected. * If you select some lines, then only the selected lines are copied * If your display retrieved for example 10 columns and you want to copy only columns 0-1, then use the array range param. (3rd param) to display only 2 columns _DebugArrayDisplay($w, "Title", "|0:1") * If you don't want the "Row column" to appear, just add the correct 4th param. _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) This will do it : #Include <Array.au3> #Include <Debug.au3> #include <Constants.au3> $s = FileRead("2.txt") Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) _ArrayColInsert($w, 1) For $i = 0 to UBound($w)-1 StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) $w[$i][1] = @extended Next _ArraySort($w, 1, 0, 0, 1) _DebugArrayDisplay($w) ; _DebugArrayDisplay($w, "Title", "|0:1") ; _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW) Edit: While I was writing this, DanP2 just said it too
    1 point
  8. Obviously you’ve never met VinnyMS before
    1 point
  9. Hi exit Now all error has finally gone now not any problems to create setup and zip files, tanks alot that you have fix it..
    1 point
  10. It appears that @mikell may have been going for the classic “one-pager”
    1 point
  11. Are you saying you can’t teach an old cat new tricks?
    1 point
  12. Yeah I've been using AutoIt for probably 12-13 years. I made habit of just leaving SciTE running most of the time, and for those times where I thought it was running but it wasn't, I wrote a script to backup the previous .session file (the file is not written until you close SciTE), close SciTE, and copy the backup file over the current. I'm really grateful to hear about this setting! I too think it should be default behavior.
    1 point
  13. Ok, here is the POC. Its ugly, but it seems to work. 2 Files to download - RunParams.au3 and RunNotepad.au3 (RunNotepad must be compiled to .exe) 1) RunParams.au3 This is the RunParams mock up. This has the code that you can incorporate in your .au3. Go ahead and run it either in interpretive mode or compiled. When you press F5 it will launch a new Notepad to simulate the PSPad log window (it also kills any notepad window first). Then after 4 secs the focus should change to the Notepad window, although you may not notice it because keystrokes are never lost to it, and in any event the focus will return to the RunParams, if that's what had focus when you pressed F5. 2) RunNotepad.au3/.exe This file exists only to launch Notepad in the background and then wait 4 secs before setting the focus to Notepad. Then it terminates. Here is RunParams.au3 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotkeySet("{F5}", "RunNotePad") Local $hWnd=GUICreate("Run - params dialog", 325, 70) Local $hEdit=GUICtrlCreateEdit("param1 param2", 5, 3, 300, 50, $WS_VSCROLL) GUISetState(@SW_SHOW) SetKeys() GUIRegisterMsg($WM_ACTIVATE, "FocusChange") While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() Exit ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func RunNotePad() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Run("RunNotePad.exe") EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func FocusChange($hWnd, $iMsg, $wParam, $lParam) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; If $wParam Then SetKeys(True) Else If WinGetHandle("[ACTIVE]")=WinGetHandle("[CLASS:Notepad]") Then WinActivate($hWnd) Else SetKeys(False) EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func SetKeys($bSet=True) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Local $sFunc For $n=32 To 126 If $bSet Then HotkeySet(Chr($n), "SendToControl") Else HotkeySet(Chr($n)) EndIf Next EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func SendToControl() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; HotkeySet(@HotKeyPressed) ControlSend($hWnd, "", $hEdit, @HotKeyPressed) HotkeySet(@HotKeyPressed,"SendToControl") EndFunc Here is RunNotepad.au3 ProcessClose("Notepad.exe") Run("Notepad.exe", @WorkingDir, @SW_SHOWNOACTIVATE) Sleep(4000) WinActivate("[CLASS:Notepad]") P.S. Its pretty ugly stuff generally, I can't say I'm proud.
    1 point
  14. Strange that a cat like @mikell didn't end up with one of his SRE(R)? and/or Scripting Dictionary solutions #include <Array.au3> Test() Func Test() Local $arrResultFromExcelFile[][] = _ [['Marky' , '07:30'], _ [ 'Ricky' , '07:30'], _ [ 'Danny' , '08:00'], _ [ 'Terry' , '08:15'], _ [ 'Mikey' , '08:15'], _ [ 'Davey' , '08:15'], _ [ 'Timmy' , '08:30'], _ [ 'Tommy' , '08:30'], _ [ 'Joey' , '08:30'], _ [ 'Robby' , '08:30'], _ [ 'Johnny', '13:30'], _ [ 'Brian' , '14:30']], _ $objDictionary, _ $arrDictionaryItems, _ $arrDictionaryKeys, _ $strKey, _ $varItem, _ $arrAppointments[0][2] ; Create Dictionary object $objDictionary = ObjCreate("Scripting.Dictionary") ; Loop through the array For $i = 0 To UBound($arrResultFromExcelFile) - 1 Step 1 ; Get the key and item $strKey = $arrResultFromExcelFile[$i][1] $varItem = $arrResultFromExcelFile[$i][0] ; If the key already exists, then add a comma and concatenate the new item with the existing one(s) If $objDictionary.Exists($strKey) Then $objDictionary.Item($strKey) &= "," & $varItem Else $objDictionary.Add($strKey, $varItem) EndIf Next ; Get the Dictionary items $arrDictionaryItems = $objDictionary.Items ; Display the Dictionary items ; _ArrayDisplay($arrDictionaryItems) ; Get the Dictionary keys $arrDictionaryKeys = $objDictionary.Keys ; Merge the two 1D arrays in a 2D array _ArrayMerge($arrAppointments, $arrDictionaryKeys, $arrDictionaryItems) _ArrayDisplay($arrAppointments) EndFunc Func _ArrayMerge(ByRef $arrDestArray, $arrArray1, $arrArray2) For $i = 0 To UBound($arrArray1) - 1 Step 1 _ArrayAdd($arrDestArray, $arrArray1[$i] & "|" & $arrArray2[$i]) Next EndFunc
    1 point
  15. When I get back into the office I will verify that PS pad can indeed be manipulated with UIAutomation so that you can do the automation you want to that editor from AutoIt. If that is possible I will post back when I get back into the office
    1 point
  16. At the time that I had requested the the output from scite, I had already fixed the errors in your script and had it working. In the script that you posted above, there's more than one error and none of those errors that I found had anything to do with the path to the eSpeak data files. Maybe the accent in the path is another error, but it is definitely not the biggest one. What was really silly was you not providing the information that I requested so that I could have confirmed what I needed to confirm and you could've moved on to getting additional help and finding out what the issues were with your script. So you have apparently wasted several days still not finding the other errors in your example script and you are getting back what "seems" to be a correct value (meaning you don't even know for sure), Why? Because you didn't want to supply the answer to a simple request (which you never did by the way). All you managed to do was piss off someone that had helped you before, was trying to help you again, and probably won't help you in the future. That's just brilliant...said no one! Here's some advice for the future: If you come here looking for help and want to ask questions, you can expect to have to answer a few too. Otherwise, you can get ignored and waste a lot of time coming to conclusions that only "seem" correct (but most likely aren't).
    1 point
  17. Use the separate SciTE4AutoIt3 installer and this issue will be resolved (is configurable) #restore last session when selecting Open file from Explorer - Only available in SciTE4AutoIt3 version save.session.advanced=1 Jos
    1 point
  18. Musashi

    Organization of script?

    Yes, that would be the hardcore option . Sometimes a bit annoying, but usually a good help. @ReconX : You can find a complete description here: https://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/au3check.html The parameter -d also sets the "MustDeclareVars" option to True During development, however, I would leave out the parameter -w 5 (gives a warning if a local variable is declared but not used). In an early stage it is not uncommon to declare local variables without using them immediately. The warnings can be a bit disturbing then. By the end of the project you can set the parameter to find and get rid of unused local variables.
    1 point
  19. mLipok

    Organization of script?

    I recomend to use: #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 or even: #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_Run_Tidy=Y #Tidy_Parameters=/reel
    1 point
  20. Musashi

    Organization of script?

    I agree @ReconX : Take a look at the system-scan-report-tool made by @spudw2k . There you will find useful code parts regarding WMI.
    1 point
  21. Declare the global outside the functions. Read the Wiki ( https://www.autoitscript.com/wiki/Best_coding_practices ) ...and that is my collaboration for today
    1 point
  22. @ReconX Use Opt("MustDeclareVars", 1) for the variables declaration, so you must declare every variable the script uses, or it will throw an error. For the script improvements, in the function ComputerInfo() you could use WMI object instead of run powershell commands, so you delete the part of StdoutRead() and ProcessWaitClose(). For the function _Randomize(), you could use Chr() function in a For Loop instead of having a predefined subset of chars (and you did repeat <> as well). You may use something like this (untested): For $i = 1 To $intPasswordLenght Step 1 $strPassword &= Chr(Random(33, 126, 1)) Next Obviousely, in this case you include few more chars than you did in your chars subset, but it shorten the code a little bit
    1 point
×
×
  • Create New...