Leaderboard
Popular Content
Showing content with the highest reputation on 06/15/2018 in all areas
-
I want ideas and T.I.Ps as a beginner
Earthshine and one other reacted to junkew for a topic
read the help file examples https://www.autoitscript.com/wiki/AutoIt_Snippets Looking at your code Use indentation/style formatting (as referred to Tidy can help in formatting layout) Learn to make functions Put comments in your code to see what you functionally want Do not use cryptic variables $enDowns is probably better written as englishDownloadFolder Probably this is much easier to use/at least its shorter local $myFolder=getDownloadFolder() $filePath = FileOpenDialog("إختر ملف الرقمنة", $myFolder, "ملف نقاط (*.men)", 1) func getDownloadFolder() local $downloadFolders[]=[@UserProfileDir & "\Downloads", _ @UserProfileDir & "\Téléchargement", _ @DesktopDir] For $i = 0 To UBound($downloadFolders) - 1 If (FileExists($downloadFolders[$i])) Then return $downloadFolders[$i] Next EndFunc and after that I am lost in what your code is doing. It seems a mem file that has multiple sections you try to split with some cryptic naming of variables like $I $II $III2 points -
Version 1.6.3.0
17,293 downloads
Extensive library to control and manipulate Microsoft Active Directory. Threads: Development - General Help & Support - Example Scripts - Wiki Previous downloads: 30467 Known Bugs: (last changed: 2020-10-05) None Things to come: (last changed: 2020-07-21) None BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort1 point -
LockFile() - Lock a file to the current process only.
krasnoshtan reacted to guinness for a topic
LockFile allows you to lock a file to the current process. This is useful if you want to interact with a specific file but wish to avoid the accidental deletion by another process or worse still a user. Examples have been provided and any advice for improvements is much appreciated. UDF: #include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; #INDEX# ======================================================================================================================= ; Title .........: Lock_File ; AutoIt Version : v3.3.10.0 or higher ; Language ......: English ; Description ...: Lock a file to the current process only. Any attempts to interact with the file by another process will fail ; Note ..........: ; Author(s) .....: guinness ; Remarks .......: The locked file handle must be closed with the Lock_Unlock() function after use ; =============================================================================================================================== ; #INCLUDES# ========================================================================================================= #include <WinAPI.au3> ; #GLOBAL VARIABLES# ================================================================================================= ; None ; #CURRENT# ===================================================================================================================== ; Lock_Erase: Erase the contents of a locked file ; Lock_File: Lock a file to the current process only ; Lock_Read: Read data from a locked file ; Lock_Reduce: Reduce the locked file by a certain percentage ; Lock_Write: Write data to a locked file ; Lock_Unlock: Unlock a file so other processes can interact with it ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; None ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Erase ; Description ...: Erase the contents of a locked file ; Syntax ........: Lock_Erase($hFile) ; Parameters ....: $hFile - Handle returned by Lock_File() ; Return values .: Success - True ; Failure - False, use _WinAPI_GetLastError() to get additional details ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Erase($hFile) _WinAPI_SetFilePointer($hFile, $FILE_BEGIN) Return _WinAPI_SetEndOfFile($hFile) EndFunc ;==>Lock_Erase ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_File ; Description ...: Lock a file to the current process only ; Syntax ........: Lock_File($sFilePath[, $bCreateNotExist = False]) ; Parameters ....: $sFilePath - Filepath of the file to lock ; $bCreateNotExist - [optional] Create the file if it doesn't exist (True) or don't create (False). Default is False ; Return values .: Success - Handle of the locked file ; Failure - Zero and sets @error to non-zero. Call _WinAPI_GetLastError() to get extended error information ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_File($sFilePath, $bCreateNotExist = False) Return _WinAPI_CreateFile($sFilePath, BitOR($CREATE_ALWAYS, (IsBool($bCreateNotExist) And $bCreateNotExist ? $CREATE_NEW : 0)), BitOR($FILE_SHARE_WRITE, $FILE_SHARE_DELETE), 0, 0, 0) ; Creation = 2, Access = 2 + 4, Sharing = 0, Attributes = 0, Security = 0 EndFunc ;==>Lock_File ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Read ; Description ...: Read data from a locked file ; Syntax ........: Lock_Read($hFile) ; Parameters ....: $hFile - Handle returned by Lock_File() ; $iBinaryFlag - [optional] Flag value to pass to BinaryToString(). Default is $SB_UTF8. See BinaryToString() documentation for more details ; Return values .: Success - Data read from the file ; Failure - Empty string and sets @error to non-zero ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Read($hFile, $iBinaryFlag = $SB_UTF8) Local $iFileSize = _WinAPI_GetFileSizeEx($hFile) + 1, _ $sText = '' Local $tBuffer = DllStructCreate('byte buffer[' & $iFileSize & ']') _WinAPI_SetFilePointer($hFile, $FILE_BEGIN) _WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer), $iFileSize, $sText) Return SetError(@error, 0, BinaryToString(DllStructGetData($tBuffer, 'buffer'), $iBinaryFlag)) EndFunc ;==>Lock_Read ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Reduce ; Description ...: Reduce the locked file by a certain percentage ; Syntax ........: Lock_Reduce($hFile, $iPercentage) ; Parameters ....: $hFile - Handle returned by Lock_File() ; $iPercentage - A percentage value to reduce the file by ; Return values .: Success - True ; Failure - False. Use _WinAPI_GetLastError() to get additional details ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Reduce($hFile, $iPercentage) If Not IsInt($iPercentage) Then $iPercentage = Int($iPercentage) If $iPercentage > 0 And $iPercentage < 100 Then Local $iFileSize = _WinAPI_GetFileSizeEx($hFile) * ($iPercentage / 100) _WinAPI_SetFilePointer($hFile, $iFileSize) Return _WinAPI_SetEndOfFile($hFile) EndIf Return Lock_Erase($hFile) EndFunc ;==>Lock_Reduce ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Write ; Description ...: Write data to a locked file ; Syntax ........: Lock_Write($hFile, $sText) ; Parameters ....: $hFile - Handle returned by Lock_File() ; $sText - Data to be written to the locked file ; Return values .: Success - Number of bytes written to the file ; Failure - 0 and sets @error to non-zero ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Write($hFile, $sText) Local $iFileSize = _WinAPI_GetFileSizeEx($hFile), _ $iLength = StringLen($sText) Local $tBuffer = DllStructCreate('byte buffer[' & $iLength & ']') DllStructSetData($tBuffer, 'buffer', $sText) _WinAPI_SetFilePointer($hFile, $iFileSize) Local $iWritten = 0 _WinAPI_WriteFile($hFile, DllStructGetPtr($tBuffer), $iLength, $iWritten) Return SetError(@error, @extended, $iWritten) ; Number of bytes written EndFunc ;==>Lock_Write ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Unlock ; Description ...: Unlock a file so other applications can interact with it ; Syntax ........: Lock_Unlock($hFile) ; Parameters ....: $hFile - Handle returned by Lock_File() ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Unlock($hFile) Return _WinAPI_CloseHandle($hFile) EndFunc ;==>Lock_Unlock Example 1: (with LockFile) #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> ; Include the LockFile.au3 UDF #include 'LockFile.au3' ; LockFile by guinness Example_1() Func Example_1() ; Path of the locked file Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir) ; Lock the file to this process and create it if not already done so Local $hLock = Lock_File($sFilePath, True) ; Erase the contents of the locked file Lock_Erase($hLock) ; Write random data to the locked file For $i = 1 To 5 Lock_Write($hLock, RandomText(10) & @CRLF) Next ; Read the locked file Local $sRead = Lock_Read($hLock) ; Display the contents of the locked file that was just read MsgBox($MB_SYSTEMMODAL, '', $sRead) ; Display the current file size of the locked file. For example 60 bytes MsgBox($MB_SYSTEMMODAL, '', ByteSuffix(_WinAPI_GetFileSizeEx($hLock))) ; Reduce the file size by 50% Lock_Reduce($hLock, 50) ; Display the reduced size. This will be 50% less than before. For example 30 bytes MsgBox($MB_SYSTEMMODAL, '', ByteSuffix(_WinAPI_GetFileSizeEx($hLock))) ; Delete the locked file. As this is locked the deletion will fail MsgBox($MB_SYSTEMMODAL, '', 'Delete the locked file: ' & _ @CRLF & _ @CRLF & _ FileDelete($sFilePath) & ' (this will return 0, as the file is currently locked).') ; Unlock the locked file Lock_Unlock($hLock) ; Delete the file as it is now unlocked MsgBox($MB_SYSTEMMODAL, '', 'Delete the locked file: ' & _ @CRLF & _ @CRLF & _ FileDelete($sFilePath) & ' (this will return 1, as the file is unlocked).') EndFunc ;==>Example_1 ; Convert a boolean datatype to an integer representation Func BooleanToInteger($bValue) Return $bValue ? 1 : 0 EndFunc ;==>BooleanToInteger ; Append the largest byte suffix to a value Func ByteSuffix($iBytes, $iRound = 2) ; By Spiff59 Local Const $aArray = [' bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB'] Local $iIndex = 0 While $iBytes > 1023 And $iIndex < UBound($aArray) $iIndex += 1 $iBytes /= 1024 WEnd Return Round($iBytes, Int($iRound)) & $aArray[$iIndex] EndFunc ;==>ByteSuffix ; Generate random text Func RandomText($iLength) Local $iRandom = 0, _ $sData = '' For $i = 1 To $iLength $iRandom = Random(55, 116, 1) $sData &= Chr($iRandom + 6 * BooleanToInteger($iRandom > 90) - 7 * BooleanToInteger($iRandom < 65)) Next Return $sData EndFunc ;==>RandomText Example 2: (without LockFile) #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <WinAPIFiles.au3> ; Traditional approach to reading and writing to a file. Due to the nature of AutoIt, the file isn't locked, thus allowing other processes to interact with the file Example_2() Func Example_2() ; Path of the locked file Local $sFilePath = _WinAPI_GetTempFileName(@TempDir) ; Lock the file to this process and create it if not already done so This is writing mode Local $hLock = FileOpen($sFilePath, $FO_OVERWRITE) ; Erase the contents of the locked file FileWrite($hLock, '') ; Write random data to the locked file For $i = 1 To 5 FileWrite($hLock, RandomText(10) & @CRLF) Next ; Close the file handle and create another handle to read the file contents FileClose($hLock) $hLock = FileOpen($sFilePath, $FO_READ) ; Read the locked file Local $sRead = FileRead($hLock) ; Display the contents of the locked file that was just read MsgBox($MB_SYSTEMMODAL, '', $sRead) ; Delete the locked file. As this is not locked by AutoIt the file will be deleted MsgBox($MB_SYSTEMMODAL, '', 'Delete the locked file: ' & _ @CRLF & _ @CRLF & _ FileDelete($sFilePath) & ' (this will return 1, as the file is''t locked by AutoIt due to safety measures in place).') ; Unlock the locked file (though not really locked) FileClose($hLock) EndFunc ;==>Example_2 ; Convert a boolean datatype to an integer representation Func BooleanToInteger($bValue) Return $bValue ? 1 : 0 EndFunc ;==>BooleanToInteger ; Generate random text Func RandomText($iLength) Local $iRandom = 0, _ $sData = '' For $i = 1 To $iLength $iRandom = Random(55, 116, 1) $sData &= Chr($iRandom + 6 * BooleanToInteger($iRandom > 90) - 7 * BooleanToInteger($iRandom < 65)) Next Return $sData EndFunc ;==>RandomText All of the above has been included in a ZIP file. Previous download: 866+ LockFile.zip1 point -
Slow down CPU = cooler CPU = fan idle
Danyfirex reacted to argumentum for a topic
The back story: I've got a Dell XPS w/ i7-8700K. The fastest, by single core, I could get, by well known PC maker. The problem is that the fan can get so loud, like, REALLY LOUD, I can not use the CPU at its max. clock speed. I could leave it at 90% all the time and not use this but I want to have the full 4.x Ghz and no parked cores, at all times, if I can. But as room temperature and CPU load changes, a set throttle, may still make fan noise. The solution: To avoid the fan from going "airplane turbine mode", the utility gets the temp. from "Core Temp" ( you can google it ) It has a"plug-in" called "Core Temp Remote Server". The utility gets the values via TCP. When it "feels" it's gonna get hot, drops the CPU throttle to a selected value, lets say 99% ( where is quieter ) and back up to 100% when it "feels" is ok to go back. Now temperature can creep up to higher than expected if load is sustained or room temperature changes. So there is an "anti creep up" feature, to temporarily set the throttle even lower, 5% at a time, until the known quiet temperature is achieved. If don't know how to find the temperature you should use, check out these videos. They will tell you how. https://www.youtube.com/watch?v=p3B5WCJZTuw&ab_channel=SergeantPope-KomadaComputerRepair https://www.youtube.com/watch?v=VuP6I0mOb1s&ab_channel=Techquickie https://www.google.com/search?q=find+max+cpu+temperature The end result: Any thermal problem, is a hardware problem. No way around that, other than attending to the CPU cooling and case ventilation. Software can not fix that. But without this utility, the PC would slow down the CPU anyway, to keep it from melting. This software preemptively slow down the CPU, keeping the CPU related fan speeds from going to maximum RPM. Hence having a slower, but a quieter box. The files are in the download section of the forum.1 point -
Forum search .selectnodes. return that to a variable like $oRoles. xpath is //role Loop through like: For $oRole in $oRoles consolewrite ($oRole.text & @crlf) Next1 point
-
Embed DLLs in script and call functions from memory (MemoryDll UDF)
yutijang reacted to argumentum for a topic
1 point -
Protect a single exe
Earthshine reacted to ViciousXUSMC for a topic
Instead of RDP use something like TeamViewer and have the server auto log in and auto launch the application. Use group policy to disable logoff or shutdown options for that generic account. Or see if you can use policy to notify a user of a RDP request and give them permissions to deny/accept a disconnect before somebody takes over the session. Also wrapping the .exe in Autoit with _Singleton() should ensure only one instance gets run just incase somebody sneaks into the server outside of your security setup. So remove any shortcuts to the .exe directly and make them open it with the autoit wrapper.1 point -
Autoit Get Users SID [HELP]
ufukkreis853 reacted to Subz for a topic
Updated code: #RequireAdmin #include <Array.au3> Global $g_bDebug = False Global $g_aRemotePaths[1][2] _UserSID("All", @ComputerName, 1) _ArrayDisplay($g_aRemotePaths) For $i = 1 To $g_aRemotePaths[0][0] ;~ Uncomment line below to write to remote registry ;~ RegWrite($g_aRemotePaths[$i][1] & "\Software\TunesKit\311", "data4", "REG_SZ", "1") ConsoleWrite('RegWrite("' & $g_aRemotePaths[$i][1] & '\Software\TunesKit\311", "data4", "REG_SZ", "1")' & @CRLF) Next Func _UserSID($_sUserName = "All", $_sRemoteComputer = @ComputerName, $_iFlag = 0) Local $sSidRegKey, $sProfileImagePath $_sRemoteComputer = $_sRemoteComputer <> "" ? StringReplace($_sRemoteComputer, "\", "") : @ComputerName Local Const $sRemoteRegHive = @OSArch = "x64" ? "\\" & $_sRemoteComputer & "\HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" : "\\" & $_sRemoteComputer & "\HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" If $g_bDebug Then ConsoleWrite("$sRemoteRegHive := " & $sRemoteRegHive & @CRLF) Local Const $sProfilesDir = RegRead($sRemoteRegHive, "ProfilesDirectory") If $g_bDebug Then ConsoleWrite("$_sRemoteComputer $sProfilesDir := " & $sRemoteRegHive & @CRLF) Local $i = 1 While 1 $sSidRegKey = RegEnumKey($sRemoteRegHive, $i) If @error Then ExitLoop If $g_bDebug Then ConsoleWrite("$sSidRegKey := " & $sSidRegKey & @CRLF) If $_iFlag And StringLen($sSidRegKey) <= 8 Then ;~ If $_iFlag is set then check if the Sid is Built-in account e.g. SystemProfile, LocalService, NetworkService and skip these accounts $i += 1 ContinueLoop EndIf $sProfileImagePath = RegRead($sRemoteRegHive & $sSidRegKey, "ProfileImagePath") If @error Then ExitLoop If $g_bDebug Then ConsoleWrite("$sProfileImagePath := " & $sProfileImagePath & @CRLF) If $_sUserName = "All" Then _ArrayAdd($g_aRemotePaths, StringTrimLeft($sProfileImagePath, StringInStr($sProfileImagePath, "\", 0, -1)) & "|\\" & $_sRemoteComputer & "\HKEY_USERS\" & $sSidRegKey) If $g_bDebug Then _ArrayDisplay($g_aRemotePaths) ElseIf StringLower($sProfileImagePath) == StringLower($sProfilesDir & "\" & $_sUserName) Then _ArrayAdd($g_aRemotePaths, $_sUserName & "|\\" & $_sRemoteComputer & "\HKEY_USERS\" & $sSidRegKey) EndIf $i += 1 WEnd $g_aRemotePaths[0][0] = UBound($g_aRemotePaths) - 1 EndFunc1 point -
Just test the DPI of the monitor: $iAppDPI = RegRead('HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics', 'AppliedDPI') ConsoleWrite($iAppDPI&@CRLF) and calculate the position of your controls.1 point
-
You can also do it in the registry with the registry functions. Also very easy.1 point
-
1 point
-
Did you happen to name it "notepad.exe"? P.S. Welcome to the forum!1 point
-
I want ideas and T.I.Ps as a beginner
iiSkLz_ reacted to Earthshine for a topic
look up the term Modular Programming and put that into practice. also format the code properly. the full scite editor comes with Tidy to format1 point -
If folder exists...
krasnoshtan reacted to SpookMeister for a topic
His example references the "hosts" file. He is warning that if there is a file with the same name as the directory that you are looking for you will get a false positive. Lets say you make a folder called C:\Testing and in it you put a file called "xyz" now if you tried $folder="C:\Testing\xyz" IF FileExist($folder) Then MsgBox(0,"Folder Found","The folder " & $folder & " exists") The IF statement would return as true even though its not really a folder1 point -
If folder exists...
krasnoshtan reacted to JerryD for a topic
While FileExists() will work most of the time, it can return a false positive if a FILE with the name of the DIRECTORY you're looking for exists. For example, let's say you're looking for the DIRECTORY: C:\WINDOWS\system32\drivers\etc\hosts Try DirGetSize()1 point