Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/01/2018 in all areas

  1. Hi, I wanted to share my very simple but quite handy stopwatch that I use every day for all sorts of stuff. Screen: Features: Pause function Reset function Multiple instances possible Code: Enjoy! alarm.ico
    1 point
  2. Hi everyone, I created a function to gather bitlocker information. It can tell you whether or not a drive is protected, which encryption method is being used, ... I tried to cover all the details in the function description The function (and 3 "internal" functions) : ; #FUNCTION# ==================================================================================================================== ; Name...........: _BitlockerDriveInfo ; Description ...: Get Bitlocker information for one or multiple drives ; Syntax.........: _BitlockerDriveInfo([$sDrive[, $sComputer = @ComputerName[, $bDebug = False]]]) ; Parameters ....: $sDrive - Optional: The drive. Allowed values are: ; |"" - Get the info for all available drives ; |Letter: - Get the info for the specific drive ; $sComputer - Optional: The computer from which the info should be requested ; $bDebug - Optional: Shows the hex ReturnValue from the WMI methods if set to True ; Return values .: Success - Returns a 2D array with the following information ; |[string] Drive Letter ; |[string] Drive Label ; |[string] Volume Type ; |[bool] Initialized For Protection ; |[string] Protection Status ; |[string] Lock Status ; |[bool] Auto Unlock Enabled ; |[bool] Auto Unlock Key Stored ; |[string] Conversion Status ; |[string] Encryption Method ; |[int] Encryption Percentage ; |[string] Wiping Status ; |[int] Wiping Percentage ; |[array] Key Protectors (Or [string] "None" if the drive isn't protected) ; Failure - 0, sets @error to: ; |1 - There was an issue retrieving the COM object. @extended returns error code from ObjGet ; |2 - The specified drive in $Drive doesn't exist ; |3 - There was an issue running the WMI query ; Author ........: colombeen ; Modified.......: ; Remarks .......: Requires to be run with admin elevation. Windows Vista or newer! ; A BIG THANKS to everyone from the community who contributed! ; Related .......: ; Link ..........: ; Example .......: #include <Array.au3> ; $Header = "Drive Letter|Drive Label|Volume Type|Initialized For Protection|Protection Status|" & _ ; "Lock Status|Auto Unlock Enabled|Auto Unlock Key Stored|Conversion Status|Encryption " & _ ; "Method|Encryption Percentage|Wiping Status|Wiping Percentage|Key Protectors" ; _ArrayDisplay(_BitlockerDriveInfo(), "Bitlocker Drive Info", "", 64, Default, $Header) ; =============================================================================================================================== Func _BitlockerDriveInfo($sDrive = "", $sComputer = @ComputerName, $bDebug = False) Local $aConversionStatusMsg[7] = ["Unknown", "Fully Decrypted", "Fully Encrypted", "Encryption In Progress", "Decryption In Progress", "Encryption Paused", "Decryption Paused"] Local $aEncryptionMethodMsg[9] = ["Unknown", "None", "AES_128_WITH_DIFFUSER", "AES_256_WITH_DIFFUSER", "AES_128", "AES_256", "HARDWARE_ENCRYPTION", "XTS_AES_128", "XTS_AES_256"] Local $aKeyProtectorTypeMsg[11] = ["Unknown or other protector type", "Trusted Platform Module (TPM)", "External key", "Numerical password", "TPM And PIN", "TPM And Startup Key", "TPM And PIN And Startup Key", "Public Key", "Passphrase", "TPM Certificate", "CryptoAPI Next Generation (CNG) Protector"] Local $aLockStatusMsg[3] = ["Unknown", "Unlocked", "Locked"] Local $aProtectionStatusMsg[3] = ["Unprotected", "Protected", "Unknown"] Local $aVolumeTypeMsg[3] = ["Operating System Volume", "Fixed Data Volume", "Portable Data Volume"] Local $aWipingStatusMsg[5] = ["Unknown", "Free Space Not Wiped", "Free Space Wiped", "Free Space Wiping In Progress", "Free Space Wiping Paused"] Local $iRow = 0 Local $sRunMethod, $objWMIService, $objWMIQuery, $sDriveFilter, $iProtectionStatus, $iLockStatus, $bIsAutoUnlockEnabled, $bIsAutoUnlockKeyStored, $iConversionStatus, $iEncryptionPercentage, $iEncryptionFlags, $iWipingStatus, $iWipingPercentage, $iEncryptionMethod, $aVolumeKeyProtectorID, $aVolumeKeyProtectors, $iKeyProtectorType $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\" & $sComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption") If @error Then Return SetError(1, @error, 0) If $sDrive <> "" Then Local $iDriveType = _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $sDrive & "'", Default, $sComputer) If @error Or ($iDriveType <> 2 And $iDriveType <> 3) Then Return SetError(2, 0, 0) $sDriveFilter = " WHERE DriveLetter='" & $sDrive & "'" EndIf $objWMIQuery = $objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume" & $sDriveFilter, "WQL", 0) If Not IsObj($objWMIQuery) Then Return SetError(3, 0, 0) Local $aResult[$objWMIQuery.count][14] For $objDrive In $objWMIQuery If $bDebug Then ConsoleWrite(@CRLF & "+> " & $objDrive.DriveLetter & @CRLF) If _WMIMethodExists($objDrive, "GetConversionStatus") Then $sRunMethod = $objDrive.GetConversionStatus($iConversionStatus, $iEncryptionPercentage, $iEncryptionFlags, $iWipingStatus, $iWipingPercentage) If $bDebug Then ConsoleWrite("!> GetConversionStatus 0x" & Hex($sRunMethod) & @CRLF) Else $iConversionStatus = -1 $iWipingStatus = -1 $iEncryptionPercentage = 0 $iWipingPercentage = 0 EndIf If _WMIMethodExists($objDrive, "GetEncryptionMethod") Then $sRunMethod = $objDrive.GetEncryptionMethod($iEncryptionMethod) If $bDebug Then ConsoleWrite("!> GetEncryptionMethod 0x" & Hex($sRunMethod) & @CRLF) Else $iEncryptionMethod = 0 EndIf If _WMIMethodExists($objDrive, "GetKeyProtectors") Then $sRunMethod = $objDrive.GetKeyProtectors("0", $aVolumeKeyProtectorID) If $bDebug Then ConsoleWrite("!> GetKeyProtectors 0x" & Hex($sRunMethod) & @CRLF) Else $aVolumeKeyProtectorID = 0 EndIf If _WMIMethodExists($objDrive, "GetLockStatus") Then $sRunMethod = $objDrive.GetLockStatus($iLockStatus) If $bDebug Then ConsoleWrite("!> GetLockStatus 0x" & Hex($sRunMethod) & @CRLF) Else $iLockStatus = -1 EndIf If _WMIMethodExists($objDrive, "GetProtectionStatus") Then $sRunMethod = $objDrive.GetProtectionStatus($iProtectionStatus) If $bDebug Then ConsoleWrite("!> GetProtectionStatus 0x" & Hex($sRunMethod) & @CRLF) Else $iProtectionStatus = 2 EndIf If _WMIMethodExists($objDrive, "IsAutoUnlockEnabled") Then $sRunMethod = $objDrive.IsAutoUnlockEnabled($bIsAutoUnlockEnabled) If $bDebug Then ConsoleWrite("!> IsAutoUnlockEnabled 0x" & Hex($sRunMethod) & @CRLF) Else $bIsAutoUnlockEnabled = "Unknown" EndIf If _WMIMethodExists($objDrive, "IsAutoUnlockKeyStored") Then $sRunMethod = $objDrive.IsAutoUnlockKeyStored($bIsAutoUnlockKeyStored) If $bDebug Then ConsoleWrite("!> IsAutoUnlockKeyStored 0x" & Hex($sRunMethod) & @CRLF) Else $bIsAutoUnlockKeyStored = "Unknown" EndIf If IsArray($aVolumeKeyProtectorID) And UBound($aVolumeKeyProtectorID) > 0 Then Dim $aVolumeKeyProtectors[UBound($aVolumeKeyProtectorID)][2] For $i = 0 To UBound($aVolumeKeyProtectorID) - 1 $aVolumeKeyProtectors[$i][0] = $aVolumeKeyProtectorID[$i] If _WMIMethodExists($objDrive, "GetKeyProtectorType") Then If $objDrive.GetKeyProtectorType($aVolumeKeyProtectorID[$i], $iKeyProtectorType) = 0 Then $aVolumeKeyProtectors[$i][1]= $aKeyProtectorTypeMsg[$iKeyProtectorType] Else $aVolumeKeyProtectors[$i][1]= "Unknown" EndIf Else $aVolumeKeyProtectors[$i][1] = "Unknown" EndIf Next Else $aVolumeKeyProtectors = "None" EndIf ; DriveLetter $aResult[$iRow][0] = $objDrive.DriveLetter ; DriveLabel $aResult[$iRow][1] = _WMIPropertyValue("VolumeName", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer) ; VolumeType If _WMIPropertyExists($objDrive, "VolumeType") Then $aResult[$iRow][2] = $aVolumeTypeMsg[$objDrive.VolumeType] Else If $objDrive.DriveLetter = _WMIPropertyValue("SystemDrive", "Win32_OperatingSystem", "", Default, $sComputer) Then $aResult[$iRow][2]= $aVolumeTypeMsg[0] ElseIf _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer) = 3 Then $aResult[$iRow][2]= $aVolumeTypeMsg[1] ElseIf _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer) = 2 Then $aResult[$iRow][2]= $aVolumeTypeMsg[2] Else $aResult[$iRow][2]= "Unknown" EndIf EndIf ; IsVolumeInitializedForProtection If _WMIPropertyExists($objDrive, "IsVolumeInitializedForProtection") Then $aResult[$iRow][3] = $objDrive.IsVolumeInitializedForProtection Else $aResult[$iRow][3] = "Unkown" EndIf ; ProtectionStatus $aResult[$iRow][4] = $aProtectionStatusMsg[$iProtectionStatus] ; LockStatus $aResult[$iRow][5] = $aLockStatusMsg[$iLockStatus + 1] ; IsAutoUnlockEnabled $aResult[$iRow][6] = $bIsAutoUnlockEnabled ; IsAutoUnlockEnabled $aResult[$iRow][7] = $bIsAutoUnlockKeyStored ; ConversionStatus $aResult[$iRow][8] = $aConversionStatusMsg[$iConversionStatus + 1] ; EncryptionMethod $aResult[$iRow][9] = $aEncryptionMethodMsg[$iEncryptionMethod + 1] ; EncryptionPercentage $aResult[$iRow][10] = $iEncryptionPercentage ; WipingStatus $aResult[$iRow][11] = $aWipingStatusMsg[$iWipingStatus + 1] ; WipingPercentage $aResult[$iRow][12] = $iWipingPercentage ; KeyProtectors $aResult[$iRow][13] = $aVolumeKeyProtectors $iRow += 1 Next _ArraySort($aResult) Return $aResult EndFunc ;==>_BitlockerDriveInfo Func _WMIPropertyExists($Object, $Property) If Not IsObj($Object) Then Return False For $sProperty In $Object.Properties_ If $sProperty.Name = $Property Then Return True Next Return False EndFunc ;==>_WMIPropertyExists Func _WMIMethodExists($Object, $Method) If Not IsObj($Object) Then Return False For $sMethod In $Object.Methods_ If $sMethod.Name = $Method Then Return True Next Return False EndFunc ;==>_WMIMethodExists Func _WMIPropertyValue($sProperty = "", $sClass = "", $sFilter = "", $sNamespace = Default, $sComputer = @ComputerName) Local $objWMIService, $objWMIQuery If $sClass = "" Or $sProperty = "" Then Return SetError(1, 0, 0) If $sFilter <> "" Then $sFilter = " " & $sFilter If $sNamespace = Default Then $sNamespace = "\root\CIMV2" $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\" & $sComputer & $sNamespace) If @error Then Return SetError(2, @error, 0) $objWMIQuery = $objWMIService.ExecQuery("SELECT * FROM " & $sClass & $sFilter, "WQL", 0x30) If Not IsObj($objWMIQuery) Then Return SetError(3, 0, 0) For $objItem In $objWMIQuery For $Property In $objItem.Properties_ If $Property.Name = $sProperty Then Return $Property.Value EndIf Next Next Return SetError(4, 0, 0) EndFunc ;==>_WMIPropertyValue Example 1: #RequireAdmin #include <array.au3> ; Get information on all available drives Global $test = _BitlockerDriveInfo() If @error Then ConsoleWrite("!> _BitlockerDriveInfo() error: " & @error & ". extended: " & @extended & @CRLF) ElseIf IsArray($test) Then _ArrayDisplay($test, "Bitlocker Drive Info", "", 64, Default, "Drive Letter|Drive Label|Volume Type|Initialized For Protection|Protection Status|Lock Status|Auto Unlock Enabled|Auto Unlock Key Stored|Conversion Status|Encryption Method|Encryption Percentage|Wiping Status|Wiping Percentage|Key Protectors") ; Display the Key Protectors for the first record If IsArray($test[0][13]) Then _ArrayDisplay($test[0][13]) EndIf Example 2: #RequireAdmin #include <array.au3> ; Get information on the C-drive of the current computer + show extra information in the console Global $test = _BitlockerDriveInfo("C:", @ComputerName, True) If @error Then ConsoleWrite("!> _BitlockerDriveInfo() error: " & @error & ". extended: " & @extended & @CRLF) ElseIf IsArray($test) Then ConsoleWrite("Bitlocker information on the " & $test[0][0] & " drive" & @CRLF) ConsoleWrite("Protection Status: " & $test[0][4] & @CRLF) EndIf Screenshot for the first example: Suggestions? Bugs? Just let me know TODO: ??? Version 1.0: Initial release Version 1.1: Fixed: Drive Label will not work when you request the information from a remote system (currently using DriveGetLabel) Fixed: The current fix for the missing VolumeType property in some Windows versions will only work locally Added: New internal function (_WMIPropertyValue()) Version 1.2: Fixed: The drive exists & drive type check only worked locally when a drive was specified in $sDrive
    1 point
  3. I see you did get the crystal ball out since you seem to know already that function wasn't use.
    1 point
  4. ... and why do you say it's a weird name? Jos
    1 point
  5. @youtuber No, since you are going to set "" and the $aUnique element for each element of the array, in your Edit control. Try this: Func _MakeArrayUnique() $aArrayedit = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF, 2) $aUnique = _ArrayUnique($aArrayedit) _ArraySort($aUnique, 0, 1) GUICtrlSetData($Edit1, "") For $i = 1 To $aUnique[0] GUICtrlSetData($Edit1, $aUnique[$i] & @CRLF, 1) Next EndFunc
    1 point
  6. Made another upload available adding Json_ObjGetItems(), Tidied source and fixed au3check warnings. Also updated json-test.au3 a bit. Thanks, Jos
    1 point
  7. Ah ok, well this is originally not my code and really only added the JSON_DUMP() function to it as I thought it would be very useful to others. I am fine when we also clean up the code further and make an update for that. I honestly think these UDF's should be added to the standard AutoIt3 distribution but that means somebody needs to build the helpfilepages and examples. Jos
    1 point
  8. Danp2

    WebDriver questions

    Not sure that is possible. You should read more here and let us know if you come up with a solution.
    1 point
  9. @Lucky_Luke welcome to the forum. Please note that this forum is dedicated to helping you with your own scripts; we do not write them for you. Many people come saying "I'm not a programmer" and find they actually enjoy getting things done with such a powerful language. That said, below are some suggestions to get you started. Look in the help file for the Excel functions. You should be able to use the following to read through your excel list. This is pseudo code only, you will need to plug in all the important bits by reading the help file sections on Excel and _ArrayDisplay. But get this working, and we'll take the next step from there. $oExcel = _Excel_Open() $oWorkbook = _Excel_BookOpen($oExcel, <path to your workbook>) $oRange = _Excel_RangeRead($oWorkbook, Default, <The Column you're looking to read>) _ArrayDisplay($oRange)
    1 point
  10. It actually does; have used this UDF successfully, works as expected. Post your code so we can help you debug...
    1 point
  11. I wanted a timer, could not find what I wanted and wrote this. Posted for the next lazy one, like me, copy'n'paste kind of ppl. And added an "Alarm", ( at times I need it to trigger at a time and not, in so many minutes ) Also added an "insist/replay" ( since I'm coding, might as well have the feature ) #NoTrayIcon #include <TrayConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) ; removes the chance for misspelled variables causing bugs. Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode. Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode. Opt("GUIOnEventMode", 1) ; OnEvent functions notifications Global $seconds = 0, $g_sec, $g_min, $g_hr, $started = False, $sec = 99, $aTimeHold[3], $g_IsAlarm = 0, $iAppTitle, $sAppTitle = timerTitle() $iAppTitle = @extended #Region ### START Koda GUI section ### Form=\\WDMYCLOUDEX4100\Public\[FMIS]\au3_Shared_projects\timerThing.kxf Global $Form1 = GUICreate($sAppTitle, 245, 74, @DesktopWidth - 275 - (40 * $iAppTitle), 20 + (40 * $iAppTitle), -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)) Global $idHour = GUICtrlCreateInput("00", 5, 4, 49, 32, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) Global $idMin = GUICtrlCreateInput("00", 58, 4, 49, 32, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) Global $idSec = GUICtrlCreateInput("00", 110, 4, 49, 32, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) Global $idStart = GUICtrlCreateButton("Start Timer", 163, 6, 75, 61, $BS_MULTILINE) Global $idTitle = GUICtrlCreateInput("", 4, 40, 129, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_WANTRETURN)) Global $idAlarm = GUICtrlCreateCheckbox("", 137, 53, 17, 19, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_RIGHTBUTTON)) Global $idInsist = GUICtrlCreateCheckbox("", 137, 37, 17, 19, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_RIGHTBUTTON)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetFont($idHour, 14, 800) GUICtrlSetFont($idMin, 14, 800) GUICtrlSetFont($idSec, 14, 800) GUICtrlSetFont($idStart, 12, 800) GUICtrlSetFont($idTitle, 12, 800) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUICtrlSetOnEvent($idStart, "idStartClick") GUICtrlSetOnEvent($idTitle, "idTitleChange") GUICtrlSetOnEvent($idAlarm, "idAlarmEvent") TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "OnTray_PRIMARYDOUBLE") GUICtrlSetTip($idStart, 'press ENTER or click' & @CR & @CR & 'once started, on close,' & @CR & 'will move to the tray area.') GUICtrlSetTip($idHour, 'Hours' & @CR & @CR & 'enter the hours' & @CR & 'and press ENTER') GUICtrlSetTip($idMin, 'Minutes' & @CR & @CR & 'enter the minutes' & @CR & 'and press ENTER') GUICtrlSetTip($idSec, 'Seconds' & @CR & @CR & 'enter the seconds' & @CR & 'and press ENTER') GUICtrlSetTip($idTitle, 'Type a title for this' & @CR & 'timer and press ENTER') GUICtrlSetTip($idAlarm, 'Swap between' & @CR & 'Timer and Alarm' & @CR & 'functionality') GUICtrlSetTip($idInsist, 'Replay the alert' & @CR & 'every 10 sec.' & @CR & 'for 10 min.') ;~ If Not FileGetSize("timerThing.wav") Then FileInstall("timerThing.wav", "timerThing.wav") ; if you wanna include your WAV file Global $hForm1 = WinGetHandle($Form1) Global $idDummy = GUICtrlCreateDummy() Global $aAccelKeys[1][2] = [["{Enter}", $idDummy]] GUISetAccelerators($aAccelKeys) GUICtrlSetOnEvent($idDummy, "On_idDummy") While 1 Sleep(50) If Not $started Then ContinueLoop If $sec = @SEC Then ContinueLoop $sec = @SEC Countdown() WEnd Func Form1Close() If $started Then TraySetState(1) WinSetState($hForm1, "", @SW_HIDE) Else GUIDelete() Exit EndIf EndFunc ;==>Form1Close Func Countdown() ; mod. from https://www.autoitscript.com/forum/topic/135227-simple-counter/?do=findComment&comment=950305 If $g_IsAlarm Then If Int(GUICtrlRead($idHour)) = Int(@HOUR) And Int(GUICtrlRead($idMin)) = Int(@MIN) And Int(GUICtrlRead($idSec)) = Int(@SEC) Then $seconds = -1 Else Return EndIf EndIf $g_sec = Mod($seconds, 60) $g_min = Mod($seconds / 60, 60) $g_hr = Floor($seconds / 60 ^ 2) If $seconds < -3 Then Return TrayToolTip() $seconds -= 1 If $seconds = -2 Then GUICtrlSetState($idInsist, $GUI_DISABLE) If GUICtrlRead($idInsist) = 1 Then $seconds = -5 InsistPlayTheWAV() AdlibRegister("InsistPlayTheWAV", 10000) Else playTheWAV() EndIf Return EndIf If $seconds < -1 Then Return GUICtrlSetData($idHour, StringFormat("%02i", $g_hr)) GUICtrlSetData($idMin, StringFormat("%02i", $g_min)) GUICtrlSetData($idSec, StringFormat("%02i", $g_sec)) EndFunc ;==>Countdown Func playTheWAV() OnTray_PRIMARYDOUBLE() WinActivate($hForm1) If Not FileGetSize(@ScriptDir & "\timerThing.wav") Then SoundSetWaveVolume(25) SoundPlay(@WindowsDir & "\media\tada.wav") Else SoundSetWaveVolume(5) SoundPlay(@ScriptDir & "\timerThing.wav") EndIf EndFunc ;==>playTheWAV Func InsistPlayTheWAV() Local Static $t = 0 If $t = 0 Then $t = TimerInit() playTheWAV() If TimerDiff($t) > 600000 Then AdlibUnRegister("InsistPlayTheWAV") $t = 0 EndIf EndFunc ;==>InsistPlayTheWAV Func TrayToolTip() Local $title = $sAppTitle If GUICtrlRead($idTitle) Then $title = GUICtrlRead($idTitle) TraySetToolTip('' & _ $title & @CR & _ GUICtrlRead($idHour) & ":" & GUICtrlRead($idMin) & ":" & GUICtrlRead($idSec) & @CR & @CR & _ 'Double' & @CR & _ 'Click to' & @CR & _ 'restore' & @CR & @CR & ' ') EndFunc ;==>TrayToolTip Func idStartClick() Local $title = $sAppTitle If GUICtrlRead($idTitle) Then $title = GUICtrlRead($idTitle) WinSetTitle($hForm1, "", $title) $sec = 99 $started = Not $started Switch $started Case True GUICtrlSetData($idStart, StringReplace(GUICtrlRead($idStart), "Start", "STOP")) $seconds = (Int(GUICtrlRead($idHour)) * 60 * 60) + (Int(GUICtrlRead($idMin)) * 60) + Int(GUICtrlRead($idSec)) $aTimeHold[0] = StringFormat("%02i", GUICtrlRead($idHour)) $aTimeHold[1] = StringFormat("%02i", GUICtrlRead($idMin)) $aTimeHold[2] = StringFormat("%02i", GUICtrlRead($idSec)) GUICtrlSetState($idStart, $GUI_FOCUS) GUICtrlSetState($idHour, $GUI_DISABLE) GUICtrlSetState($idMin, $GUI_DISABLE) GUICtrlSetState($idSec, $GUI_DISABLE) GUICtrlSetState($idAlarm, $GUI_DISABLE) Case Else GUICtrlSetData($idStart, StringReplace(GUICtrlRead($idStart), "STOP", "Start")) GUICtrlSetData($idHour, $aTimeHold[0]) GUICtrlSetData($idMin, $aTimeHold[1]) GUICtrlSetData($idSec, $aTimeHold[2]) GUICtrlSetState($idHour, $GUI_ENABLE) GUICtrlSetState($idMin, $GUI_ENABLE) GUICtrlSetState($idSec, $GUI_ENABLE) GUICtrlSetState($idAlarm, $GUI_ENABLE) GUICtrlSetState($idInsist, $GUI_ENABLE) GUICtrlSetState($idStart, $GUI_FOCUS) EndSwitch EndFunc ;==>idStartClick Func On_idDummy() Local $i, $s = ControlGetFocus($hForm1) $i = Int(StringRight($s, 1)) If $s = "Button1" Then Return ControlClick($hForm1, "", "Button1") If StringInStr($s, "Edit") Then Switch $i Case 1, 2, 3 Send("{Tab}") EndSwitch EndIf EndFunc ;==>On_idDummy Func idTitleChange() Local $title = $sAppTitle If GUICtrlRead($idTitle) Then $title = GUICtrlRead($idTitle) WinSetTitle($hForm1, "", $title) EndFunc ;==>idTitleChange Func timerTitle() Local $n, $i = 0 For $n = 1 To 1000 If Not WinExists(" Timer thing [" & $n & "]") Then AutoItWinSetTitle(" Timer thing [" & $n & "]") $i = $n - 1 If 40 * $n > @DesktopHeight - 150 Then $i = 1 Return SetError(0, $i, " Timer " & $n) EndIf Next Return SetError(1, $i, " Timer ???") EndFunc ;==>timerTitle Func OnTray_PRIMARYDOUBLE() TraySetState(2) WinSetState($hForm1, "", @SW_SHOW) EndFunc ;==>OnTray_PRIMARYDOUBLE Func idAlarmEvent() ConsoleWrite('+ Func idAlarmEvent() : ' & GUICtrlRead($idAlarm) & @CRLF) If GUICtrlRead($idAlarm) = 1 Then $g_IsAlarm = 1 GUICtrlSetData($idStart, StringReplace(GUICtrlRead($idStart), "Timer", "Alarm")) $sAppTitle = StringReplace($sAppTitle, "Timer", "Alarm") Else $g_IsAlarm = 0 GUICtrlSetData($idStart, StringReplace(GUICtrlRead($idStart), "Alarm", "Timer")) $sAppTitle = StringReplace($sAppTitle, "Alarm", "Timer") EndIf idTitleChange() EndFunc ;==>idAlarmEvent
    1 point
  12. Having used the _SelfDelete() function before, I knew it could be improved upon with adding more functionality to compensate for when an AutoIt error might occur. The version I updated includes the ability to monitor when the process is closed and/or the timer is reached, therefore if an error was to occur with your program and the _SelfDelete() function was called before, it will still delete the executable even with an AutoIt error (due to bad coding of course!) This can't be said for the old version of _SelfDelete() as you'll never have chance to call the function! I also included the option to check either the process name or PID, depending on your preference. Thanks. Function: Using a Batch script. Save as _SelfDelete.au3 #include-once #include <FileConstants.au3> #include <StringConstants.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _SelfDelete ; Description ...: Delete the current executable after it's finished processing and/or the timer has been reached. ; Syntax ........: _SelfDelete([$iDelay = 5[, $fUsePID = False[, $fRemoveDir = False]]]) ; Parameters ....: $iDelay - [optional] An integer value for the delay to wait (in seconds) before stopping the process and deleting the executable. ; If 0 is specified then the batch will wait indefinitely until the process no longer exits. Default is 5 (seconds). ; $fUsePID - [optional] Use the process name (False) or PID (True). Default is False. ; $fRemoveDir - [optional] Remove the script directory as well (True) or only the running executable (False). Default is False. ; Return values .: Success - Returns the PID of the batch file. ; Failure - Returns 0 & sets @error to non-zero ; Author ........: guinness ; Modified ......: ; Remarks .......: The idea for removing the directory came from: http://www.autoitscript.com/forum/topic/137287-delete-scriptdir/ ; Example .......: Yes ; =============================================================================================================================== Func _SelfDelete($iDelay = 5, $fUsePID = Default, $fRemoveDir = Default) If @Compiled = 0 Then Return SetError(1, 0, 0) EndIf Local $sTempFileName = @ScriptName $sTempFileName = StringLeft($sTempFileName, StringInStr($sTempFileName, '.', $STR_NOCASESENSEBASIC, -1) - 1) While FileExists(@TempDir & '\' & $sTempFileName & '.bat') $sTempFileName &= Chr(Random(65, 122, 1)) WEnd $sTempFileName = @TempDir & '\' & $sTempFileName & '.bat' Local $sDelay = '' $iDelay = Int($iDelay) If $iDelay > 0 Then $sDelay = 'IF %TIMER% GTR ' & $iDelay & ' GOTO DELETE' EndIf Local $sRemoveDir = '' If $fRemoveDir Then $sRemoveDir = 'RD /S /Q "' & FileGetShortName(@ScriptDir) & '"' & @CRLF EndIf Local $sAppID = @ScriptName, $sImageName = 'IMAGENAME' If $fUsePID Then $sAppID = @AutoItPID $sImageName = 'PID' EndIf Local Const $iInternalDelay = 2, _ $sScriptPath = FileGetShortName(@ScriptFullPath) Local Const $sData = 'SET TIMER=0' & @CRLF _ & ':START' & @CRLF _ & 'PING -n ' & $iInternalDelay & ' 127.0.0.1 > nul' & @CRLF _ & $sDelay & @CRLF _ & 'SET /A TIMER+=1' & @CRLF _ & @CRLF _ & 'TASKLIST /NH /FI "' & $sImageName & ' EQ ' & $sAppID & '" | FIND /I "' & $sAppID & '" >nul && GOTO START' & @CRLF _ & 'GOTO DELETE' & @CRLF _ & @CRLF _ & ':DELETE' & @CRLF _ & 'TASKKILL /F /FI "' & $sImageName & ' EQ ' & $sAppID & '"' & @CRLF _ & 'DEL "' & $sScriptPath & '"' & @CRLF _ & 'IF EXIST "' & $sScriptPath & '" GOTO DELETE' & @CRLF _ & $sRemoveDir _ & 'GOTO END' & @CRLF _ & @CRLF _ & ':END' & @CRLF _ & 'DEL "' & $sTempFileName & '"' Local Const $hFileOpen = FileOpen($sTempFileName, $FO_OVERWRITE) If $hFileOpen = -1 Then Return SetError(2, 0, 0) EndIf FileWrite($hFileOpen, $sData) FileClose($hFileOpen) Return Run($sTempFileName, @TempDir, @SW_HIDE) EndFunc ;==>_SelfDeleteFunction: Using a VBScript file. Save as _SelfDelete.au3 #include-once #include <FileConstants.au3> #include <StringConstants.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _SelfDelete ; Description ...: Delete the current executable after it's finished processing and/or the timer has been reached. ; Syntax ........: _SelfDelete([$iDelay = 5[, $fUsePID = False[, $fRemoveDir = False]]]) ; Parameters ....: $iDelay - [optional] An integer value for the delay to wait (in seconds) before stopping the process and deleting the executable. ; If 0 is specified then the script will wait indefinitely until the process no longer exits. Default is 5 (seconds). ; $fUsePID - [optional] Use the process name (False) or PID (True). Default is False. ; $fRemoveDir - [optional] Remove the script directory as well (True) or only the running executable (False). Default is False. ; Return values .: Success - Returns the PID of the batch file. ; Failure - Returns 0 & sets @error to non-zero ; Author ........: guinness ; Modified ......: ; Remarks .......: The idea for removing the directory came from: http://www.autoitscript.com/forum/topic/137287-delete-scriptdir/ ; Example .......: Yes ; =============================================================================================================================== Func _SelfDelete($iDelay = 5, $fUsePID = Default, $fRemoveDir = Default) If @Compiled = 0 Then Return SetError(1, 0, False) EndIf Local $sTempFileName = @ScriptName $sTempFileName = StringLeft($sTempFileName, StringInStr($sTempFileName, '.', $STR_NOCASESENSEBASIC, -1) - 1) While FileExists(@TempDir & '\' & $sTempFileName & '.bat') $sTempFileName &= Chr(Random(65, 122, 1)) WEnd $sTempFileName = @TempDir & '\' & $sTempFileName & '.vbs' Local $sDelay = '' $iDelay = Int($iDelay) If $iDelay > 0 Then $sDelay = @TAB & 'iTimeOut = iTimeOut + 1' & @CRLF _ & @TAB & 'If iTimeOut > ' & $iDelay & ' Then' & @CRLF _ & @TAB & @TAB & 'For Each oProcess in oWMIQuery' & @CRLF _ & @TAB & @TAB & @TAB & 'oProcess.Terminate()' & @CRLF _ & @TAB & @TAB & 'Next' & @CRLF _ & @TAB & @TAB & 'iExit = 2' & @CRLF _ & @TAB & 'End If' & @CRLF EndIf Local $sRemoveDir = '' If $fRemoveDir Then $sRemoveDir = 'oFileSystem.DeleteFolder "' & @ScriptDir & '", True' & @CRLF EndIf Local $sAppID = @ScriptName, $sImageName = 'Name' If $fUsePID Then $sAppID = @AutoItPID $sImageName = 'ProcessId' EndIf Local Const $iInternalDelay = 10, _ $sScriptPath = @ScriptFullPath Local Const $sData = 'Option Explicit' & @CRLF _ & 'Dim iExit, iTimeOut, oFileSystem, oProcess, oWMIQuery, oWMIService, sComputer, sFilePath, sWMIQuery' & @CRLF _ & @CRLF _ & 'sFilePath = "' & $sScriptPath & '"' & @CRLF _ & @CRLF _ & 'iExit = 0' & @CRLF _ & 'iTimeOut = 0' & @CRLF _ & 'sComputer = "."' & @CRLF _ & @CRLF _ & 'Set oWMIService = GetObject("winmgmts:" _' & @CRLF _ & @TAB & @TAB & '& "{impersonationLevel=impersonate}!\\" _' & @CRLF _ & @TAB & @TAB & '& sComputer & "\root\cimv2")' & @CRLF _ & @CRLF _ & 'sWMIQuery = "Select * From Win32_Process Where ' & $sImageName & ' = ''' & $sAppID & '''"' & @CRLF _ & @CRLF _ & 'While (iExit = 0)' & @CRLF _ & @TAB & 'Set oWMIQuery = oWMIService.ExecQuery(sWMIQuery)' & @CRLF _ & @TAB & 'If oWMIQuery.Count = 0 Then' & @CRLF _ & @TAB & @TAB & 'iExit = 1' & @CRLF _ & @TAB & 'End If' & @CRLF _ & @TAB & 'WScript.Sleep(1000)' & @CRLF _ & $sDelay _ & 'Wend' & @CRLF _ & @CRLF _ & 'WScript.Sleep(1000)' & @CRLF _ & 'iExit = 0' & @CRLF _ & 'iTimeOut = 0' & @CRLF _ & 'Set oFileSystem = CreateObject("Scripting.FileSystemObject")' & @CRLF _ & 'While (iExit = 0)' & @CRLF _ & @TAB & 'iTimeOut = iTimeOut + 1' & @CRLF _ & @TAB & 'If oFileSystem.FileExists(sFilePath) Then' & @CRLF _ & @TAB & @TAB & 'oFileSystem.DeleteFile sFilePath, True' & @CRLF _ & @TAB & 'End If' & @CRLF _ & @TAB & 'If oFileSystem.FileExists(sFilePath) <> True Then' & @CRLF _ & @TAB & @TAB & 'iExit = 1' & @CRLF _ & @TAB & 'End If' & @CRLF _ & @TAB & 'If iTimeOut > ' & $iInternalDelay & ' Then' & @CRLF _ & @TAB & @TAB & 'iExit = 2' & @CRLF _ & @TAB & 'End If' & @CRLF _ & 'Wend' & @CRLF _ & @CRLF _ & $sRemoveDir _ & 'oFileSystem.DeleteFile WScript.ScriptFullName, True' & @CRLF _ Local Const $hFileOpen = FileOpen($sTempFileName, $FO_OVERWRITE) If $hFileOpen = -1 Then Return SetError(2, 0, False) EndIf FileWrite($hFileOpen, $sData) FileClose($hFileOpen) Return ShellExecute($sTempFileName, @TempDir, @TempDir, '', @SW_HIDE) EndFunc ;==>_SelfDeleteExample use of Function: #include <MsgBoxConstants.au3> #include '_SelfDelete.au3' _SelfDelete(30, 0) ; Start the SelfDelete batch file with a 30 second timer and using the prcocess name rather than the PID. If @error Then Exit MsgBox($MB_SYSTEMMODAL, '_SelfDelete()', 'The script must be a compiled exe to work correctly.') ; Display a warning if the script isn't compiled. EndIf While 1 Sleep(100) ; Wait or manually close the application via the traymenu icon. WEndWARNING: This will delete your executable if the function is called, so take the proper precautions and make sure you backup.
    1 point
  13. Don't forget we need some sort of compatibility for all used OSes. Jos
    1 point
  14. Other alternative... Run(@ComSpec & " /c start microsoft-edge:https://google.com","",@SW_HIDE) Saludos
    1 point
  15. Melba23

    Disable Exiting GUI

    Zari, This disables the red [X] and the System Menu "Close" item: #Include <GUIMenu.au3> $hGUI = GUICreate('MyGUI') $hMenu = _GUICtrlMenu_GetSystemMenu($hGUI) _GUICtrlMenu_EnableMenuItem($hMenu, $SC_CLOSE, $MF_GRAYED, False) ;_GUICtrlMenu_EnableMenuItem($hMenu, $SC_MINIMIZE, $MF_GRAYED, False) _GUICtrlMenu_EnableMenuItem($hMenu, $SC_MAXIMIZE, $MF_GRAYED, False) GUISetState() While 1 Sleep(10) WEndM23
    1 point
  16. As I understand it I think the question your wanting the answer to is "How do I move files, that I only have the name of, using only the mouse?" That is awkward, but if I had the same problem I would: DirCreate() a folder Open it on the desktop with ShellExecute("Explorer", "Path to Folder") WinMove() the folder to an known position (like 0,0) Then FileCopy() the file by name into the new folder Then MouseClickDrag() the file from where it appears in that folder to your chrome browser Then FileDelete() the file from the new folder Repeat Since the file will always appear in the same place this should work.
    0 points
×
×
  • Create New...