Jump to content

Search the Community

Showing results for tags 'lock'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 10 results

  1. Hi Virtual People, I'm trying to lock my screen in Windows 10 but to no avail. Has Windows 10 forbidden this feature? Send("#l") Above code does not work. Even sending Ctrl Alt Del does not work nor as an Admin. Note: I want to lock my screen, not log off. Thanks for been kind.
  2. I've run into the problem where multiple script processes writing to a log file at the same time can interfere with one another. That is, file writes using FileWriteLine are not atomic, so a line of text from one process can have fragments of text from other processes mixed in with it. Exclusive file-locking should take care of the problem. Looking through the standard UDFs, I see that _WinAPI_LockFile is available, but according to the MSDN documentation it doesn't block - it returns immediately if the lock can't be obtained - and there doesn't seem to be a UDF for the LockFileEx function. I considered writing my own UDF for LockFileEx, but some aspects (e.g., creating the OVERLAPPED structure and its members) look too complex for the amount of time I have available. I think approximating LockFileEx using LockFile could solve my problem, but I'd like to keep it simple while still working reliably. I'm not confident that (e.g.) a simple retry loop to simulate blocking will be adequate. Any suggestions for a simple way to achieve exclusive file-locking with blocking?
  3. I want to sell some small scripts, simple stuff for a few bucks. How can I make sure users need a password to use it? Or maybe a licence that is good for a year? Lifetime? I realize this is a very broad question...but can somebody point me in the right direction to get this done? Scripts will be small automation snippets. Thanks THanks
  4. My password is in English but I often use my native language when I use the computer. Is it possible to make a script that runs in the background and changes active language to English whenever computer is locked via winkey+l? I tried using the AssignKey function, however while it did seem to work for other keys, winkey+l (or any other combination involving winkey) did not work. Is there a way around this?
  5. Hi These example apps can be used to lock the keyboard and mouse (useful for test automation). I've also included a Toddler/Child Lock app which lets them press some keys A-Z and 0-9 and move the mouse and plays a sound. Its uses BlockInputEx UDF Most example ALT+ESC to end enjoy KeyBoardMouseLock.zip
  6. Ever wanted to use Autoit to lock up your flash drive at home? Well here's the code for it. Code from user LvlUp and some minor modification from me. All props to LvlUp and his coding abilities and assistance with this code. Here's the main code: #NoTrayIcon #include <Misc.au3> #include <eject.au3> Opt("TrayMenuMode",1) $menu = TrayCreateItem("DriveLocker") $menu2 = TrayCreateItem("") $menuLock = TrayCreateItem("Lock Drive") $menuExit = TrayCreateItem("Exit") TraySetState() While 1 $letter = DriveGetDrive("REMOVABLE") If IsArray($letter) Then For $i = 1 to $letter[0] _Check($letter[$i]) Next EndIf $time = TimerInit() While TimerDiff($time) < 10000 $msg = TrayGetMsg() TrayItemSetState($msg,4) Select Case $msg = $menuLock _LockDrive() Case $msg = $menuExit Exit EndSelect Sleep(100) WEnd WEnd Func _Check($strDriveLetter) If FileExists($strDriveLetter & "\IAmLocked") Then _Unlock($strDriveLetter) EndFunc Func _Unlock($strDriveLetter) $strPassword = InputBox("Security Check", "Enter your password.", "", "*", "", "", @DesktopWidth/2, @DesktopHeight/2,15, "passwordBox") ToolTip("Enter Password NOW.") _MouseTrap(@DesktopWidth, @DesktopHeight-100) If ($strPassword = "password") Then _MouseTrap() FileDelete($strDriveLetter & "\IAmLocked") _ReAnimate($strDriveLetter) Else EjectVolume($strDriveLetter) _MouseTrap() EndIf EndFunc Func _ReAnimate($strDriveLetter) ;Closes the autoplay window if open WinClose("AutoPlay") EndFunc Func _LockDrive() $letter = DriveGetDrive("REMOVABLE") If IsArray($letter) Then For $i = 1 To $letter[0] If MsgBox(36,"Lock This Drive?","Do you wish to lock the " & StringUpper($letter[$i]) & " drive?") = 6 Then FileWrite($letter[$i] & "\IAmLocked","Locked") EjectVolume($letter[$i]) EndIf Next EndIf EndFunc And the includes file for eject.au3 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WinApi.au3> ;Prototypes ;BOOL EjectVolume(TCHAR cDriveLetter); ;HANDLE OpenVolume(TCHAR cDriveLetter); ;BOOL LockVolume(HANDLE hVolume); ;BOOL DismountVolume(HANDLE hVolume); ;BOOL PreventRemovalOfVolume(HANDLE hVolume, BOOL fPrevent); ;BOOL AutoEjectVolume(HANDLE hVolume); ;BOOL CloseVolume(HANDLE hVolume); ;StringFormat Output $szVolumeFormat = "\\\\.\\%s" $szRootFormat = "%s\\" $szErrorFormat = "Error %d: %s\n" ;------------------------------------------ ;Arbitrary variables ;;Global Const $INVALID_HANDLE_VALUE = 0 ;------------------------------------------ ;DeviceIoControl Contants Global Const $FSCTL_LOCK_VOLUME = int(0x090018) Global Const $FSCTL_DISMOUNT_VOLUME = int(0x00090020) Global Const $IOCTL_STORAGE_EJECT_MEDIA = int(0x002D4808) Global Const $IOCTL_STORAGE_MEDIA_REMOVAL = int(0x002D4804) ;------------------------------------------ ;Retry Constants Global Const $LOCK_TIMEOUT = 10000 ; 10 Seconds Global Const $LOCK_RETRIES = 20 ;$OpenVolume = InputBox("Ejecting...", "Enter the drive to eject", "G:") ;ConsoleWrite("Trying to Eject the drive " & EjectVolume($OpenVolume) & @crlf) Func ReportError($szMsg) ConsoleWrite(StringFormat($szErrorFormat, _WinAPI_GetLastErrorMessage (), $szMsg) & @CRLF) Exit EndFunc ;==>ReportError Func OpenVolume($cDriveLetter) ;HANDLE hVolume ;UINT uDriveType ;TCHAR szVolumeName[8] ;TCHAR szRootName[5] ;DWORD dwAccessFlags $szRootName = StringFormat($szRootFormat, $cDriveLetter) $uDriveType = DriveGetType($szRootName); ConsoleWrite($szRootName & @tab & $uDriveType & @crlf) Switch $uDriveType Case "Removable" $dwAccessFlags = 6 Case "CDROM" $dwAccessFlags = 2 Case Else ConsoleWrite("Cannot eject. Drive type is incorrect." & @CRLF) Return $INVALID_HANDLE_VALUE EndSwitch $szVolumeName = StringFormat($szVolumeFormat, $cDriveLetter) ;$szVolumeName = $szVolumeFormat & $cDriveLetter ConsoleWrite($szVolumeName & @crlf ) $hVolume = _WinAPI_CreateFile ($szVolumeName, 2,$dwAccessFlags, 6) #cs hVolume = CreateFile( szVolumeName, dwAccessFlags, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL ); #ce If ($hVolume == $INVALID_HANDLE_VALUE) Then ReportError("CreateFile"); Return $hVolume; EndFunc ;==>OpenVolume Func CloseVolume($hVolume) Return _WinAPI_CloseHandle ($hVolume); EndFunc ;==>CloseVolume Func LockVolume($hVolume) Local $dwBytesReturned Local $dwSleepAmount Local $nTryCount local $iRead $dwSleepAmount = $LOCK_TIMEOUT / $LOCK_RETRIES; ; Do this in a loop until a timeout period has expired For $nTryCount = 0 To $nTryCount < $LOCK_RETRIES If _Device_Control($hVolume, $FSCTL_LOCK_VOLUME, $iRead) Then Return True Else Sleep($dwSleepAmount); EndIf Next Return False; EndFunc ;==>LockVolume Func DismountVolume($hVolume) ConsoleWrite("Dismount " & $hVolume & @crlf) Local $dwBytesReturned, $iRead local $aResult = _Device_Control($hVolume, $FSCTL_DISMOUNT_VOLUME, $iRead) ;msgbox(0,"",$aResult) Return $aResult ;Return $dwBytesReturned EndFunc ;==>DismountVolume Func PreventRemovalOfVolume($hVolume, $fPreventRemoval) Local $dwBytesReturned Local $aResult Local $lpInbuffer,$nInBufferSize,$lpOutBuffer,$nOutBufferSize,$lpOverlapped $PMRBUFFER = DllStructCreate("bool PreventMediaRemoval") DllStructSetData($PMRBUFFER,"PreventMediaRemoval",$fPreventRemoval) $lpBytesReturned = DllStructCreate("int Read") $pRead = DllStructGetPtr($lpBytesReturned, "Read") $aResult = Dllcall("kernel32.dll","int","DeviceIoControl","hwnd",$hVolume,"uint",$IOCTL_STORAGE_MEDIA_REMOVAL,"ptr",DllStructGetPtr($PMRBUFFER),"uint",DllStructGetSize($PMRBUFFER), _ "ptr",$lpOutBuffer,"uint",$nOutBufferSize,"ptr",$pRead,"ptr",$lpOverlapped) if $aResult = 0 then msgbox(0,"",_WinAPI_GetLastErrorMessage()) Return $aResult <> 0 ;& PMRBuffer, sizeof (PREVENT_MEDIA_REMOVAL), ;NULL, 0, ; & dwBytesReturned, ;NULL); EndFunc ;==>PreventRemovalOfVolume Func AutoEjectVolume($hVolume) Local $aResult, $iRead; $aResult = _Device_Control($hVolume, $IOCTL_STORAGE_EJECT_MEDIA, $iRead) Return $aResult EndFunc ;==>AutoEjectVolume Func EjectVolume($cDriveLetter) Local $hVolume; Local $fRemoveSafely = False; Local $fAutoEject = False; ; Open the volume. $hVolume = OpenVolume($cDriveLetter); If $hVolume == $INVALID_HANDLE_VALUE Then Return False ; Lock and dismount the volume. If LockVolume($hVolume) And DismountVolume($hVolume) Then $fRemoveSafely = True; ConsoleWrite("Volume Locked and Dismounted, trying to Eject " & @crlf) ; Set prevent removal to false and Eject the volume. If PreventRemovalOfVolume($hVolume, False) And AutoEjectVolume($hVolume) Then $fAutoEject = True; EndIf Else ConsoleWrite("Volume can't be locked or dismounted, please close possible opened files" & @crlf) EndIf ; Close the volume so other processes can use the drive. If CloseVolume($hVolume) = False Then Return False; EndIf If $fAutoEject Then ConsoleWrite(StringFormat("Media in drive %s has been ejected safely.\n", $cDriveLetter)) Else If $fRemoveSafely Then ConsoleWrite(StringFormat("Media in drive %s can be safely removed.\n", $cDriveLetter)) EndIf EndIf Return True; EndFunc ;==>EjectVolume Func _Device_Control($hDevice, $dwIoControlAutoit, ByRef $iRead) Local $aResult Local $lpInbuffer,$nInBufferSize,$lpOutBuffer,$nOutBufferSize,$lpOverlapped $tRead = DllStructCreate("int Data") $aResult = Dllcall("kernel32.dll","int","DeviceIoControl","hwnd",$hDevice,"uint",$dwIoControlAutoit,"ptr",$lpInBuffer,"uint",0, _ "ptr",$lpOutBuffer,"uint",0,"ptr",DllStructGetPtr($tRead),"ptr",$lpOverlapped) $iRead = DllStructGetData($tRead, "Data") ConsoleWrite("Device Control " & $iRead & @CRLF) Return $aResult<>0 EndFunc ;==>_Device_Control Enjoy.
  7. Hi there! I created this stuff for anyone who wants to lock down their computer for a period of time. Very useful for parents to lock their son's computer It is very hard to terminate the program by Task Manager because it blocks your input every second and even shutting down Windows is useless because it starts on WIndows startup. Enjoỳ̀̀̀̀̀̀̀̀̀̀̀̀̀̀ <snip> To use it, please compile. Hey, my member's title is "Polymath", what does it mean?
  8. Hi, Is it possible to lock a Windows dll (like user32) to block any function call from other applications? Thanks for anyhelp. Br, FireFox.
  9. good afternoon there is some function in AutoIT like (_BlockInputEx) but joystick to lock the buttons of the joystick you want? thank you
  10. Note: This is completely unrelated to the program offered on TuCows and CNET, I named it without ever checking the title, and I may decide to change it at will. What Does it do? This program allows you to require a specific drive (USB preferably) to be connected to the computer to gain access while the program is running. Downloads: USBLock.zip (Includes Source code, Compiled version, and English .LANG file) UPDATES: (click "see post" to see notes on changes) Version 6: see post Version 5: see post Version 4: see post Version 3: see post Version 2: see post ----------------------------------- -How does it do it? 1a. On a normal run, the program will ask you for a drive letter to assign as a "Key Drive". 1b. A drive letter is assigned by command-line parameter. 1c. The "auto" parameter is used, and we skip to Step 4. 2. The Program will then generate a random keyfile, save a hash of the keyfile locally and save the actual keyfile on the root of the chosen/validated drive. 3. Waits until the keydrive is removed. 4. BlockInput is called 5. Then the program then checks repeatedly for the existence of the keyfile on all drives 6. The keyfile is validated, if it is valid, BlockInput is released and we return tp Step 2. 7. Assuming the keyfile is invalid, it is deleted and we return to step 5. Note: There is a special keyfile that can be saved on a drive that will shut down the program to allow emergency access. (if you edit the emergency text in the script, you will need to edit your own emergency keyfile) USBLock_Emergency_Keyfile.zip Requirements: WindowsConstants.au3 GUIConstants.au3 StaticConstants.au3 String.au3 Misc.au3 myToast.au3 - by me (given) MD5.au3 - which is either by: - Ward (Using CallWindowProc; I suggest this one.) - Frez Systems Ltd and SvenP (all AutoIt) - Other Credits: Monitor On/Off Example - MrCreatoR MD5 - SvenP or Ward ... let me know if you were missed for credit. EDIT: fixed the "steps" explanation 5-5-13 Edit: Re-added images to post
×
×
  • Create New...