Leaderboard
Popular Content
Showing content with the highest reputation on 03/12/2019 in all areas
-
Close multiple processes in Array
RestrictedUser and one other reacted to Subz for a topic
Slightly modified version, to close all instances: Global $aProcess Global $arrProcess[4] = ["notepad.exe", "word.exe", "firefox.exe", "chrome.exe"] For $i = 0 To UBound($arrProcess) - 1 Step 1 If ProcessExists($arrProcess[$i]) Then ConsoleWrite('Closing process "' & $arrProcess[$i] & '"' & @CRLF) $aProcess = ProcessList($arrProcess[$i]) For $j = 1 To $aProcess[0][0] If ProcessClose($aProcess[$j][1]) Then ConsoleWrite(" - Instance: " & $j & " closed." & @CRLF) Else ConsoleWrite(" - Instance: " & $j & " cannot be closed." & @CRLF) EndIf Next Else ConsoleWrite('The process "' & $arrProcess[$i] & '"' & " doesn't exist." & @CRLF) EndIf Next2 points -
Close multiple processes in Array
Subz and one other reacted to FrancescoDiMuro for a topic
@Colduction Global $arrProcess[4] = ["notepad.exe", "word.exe", "firefox.exe", "chrome.exe"] For $i = 0 To UBound($arrProcess) - 1 Step 1 If ProcessExists($arrProcess[$i]) Then ConsoleWrite("Closing process '" & $arrProcess[$i] & "'" & @CRLF) If ProcessClose($arrProcess[$i]) Then ConsoleWrite("Process closed." & @CRLF) Else ConsoleWrite("Cannot close the process." & @CRLF) EndIf Else ConsoleWrite("The process '" & $arrProcess[$i] & "' doesn't exist." & @CRLF) EndIf Next You can find more about arrays here, and, youo don't need to make all those loops.2 points -
Copy and and replace Text From One file to another - (Moved)
Earthshine and one other reacted to BrewManNH for a topic
So, you're asking why he's doing the right thing by declaring the variables, rather than which scope he's using? Good coding practice tells you you should always declare your variables with the proper scope. Without the Global, he'd need a new line for all of the variables he's declaring, which in this case he is by using the continuation character, but didn't need to. It's true, that the variables would have been automatically declared in the global scope, but he's showing the proper method.2 points -
Get an array of pixels of a certain color #include <ScreenCapture.au3> #include <Array.au3> $iColor = 0xFF0000 ; red $hBitmap = _ScreenCapture_Capture() Global $iIndex, $tSize = _WinAPI_GetBitmapDimension($hBitmap), _ $iWidth = $tSize.X, $iHeight = $tSize.Y, $iSize = $iWidth * $iHeight, _ $aPixels[$iSize + 1][2] ; DllStructGetData test $iTime = TimerInit() $tBits = DllStructCreate("dword[" & $iSize & "]") _WinAPI_GetBitmapBits($hBitmap, $iSize * 4, DllStructGetPtr($tBits)) For $i = 0 To $iHeight - 1 For $j = 0 To $iWidth - 1 $iIndex += 1 If BitAND(DllStructGetData($tBits, 1, $iIndex), 0x00FFFFFF) = $iColor Then $aPixels[0][0] += 1 $aPixels[$aPixels[0][0]][0] = $j $aPixels[$aPixels[0][0]][1] = $i EndIf Next Next ReDim $aPixels[$aPixels[0][0] + 1][2] ConsoleWrite("DllStructGetData: " & Round(TimerDiff($iTime)) & "ms" & @CRLF) _ArrayDisplay($aPixels) ; StringInStr test $iTime = TimerInit() $tBits = DllStructCreate('byte[' & $iSize * 4 & ']') _WinAPI_GetBitmapBits($hBitmap, $iSize * 4, DllStructGetPtr($tBits)) $sText = StringTrimLeft(DllStructGetData($tBits, 1), 2) $iStep = $iWidth * 8 Dim $aPixels[$iSize + 1][2], $aLines[$iHeight], $c = 0 For $i = 1 To StringLen($sText) Step $iStep $aLines[$c] = StringMid($sText, $i, $iStep) $c += 1 Next Dim $iPos, $iStart, $iLen = StringLen($aLines[0]) $iColor = StringRegExpReplace(Hex($iColor, 6), "(.{2})(.{2})(.{2})", "$3$2$1") For $i = 0 To $iHeight - 1 $iStart = 1 While $iStart <= $iLen $iPos = StringInStr($aLines[$i], $iColor, 1, 1, $iStart) If $iPos Then If Mod($iPos - 1, 8) Then $iStart = $iPos + 2 ContinueLoop EndIf $aPixels[0][0] += 1 $aPixels[$aPixels[0][0]][0] = ($iPos - 1) / 8 $aPixels[$aPixels[0][0]][1] = $i $iStart = $iPos + 8 Else ExitLoop EndIf WEnd Next ReDim $aPixels[$aPixels[0][0] + 1][2] ConsoleWrite("StringInStr: " & Round(TimerDiff($iTime)) & "ms" & @CRLF) _ArrayDisplay($aPixels) _WinAPI_DeleteObject($hBitmap)2 points
-
Hi, the question is, why does anyone need an "AutoIt-Array of Pixels", every bitmap IS an array of width x height "pixels". So reading $aPixels[$i][$j] = DllStructGetData($tBits, 1, $iIndex) causes me physical pain...the slowest and wasteful memory method to "store" a bitmap...which is by the way loaded in RAM at this time... Not that i prefer _GDIPlus_BitmapLockBits to get a pointer to a bitmap or CreateDIBSection (which gives you pointer/handle/DC...) but once you got the pointer, you can easily catch the color of the x- and y-koordinates by simply addressing it. $color = DllStructGetData($tBits, 1, ($Width*$y + $x) ;x and y are the koordinates (0-based) of the "pixel" in the bitmap Yes, AutoIt is very slow with calculations within nested loops, but dllstructgetdata() is as fast as $aPixels[$i][$j]. Very much faster are all native String-Functions in AutoIt. You can use them to find or manipulate "colors" in a bitmap: $tBits = DllStructCreate("char[" & $iSize*4 & "]") ;every ARGB is a "word" of 4 char gives you access to a "string". So a "pixelsearch" is easily and superfast done with a StringInstr()...2 points
-
Version 1.7.0.1
10,054 downloads
Extensive library to control and manipulate Microsoft Outlook. This UDF holds the functions to automate items (folders, mails, contacts ...) in the background. Can be seen like an API. There are other UDFs available to automate Outlook: OutlookEX_GUI: This UDF holds the functions to automate the Outlook GUI. OutlookTools: Allows to import/export contacts and events to VCF/ICS files and much more. Threads: Development - General Help & Support - Example Scripts - Wiki BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort KNOWN BUGS (last changed: 2020-02-09) None1 point -
Close multiple processes in Array
RestrictedUser reacted to FrancescoDiMuro for a topic
@Colduction You're welcome1 point -
Run script as System or Administrator on non-access user
RestrictedUser reacted to AdamUL for a topic
To not get the UAC prompt for Admins, without completely turning off UAC. You would want to set the ConsentPromptBehaviorAdmin to 0, which is $UAC_ELEVATE_WITHOUT_PROMPTING. I wrote a UDF for this. This function call would need to be in a different script, run as admin, to set the setting. After that, your scripts with #RequireAdmin or a compiled script with the manifest set to requireAdministrator will run without the UAC prompt. As mentioned in the UDF: "Use this option only in the most constrained environments." #RequireAdmin #include <UAC.au3> _UAC_SetConsentPromptBehaviorAdmin($UAC_ELEVATE_WITHOUT_PROMPTING) Adam1 point -
You learn something new each day1 point
-
Copy and and replace Text From One file to another - (Moved)
FrancescoDiMuro reacted to BrewManNH for a topic
How would you have declared it? It's not in a function, and other than the UDF functions, there aren't any in the snippet, so Global is the only reasonable declaration of it.1 point -
Run script as System or Administrator on non-access user
RestrictedUser reacted to benched42 for a topic
Well I tried that at one time by building the admin password one character at a time using the CHR() function. For a password of "Password1" the code I wrote initially was very rudimentary: $theAdminPassword = Chr(80) & Chr(97) & Chr(115) & Chr(115) & Chr(119) & Chr(111) & Chr(114) & Chr(100) & Chr(49) Doesn't do a lot to stop a clever and determined user, but does obfuscate it somewhat. Another way is to put the numbers into a text file and read them line by line to build the admin password. Then you can easily change admin passwords without rewriting code. I wrote something like this later as we changed our admin password: $fHandle = FileOpen({some UNC path to a public file on the network}, 0) $theAdminPassword = "" While 1 FileReadLine($fHandle, $theChar) If @error ExitLoop Endif $theAdminPassword = $theAdminPassword & Chr($theChar) WEnd FileClose($fHandle)1 point -
get multiple files selected from the file explorer context menu
pixelsearch reacted to LarsJ for a topic
You can do it this way: ; Windows Explorer on XP, Vista, 7, 8 $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then Exit ; Shell object $oShell = ObjCreate( "Shell.Application" ) ; Find window For $oWindow In $oShell.Windows() If $oWindow.HWND() = $hExplorer Then ExitLoop Next ; Selected items For $oItem In $oWindow.Document.SelectedItems() ConsoleWrite( $oItem.Path() & @CRLF ) Next1 point -
@Nine AndyG is very much correct Local $iSize = 4096 Local $tBits = DllStructCreate("char[" & $iSize * 4 & "]") ;every ARGB is a "word" of 4 char Local $sAlpha = "ACTG" For $i = 1 To $iSize * 4 DllStructSetData($tBits, 1, StringMid($sAlpha, Random(1, 4, 1), 1), $i) Next ConsoleWrite(StringInStr(DllStructGetData($tBits, 1), "TAGC") & @crlf) @InnI Showoff1 point
-
Rangeread can read more than just one cell at a time, and returns 2d array. is your data not next to each other in the sheet?1 point
-
As you are only reading a few rows/columns I would use _Excel_RangeRead to read the whole used range and then process the returned array.1 point
-
I will help you to give it a try. Me and some other helpers I am sure. Please can you provide us some elements to help us to help you : -First of all start any windows from comodo's firewall. A windows where you have any button. -Then you spy this button information with simple spy then you provide us the complete information from SimpleSpy. -If no one do it before me; I ll give you a line that should work with it and good syntax. (If it work with that kind of GUI.*)1 point
-
Modify Windows Contextmenu - (Moved)
AndroidZero reacted to nacerbaaziz for a topic
here is an example about what you want brother #RequireAdmin $ext = ".txt" $mainName = "custtome menu" $mainIcon = "c:\test.ico" $mainPosition = "Top" ;avalable options (Top and middle or Bottom) $name1 = "open with notepad" $icon1 = "c:\test1.ico" $path1 = "c:\Windows\system32\notepad.exe %1" $name2 = "Delete file" $icon2 = "c:\test2.ico" $path2 = 'c:\Windows\System32\cmd.exe /c Del "%1" & exit' If Not ($ext = "*") Then $read = RegRead("HKEY_CLASSES_ROOT\" & $ext, "") If @error Then $ext = StringReplace($ext, ".", "") & "File" Else $ext = $read EndIf Else $ext = "*" EndIf $HKCR = "HKCR" If @OSArch = "x64" Then $HKCR = "HKCR64" ;writing the main menu RegWrite($HKCR & "\" & $ext & "\shell\" & $mainName, "MUIVerb", "REG_SZ", $mainName) RegWrite($HKCR & "\" & $ext & "\shell\" & $mainName, "Icon", "REG_SZ", $mainIcon) RegWrite($HKCR & "\" & $ext & "\shell\" & $mainName, "ExtendedSubCommandsKey", "REG_SZ", $ext & "\shell\" & $mainName & "\Options") RegWrite($HKCR & "\" & $ext & "\shell\" & $mainName, "Position", "REG_SZ", $mainPosition) ;writing the sub menu RegWrite($HKCR & "\" & $ext & "\shell\" & $mainName & "\Options\shell\" & $name1, "MUIVerb", "reg_sz", $name1) RegWrite($HKCR & "\" & $ext & "\shell\" & $mainName & "\Options\shell\" & $name1, "Icon", "reg_sz", $icon1) RegWrite($HKCR & "\" & $ext & "\shell\" & $mainName & "\Options\shell\" & $name1 & "\command", "", "reg_sz", $path1) RegWrite($HKCR & "\" & $ext & "\shell\" & $mainName & "\Options\shell\" & $name2, "MUIVerb", "reg_sz", $name2) RegWrite($HKCR & "\" & $ext & "\shell\" & $mainName & "\Options\shell\" & $name2, "Icon", "reg_sz", $icon2) RegWrite($HKCR & "\" & $ext & "\shell\" & $mainName & "\Options\shell\" & $name2 & "\command", "", "reg_sz", $path2) Exit1 point -
Coukld you please try this code snippet? Local $oExcel = _Excel_Open() $oExcel.EnableEvents = False Local $BulkMut = _Excel_BookOpen($oExcel, $BulkMut_path & $BulkMut_File) $oExcel.EnableEvents = True1 point
-
@MattH O sorry, i didn't see your second post here, check this function, i wrote it a long time ago, but i changed it a little now so it will return only parent paths (if $iRet = 1)... #include <Array.au3> ;Only for _ArrayDisplay() $sPath = @MyDocumentsDir $Results = _FileFind($sPath, "*.txt", 1, 1) If @error = 3 Then MsgBox(48, "Attention", "No files found.") Else _ArrayDisplay($Results) EndIf ;Flag = 1 search with recurse ;Flag <> 1 search without recurse ; ;$iRet = 1 return parent directory of the file path ;$iRet <> 1 return full file path ;On Failure set @error as following: ; 1 - $sPath is not a dir or it not exists (in this case returned -1). ; 2 - $sPath is empty dir. ; 3 - No files found in $sPath dir. ; ;On Seccess return array with founded files. Func _FileFind($sPath, $Mask, $Flag=0, $iRet=0) If Not StringInStr(FileGetAttrib($sPath), "D") Then Return SetError(1, 0, -1) Local $RetPathArr[1], $FindNextFile, $CurrentPath, $SubDirFindArr, $Ubound = 0 If StringInStr($Mask, "*") Then $Mask = StringReplace($Mask, "*.", "") $sPath = StringRegExpReplace($sPath, '\\+ *$', '\') Local $FindFirstFile = FileFindFirstFile($sPath & "\*.*") If @error = 1 Then Return SetError(2, 0, 0) If $FindFirstFile = -1 Then Return SetError(3, 0, 0) While 1 $FindNextFile = FileFindNextFile($FindFirstFile) If @error = 1 Then ExitLoop $CurrentPath = $sPath & "\" & $FindNextFile If $Flag = 1 And StringInStr(FileGetAttrib($CurrentPath), "D") Then $SubDirFindArr = _FileFind($CurrentPath, $Mask, $Flag) If IsArray($SubDirFindArr) Then For $i = 1 To UBound($SubDirFindArr)-1 $Ubound = UBound($RetPathArr) ReDim $RetPathArr[$Ubound+1] $RetPathArr[$Ubound] = $SubDirFindArr[$i] If $iRet = 1 Then $RetPathArr[$Ubound] = StringRegExpReplace($RetPathArr[$Ubound], "\\[^\\]*$", "") Next EndIf Else If $Mask = "*" Or $FindNextFile = $Mask Or StringRegExpReplace($CurrentPath, '^.*\.', '') = $Mask Then $Ubound = UBound($RetPathArr) ReDim $RetPathArr[$Ubound+1] $RetPathArr[$Ubound] = $CurrentPath If $iRet = 1 Then $RetPathArr[$Ubound] = $sPath EndIf EndIf WEnd FileClose($FindFirstFile) If $Ubound = 0 Then Return SetError(3, 0, 0) $RetPathArr[0] = $Ubound Return $RetPathArr EndFunc1 point
-
[Solved] How to attach to an already running Chrome instance ?
Exit reacted to JLogan3o13 for a topic
Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states: Moderation Team0 points