
Luke94
-
Posts
191 -
Joined
-
Last visited
-
Days Won
1
Reputation Activity
-
Luke94 got a reaction from Flickblue in Array loop problems
This part of your code decides the number of times your script loops.
For $d = 0 To 4 Step 1 Once $d = 4, the loop exits. You could increase the number of loops or use a While Loop to create an endless loop.
-
Luke94 got a reaction from dmob in excel printing fit to page, shrink to page
Try setting zoom to false:
$workbook.sheets(1).pagesetup.Zoom=False $workbook.sheets(1).pagesetup.FitToPagesWide=1 $workbook.sheets(1).pagesetup.FitToPagesTall=1
-
Luke94 got a reaction from vkrisz81 in excel printing fit to page, shrink to page
Try setting zoom to false:
$workbook.sheets(1).pagesetup.Zoom=False $workbook.sheets(1).pagesetup.FitToPagesWide=1 $workbook.sheets(1).pagesetup.FitToPagesTall=1
-
Luke94 got a reaction from iamkoshr in within the parentheses of a function | func example()
No, the information within the parentheses (parameter) is passed by the user which is then copied into a new variable for use within the function - any changes made to the variable will be Local. See https://www.autoitscript.com/wiki/Best_coding_practices#Scopes_of_Variables
Declaring ByRef links the parameter to the original variable meaning any changes made to the variable within the function will be made to the original variable.
This feels like a bad example but have a look anyway:
Global $g_sText = 'iamkoshr' ; This is the variable we are passing to the functions Function1($g_sText) ConsoleWrite('Global Variable: ' & $g_sText & @CRLF) ; Here the output WILL be changed even though the parameter was changed within Function1 Function2($g_sText) ConsoleWrite('Global Variable: ' & $g_sText & @CRLF) ; Here the output will NOT be changed because the ByRef keyword was used Func Function1($sText) ConsoleWrite('Parameter: ' & $sText & @CRLF) ; Output the parameter passed by the user $sText = 'CHANGED!' ; Change the parameter EndFunc Func Function2(ByRef $sText) ConsoleWrite('Parameter: ' & $sText & @CRLF) ; Output the parameter passed by the user $sText = 'BYREF CHANGED!' ; Change the parameter EndFunc
-
Luke94 got a reaction from iamkoshr in within the parentheses of a function | func example()
Have you read this?
-
Luke94 got a reaction from pixelsearch in How to close a gui quicker than it does!
As mine was marked as the solution, I've passed the thanks onto Resiak1811.
-
Luke94 reacted to Resiak1811 in How to close a gui quicker than it does!
try that :
#include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> $Computer = @ComputerName Local $timestamp $GUI = GUICreate($Computer & " time", 150, 80, "", "", BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD)) WinSetOnTop($GUI, "", 1) $Cmd_out = _GetDOSOutput("net time \\" & $Computer) $timestamp = StringRegExp($Cmd_out, "\d{2}:\d{2}:\d{2}", 1) GUICtrlCreateLabel($timestamp[0], 20, 10, 120, 350) GUICtrlSetFont(-1, "18", "800", "", "Consolas") GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch $aTime = TimeCalc($Computer) WEnd Func TimeCalc($Computer) $Cmd_out = _GetDOSOutput("net time \\" & $Computer) If $Cmd_out <> "" Then $timestamp = StringRegExp($Cmd_out, "\d{2}:\d{2}:\d{2}", 1) GUICtrlSetData(-1, $timestamp[0]) EndIf EndFunc ;==>TimeCalc Func _GetDOSOutput($sCommand) Local $iPID, $sOutput = "" $iPID = Run('"' & @ComSpec & '" /c ' & $sCommand, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $sOutput &= StdoutRead($iPID, False, False) If @error Then ExitLoop Sleep(10) WEnd Return $sOutput EndFunc ;==>_GetDOSOutput
-
Luke94 got a reaction from adragomir in How to run java -jar ... but hide the cmd?
ShellExecute(@ScriptDir & "\jvm\bin\java.exe","-jar " & @ScriptDir & "\learnLambda-1.0.jar", "", "", @SW_HIDE); or
Run(@ComSpec & " /c " & ".\jvm\bin\java.exe -jar " & ".\learnLambda-1.0.jar", "", @SW_HIDE); Edit: @SW_HIDE belongs in the 5th parameter of ShellExecute.
-
Luke94 reacted to Subz in Split String and Wrap Each Word in Quotations
Or
Local $sString = 'Item 1, Item@2, Item_3, Item/4, Item-5' $sString = '"' & StringReplace($sString, ", ", '", "') & '"'
-
Luke94 reacted to Nine in Split String and Wrap Each Word in Quotations
This ?
Local $sText = "Item 1, Item@2, Item_3, Item/4, Item-5" Local $sFinal = '"' & StringRegExpReplace($sText, '(, )', '", "') & '"' ConsoleWrite($sFinal & @CRLF)
-
Luke94 reacted to Zedna in ADODB.Connection Execute Returns 1 Row (SQL WHILE Loop)
Here is another way how to get more rows from ADO Recordset by While loop:
-
Luke94 got a reaction from lee321987 in HotKey does not work (HotKeySet), and can't click tray icon to exit
_WinAPI_ReadDirectoryChanges blocks until a change is made. (Or the directory handle is closed, I think)
Depending what you're aiming to achieve, the solution may be to create two scripts. The second script could be called when _WinAPI_ReadDirectoryChanges detects a change maybe?
You could use HotKeySet in the second script to kill the process of the first script as well. Edit: In this case, you'd want to start both scripts at the same time otherwise HotKeySet wouldn't be functional until _WinAPI_ReadDirectoryChanges detects a change.
-
Luke94 reacted to ahha in ListView sorting on date
Thanks to all for the answers/suggestions. They provided me lots of information and I learned much.
Here's my version that does not need to use GUICtrlRegisterListViewSort (thanks @Luke94), does not need a phantom column (thanks @mikell), and takes care of the up/down arrow issue (thanks @pixelsearch).
I basically use an array to load listview with MM/DD/YYYY format, then when header is clicked I alter array to YYYYMMDD format, load it back into listview, let listview use the regular sort, then load listview back to the array, convert array back to MM/DD/YYYY format and reload listview.
I know a lot of loads/reloads but it's straightforward and I understand it (excuse all the debug statements, it helps me :).
Any comments welcomed.
#AutoIt3Wrapper_run_debug_mode=Y #include <Debug.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> AutoItSetOption("MustDeclareVars", 1) ;v1a - original ;v1b - creating array that we can array->listview, and listview->array ;v1c - changing $aListView because using _GUICtrlListView_AddArray ;v1d - try using all UDF _ functions as mixing could cause issues ;v1e - cleaning out extraneous code ;v1f - released Global $debug = 0, $g_h_GUI, $g_id_ListView Example() Exit Func Example() Local $idRow1, $idRow2, $idRow3, $i, $j, $iRow, $jCol, $string, $aTemp $g_h_GUI = GUICreate("ListView Sort Question", 300, 200) ;get handle in case we need it later ;$g_id_ListView = _GUICtrlListView_Create($g_h_GUI, "Row#|Name|Date ", 10, 10, 280, 180) ;v1d $g_id_ListView = GUICtrlCreateListView("Row#|Name|Date ", 10, 10, 280, 180) ;v1c $iRow = 5 $jCol = 3 Local $aListView[$iRow][$jCol] = _ [ _ ["#1","Alice","01/15/2022"] , _ ["#2","Bob","02/22/2021"] , _ ["#3","Carol","03/13/2021"] , _ ["#10","Dave","10/09/2021"] , _ ["#11","Eve","11/21/2021"] _ ] ;_DebugArrayDisplay($aListView) _GUICtrlListView_AddArray($g_id_ListView, $aListView) ;load listview GUISetState(@SW_SHOW) ;$vCompareType = 0 ;not ok as Row# sort #1, #10, and want #1, #2, ;$vCompareType = 1 ;not ok as Row# sort #1, #10, and want #1, #2, Local $vCompareType = 2 ;Row# okay but Date messed up _GUICtrlListView_RegisterSortCallBack($g_id_ListView, $vCompareType) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $g_id_ListView ;Pause("col="&GUICtrlGetState($g_id_ListView)) If GUICtrlGetState($g_id_ListView) = 2 Then ;date column so we do a special sort For $i = 0 to $iRow - 1 ;overwrite in array col MM/DD/YYYY with YYYYMMDD for sorting purposes $string = $aListView[$i][2] ;initially MM/DD/YYYY format $string = StringRight($string, 4) & StringLeft($string, 2) & StringMid($string, 4, 2) ;now in YYYYMMDD format $aListView[$i][2] = $string ;stuff into array Next If $debug <> 0 Then _DebugArrayDisplay($aListView, "$aListView after converting to YYYYMMDD format") _GUICtrlListView_DeleteAllItems($g_id_ListView) ;clear out listview Pause("Listview cleared") _GUICtrlListView_AddArray($g_id_ListView, $aListView) ;reload listview from array Pause("Listview reloaded with YYYYMMDD date format") _GUICtrlListView_SortItems($g_id_ListView, GUICtrlGetState($g_id_ListView)) ;use standard sort Pause("Standard sort used on YYYYMMDD date format") For $i = 0 to $iRow - 1 ;get each row of listview into array $aTemp = _GUICtrlListView_GetItemTextArray($g_id_ListView, $i) ;get row $i into $aTemp [0] has count For $j = 1 to $aTemp[0] $aListView[$i][$j - 1] = $aTemp[$j] ;stick it back into $aListView Next Next If $debug <> 0 Then _DebugArrayDisplay($aListView, "After loop: $aListView after reading $g_id_ListView") ;now convert YYYYMMDD in array to MM/DD/YYYY format then load array into listview For $i = 0 to $iRow - 1 ;overwrite in array col YYYYMMDD with MM/DD/YYYY $string = $aListView[$i][2] ;YYYYMMDD format $string = StringMid($string, 5, 2) &"/"& StringRight($string, 2) &"/"& StringLeft($string, 4) ;now in MM/DD/YYYY format $aListView[$i][2] = $string ;stuff into array Next If $debug <> 0 Then _DebugArrayDisplay($aListView, "$aListView after YYYYMMDD to MM/DD/YYYY") ;now stuff back into listview _GUICtrlListView_DeleteAllItems($g_id_ListView) ;clear out listview _GUICtrlListView_AddArray($g_id_ListView, $aListView) ;reload listview from array Pause("Listview reloaded with MM/DD/YYYY date format") Else ;use standard sort _GUICtrlListView_SortItems($g_id_ListView, GUICtrlGetState($g_id_ListView)) ;use standard sort EndIf EndSwitch WEnd _GUICtrlListView_UnRegisterSortCallBack($g_id_ListView) GUIDelete($g_id_ListView) EndFunc ;Func Example() Func Pause($text="") If $debug <> 0 Then MsgBox(262144, "DEBUG", "Paused: " & $text) EndFunc
-
Luke94 reacted to mikell in ListView sorting on date
A simpler way using a workaround : create a col #3 (width=0) for sorting only
;#AutoIt3Wrapper_run_debug_mode=Y #include <GUIConstantsEx.au3> #include <GuiListView.au3> #Include <Array.au3> Global $g_id_ListView Example() Exit Func Example() Local $array[5] = [ _ "#1|Alice|01/15/2022", _ "#2|Bob|02/22/2021", _ "#3|Carol|03/13/2021", _ "#10|Dave|10/09/2021", _ "#11|Eve|11/21/2021"] ; _ArrayDisplay($array) GUICreate("ListView Sort Question", 300, 200) $g_id_ListView = GUICtrlCreateListView("Row#|Name|Date| ", 10, 10, 280, 180) For $i = 0 to UBound($array)-1 GUICtrlCreateListViewItem($array[$i] & "|" & StringRegExpReplace($array[$i], '.*(\d{2})/(\d{2})/(\d{4})', "$3$1$2"), $g_id_ListView) Next _GUICtrlListView_SetColumnWidth($g_id_ListView, 3, 0) GUISetState(@SW_SHOW) _GUICtrlListView_RegisterSortCallBack($g_id_ListView) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $g_id_ListView ;MsgBox(0,"","col="&GUICtrlGetState($g_id_ListView)) ; If col 2 is clicked then use col 3 for sorting <<<<<<<<<<<<<<<<<<<<<< If GUICtrlGetState($g_id_ListView) = 2 Then _GUICtrlListView_SortItems($g_id_ListView, 3) EndSwitch WEnd _GUICtrlListView_UnRegisterSortCallBack($g_id_ListView) GUIDelete($g_id_ListView) EndFunc ;Func Example()
-
Luke94 reacted to Subz in Understanding how to use @AppDataDir when building out a path location
FileExists (@AppDataDir & "\Microsoft\Word\Startup\Normal.dotm")
-
Luke94 got a reaction from junkew in How to scrape names from Whatsapp Web
Have a look at junkew's IUIAutomation UDF or Danp2's WebDriver UDF.
-
Luke94 reacted to Melba23 in How to use StringRegExpReplace keep unknow character itself and replcae
jimmy123j,
This seems to do the trick:
$sString_1 = "ABC12+ABC34-AB5>CD60=CD50" $sString_2 = StringRegExpReplace($sString_1, "(\W)", " $1 ") ConsoleWrite($sString_2 & @CRLF) $sString_1 = "<TD> BKColor=#FF12BC TextColor=#ACF9F9 <span> ABC > ???? </span> > A15F </TD>" $sString_2 = StringRegExpReplace($sString_1, "^(.*> >).*(</TD>)$", "$1 123456 $2") ConsoleWrite($sString_2 & @CRLF) Please ask if you have any questions.
M23
-
Luke94 got a reaction from argumentum in Why can't arrays contain variables?
I may still be misunderstanding so apologies if so.
Maybe a Map?
Maybe an Enum?
#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> ;~ Global $arrayall[3] = [$Label1, $Label2, $Label3, $Label4] Global Enum $LABEL_1 = 0, $LABEL_2, $LABEL_3, $LABEL_4 Global $g_iLabelID[4] #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 529, 437, 192, 124) $Label1 = GUICtrlCreateLabel("", 56, 24, 100, 17) $Label2 = GUICtrlCreateLabel("", 56, 64, 100, 17) $Label3 = GUICtrlCreateLabel("", 56, 104, 100, 17) $Label4 = GUICtrlCreateLabel("", 56, 144, 100, 17) $Button1 = GUICtrlCreateButton("SET", 56, 184, 36, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $arrayall[4] = [$Label1, $Label2, $Label3, $Label4] While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _SETDATA() EndSwitch WEnd Func _SETDATA() For $i = 0 To (UBound($arrayall) - 1) GUICtrlSetData($arrayall[$i], 'Set data') Next GUICtrlSetData($arrayall[$LABEL_3], 'This is Label 3') EndFunc
-
Luke94 got a reaction from ad777 in _ArraySearch "bug" ? - (Moved)
I guess how it is now is correct? You would never search a singular item because you wouldn't need to search it.
You wouldn't search among the rock. You'd just check to see if the rock was what you was looking for?
#include <Array.au3> Global $topPoints = [["Jos", 1000], ["jchd", 900], ["TommyDDR", 800]] Global $playerToFind = "TommyDDR" For $i = 3 To 1 Step -1 Local $top = isTopPoints($playerToFind, $i-1) ? " is in TOP " : " is not in TOP " ConsoleWrite($playerToFind & $top & $i & @CRLF) Next Func isTopPoints($player, $nbMax) If $nbMax = 0 Then Return ($topPoints[0][0] = $player) Else Return _ArraySearch($topPoints, $player, 0, $nbMax) >= 0 EndIf EndFunc
-
Luke94 got a reaction from _Ray in How to use array as input in IE
Line 177 needs changing to:
Local $datawb = _Excel_BookOpen($oExcel, @ScriptDir & '\SBMO Store setting input.xlsx') You we're passing '\SBMO Store setting input.xlsx' into the $bReadOnly parameter.
-
Luke94 got a reaction from Danp2 in How to use array as input in IE
Line 177 needs changing to:
Local $datawb = _Excel_BookOpen($oExcel, @ScriptDir & '\SBMO Store setting input.xlsx') You we're passing '\SBMO Store setting input.xlsx' into the $bReadOnly parameter.
-
Luke94 reacted to Jos in Auto refresh label in GUI
Nah, you don't want that assuming the GuiGetMsg() is still in that loop giving the 10msecs pause already.
-
Luke94 got a reaction from bobomb in USB Burning tool for PE projects - (Progress Bar options, and disk list)
The command is executed and once completed the console is read. You could split $line with @CRLF and loop through the return array?
-
Luke94 got a reaction from bobomb in USB Burning tool for PE projects - (Progress Bar options, and disk list)
@bobomb, does this work?
Func CopyDataFilesD() Local $GoFiles = ($CachePath & $finaldirs), $StartProgAt, $xcopycmd, $line = "" FileOpen($GoFiles, 0) Local $aArray[1000] ReDim $aArray[_FileCountLines($GoFiles) + 1] For $i = 1 To _FileCountLines($GoFiles) $newline = FileReadLine($GoFiles, $i) $aArray[$i] = $newline Next _ArraySort($aArray) $StartProgAt = 65 For $i = 1 To UBound($aArray) - 1 $xcopycmd = Run('cmd /c xcopy ' & $MountedDrive & ':\' & $aArray[$i] & ' ' & $dataDrive & ':\' & $aArray[$i] & ' /i /s /e /h /r /v /y', @WorkingDir, @SW_HIDE, 2) ProcessWaitClose($xcopycmd) $line = StdoutRead($xcopycmd) If $aArray[$i] = "Programs" Then ProgressSet($StartProgAt & "%", "Copying " & $line) $StartProgAt = ($StartProgAt + 15) Else ProgressSet($StartProgAt & "%", "Copying " & $line) $StartProgAt = ($StartProgAt + 1) EndIf Next EndFunc ;==>CopyDataFilesD You may want to write $line to the Console to see what's been returned by StdoutRead.
-
Luke94 got a reaction from bobomb in USB Burning tool for PE projects - (Progress Bar options, and disk list)
Local $aLines = StringSplit($line, @CRLF) Local $sLastLine = $aLines[(UBound($aLines) - 1)]