Jump to content
SuleymanTopaloglu

Example Kiosk-Screensaver (PREVENTED CTRL+ALT+DEL)

Recommended Posts

SuleymanTopaloglu
Posted (edited)

Hello i am new here and this is my first thread

in this script i used some code snippets from forum.

I do not remember who these belonged to.

Disabled

ALT+F4

ALT+TAB

TASK MANAGER

LOCKING WINDOWS

deleted items from ctrl+alt+delete screen

(Lock Computer,Switch User,Sign Out,Chance a password,Task Manager)

 

CTRL+ALT+DELETE (how ?)

firstly we are disabled locking computer

RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableLockWorkstation',"REG_DWORD",0x00000001)

and then ctrl+alt+delete pressed IsDesktopLocked() triggered.

we are calling  

Run("rundll32.exe user32.dll,LockWorkStation")

command with checking if $blockctrlaltdel = 1 statements. 

then it return us to kiosk screen, because we are disabled locking computer. 

 

Func IsDesktopLocked()
    Local $hDesktop
    Local $iRet
    Local $iRC
    Local $sMsg
    Local Const $DESKTOP_SWITCHDESKTOP = 0x100
    $hDesktop = DllCall("User32.dll", "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", $DESKTOP_SWITCHDESKTOP)
    $iRet = DllCall("User32.dll", "int", "SwitchDesktop", "int", $hDesktop[0])
    If IsArray($iRet) Then
        If $iRet[0] = 0 Then
            if $blockctrlaltdel = 1 Then
               Run("rundll32.exe user32.dll,LockWorkStation")
            EndIf
            $iRC = 1
        ElseIf $iRet[0] = 1 Then

            $iRC = 0
        EndIf
    Else

    EndIf
    DllCall("User32.dll", "int", "CloseDesktop", "int", $hDesktop[0]);<-- handle returned by "OpenDesktop"
    ;$iRet = DllCall("User32.dll", "int", "CloseDesktop", "int", $iRet[0])
    Return ($iRC)
 EndFunc   ;==>IsDesktopLocked

maybe this blocked to lock computer when rdp session closed. i havent tried and This script needed to Google chrome and "WinLockDll.dll" to work. 

FULL SCRIPT

 

#include <WinAPI.au3>
#include <FontConstants.au3>
#include <GUIConstants.au3>

Opt('GUIOnEventMode', 1)
Opt("TrayAutoPause", 0)
HotKeySet("{ESCAPE}","_EXIT")
;~ $sFilePath = "D:\kiosk\"
local $Form1,$blockctrlaltdel
Global Const $VK_F4 = 0x73
Global $winlockdll = DllOpen(@ScriptDir&"\WinLockDll.dll")
kullanimkapat()

#region ; WinEventHook
Global Const $EVENT_OPEN_DESKTOP_CHANGED = 0x0020
$h_DLL_User32 = DllOpen("User32.dll")
$h_WinEventHook_Proc = DllCallbackRegister("_WinEventHook_Proc", "none", "hwnd;int;hwnd;long;long;int;int")
If @error Then
    ConsoleWrite("Error DllCallbackRegister(_WinEventHook_Proc) did not succeed. FFH will exit now.")
    Exit
EndIf
$h_Hook = _WinEventHook_Set(0x0020, 0x0020, $h_DLL_User32)
If @error Then
    ConsoleWrite("Error _WinEventHook_Set() did not succeed. FFH will exit now.")
    Exit
EndIf
OnAutoItExitRegister("_WinEventHook_UnSet")
#endregion ; WinEventHook
Global $winlockdll = DllOpen(@ScriptDir&"\WinLockDll.dll")

Func kullanimkapat()
   $blockctrlaltdel = 1
   Global $hHookProc = DllCallbackRegister("_KeyboardProc", "long", "int;wparam;lparam")
   Global $hHookKeyboard = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hHookProc), _WinAPI_GetModuleHandle(0), 0)
   Global $hSysTray_Handle = DllCall("user32.dll", "HWND", "FindWindow", "str", "Shell_TrayWnd", "str", "")
   _WinAPI_ShellChangeNotify($SHCNE_ASSOCCHANGED, 0, 0, 0)
   _SendMessage($hSysTray_Handle[0], 0x5B4, 0, 0)
   DllCall($winlockdll, "Int", "Keys_Enable_Disable ", "Int", "1")
   DllCall($winlockdll, "Int", "TaskManager_Enable_Disable", "Int", "0")
   DllCall($winlockdll, "Int", "TaskSwitching_Enable_Disable", "Int", "0")
   DllCall($winlockdll, "Int", "Keys_Enable_Disable", "Int", "1")
   RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableChangePassword',"REG_DWORD",0x00000001)
   RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System', 'HideFastUserSwitching', "REG_DWORD",0x00000001)
   RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', 'NoLogoff',"REG_DWORD",0x00000001)
   RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', 'NoClose',"REG_DWORD",0x00000001)
   RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableTaskMgr',"REG_DWORD",0x00000001)
   RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableLockWorkstation',"REG_DWORD",0x00000001)
   FileDelete ( @LocalAppDataDir&"\Google\Chrome\User Data\Default\Preferences" )
;~    Local $hFileOpen = FileOpen($sFilePath,BitOR(8,2))
;~    FileWrite($hFileOpen,'<!DOCTYPE html><meta http-equiv="refresh" content="30"><html><head><script type="text/javascript">function disableselect(e){return!1}function reEnable(){return!0}document.onselectstart=new Function("return false"),document.oncontextmenu=new Function("return false"),window.sidebar&&(document.onmousedown=disableselect,document.onclick=reEnable);</script><style>#masano{top:50%;left:50%;width:250px;height:250px;margin-top:-125px;margin-left:-125px;border:1px solid red;background-color:red;position:fixed;font:normal 200px Calibri;line-height:250px;text-align:center;color:white}</style><title>*</title></head><body><div id="masano">'&@ComputerName&'</div></body></html>"')
;~    FileClose($hFileOpen);kiosk html writed
   Run("taskkill /im chrome.exe /f /t")
   Sleep(3000)
;~    Run(@HomeDrive&"\Program Files (x86)\Google\Chrome\Application\chrome.exe --kiosk "&$sFilePath)
   Run(@HomeDrive&"\Program Files (x86)\Google\Chrome\Application\chrome.exe --kiosk https://www.autoitscript.com/autoit3/files/graphics/autoit_10_wall_1920x1200.jpg")
   WinMinimizeAll()
   Global $hSplash = GuiCreate("", @DesktopWidth+5, @DesktopHeight+5, -5, -5,$WS_POPUP,$WS_THICKFRAME) ;invinsible fullscreen gui on top google chrome.
   GUISetBkColor (0xf0f8ff)
   WinSetTrans($hSplash, "", 5)
   GUISetState()
   WinSetOnTop($hSplash, "", 1)
EndFunc

Func kullanimAc()
   FileDelete ( @LocalAppDataDir&"\Google\Chrome\User Data\Default\Preferences" )
   $blockctrlaltdel = 0
   DllCallbackFree($hHookProc)
   If Not IsHWnd($hSysTray_Handle[0]) Then ShellExecute(@WindowsDir & "\Explorer.exe")
   DllCall($winlockdll, "Int", "Keys_Enable_Disable ", "Int", "0")
   DllCall($winlockdll, "Int", "TaskManager_Enable_Disable", "Int", "1")
   DllCall($winlockdll, "Int", "TaskSwitching_Enable_Disable", "Int", "1")
   DllCall($winlockdll, "Int", "Keys_Enable_Disable ", "Int", "0")
   RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System','DisableChangePassword')
   RegDelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System', 'HideFastUserSwitching')
   RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', 'NoLogoff')
   RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', 'NoClose')
   RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableTaskMgr')
   RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableLockWorkstation')
   Run("taskkill /im chrome.exe /f /t")
   Sleep(500)
   GUIDelete($hSplash)
   Sleep(500)
EndFunc
Func _KeyboardProc($nCode, $wParam, $lParam)
    If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam)
    Switch $wParam
        Case $WM_KEYDOWN, $WM_SYSKEYDOWN, $WM_KEYUP, $WM_SYSKEYUP
            Local $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
            Local $vKode = DllStructGetData($tKEYHOOKS, "vkCode")
            Local $iFlags = DllStructGetData($tKEYHOOKS, "flags")

            Switch $vKode
                Case $VK_F4
                    If BitAND($iFlags, $LLKHF_ALTDOWN) Then
                        Return -1
                    Else
                        Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam)
                    EndIf
            EndSwitch
    EndSwitch

    Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam)
EndFunc

#region ; WinEventHook Functions
Func _WinEventHook_Proc($h_Hook, $iEvent, $hWnd, $idObject, $idChild, $iEventThread, $iEventTime)
    ;ConsoleWrite($hWnd & @TAB & $idObject & @CRLF)
    ConsoleWrite(TimerInit() & @tab & hex($iEvent,4) & @tab & "IsDesktopLocked()" & @tab & IsDesktopLocked() & @crlf)
EndFunc   ;==>_WinEventHook_Proc

Func _WinEventHook_Set($iEventMin, $iEventMax, $hDLLUser32)
    Local $aRet
    Local Const $WINEVENT_OUTOFCONTEXT = 0x0
    Local Const $WINEVENT_SKIPOWNPROCESS = 0x2
    If Not $hDLLUser32 Or $hDLLUser32 = -1 Then $hDLLUser32 = "User32.dll"
    $aRet = DllCall($hDLLUser32, "hwnd", "SetWinEventHook", _
            "uint", $iEventMin, _
            "uint", $iEventMax, _
            "hwnd", 0, _
            "ptr", DllCallbackGetPtr($h_WinEventHook_Proc), _
            "int", 0, _
            "int", 0, _
            "uint", $WINEVENT_OUTOFCONTEXT) ; BitOR($WINEVENT_OUTOFCONTEXT, $WINEVENT_SKIPOWNPROCESS)
    If @error Then Return SetError(@error, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_WinEventHook_Set

Func _WinEventHook_UnSet()
    If $h_WinEventHook_Proc Then
        DllCallbackFree($h_WinEventHook_Proc)
    EndIf
    If $h_Hook Then DllCall($h_DLL_User32, "int", "UnhookWinEvent", "hwnd", $h_Hook)
    If $h_DLL_User32 Then DllClose($h_DLL_User32)
EndFunc   ;==>_WinEventHook_UnSet
#endregion ; WinEventHook Functions


Func IsDesktopLocked()
    Local $hDesktop
    Local $iRet
    Local $iRC
    Local $sMsg
    Local Const $DESKTOP_SWITCHDESKTOP = 0x100
    $hDesktop = DllCall("User32.dll", "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", $DESKTOP_SWITCHDESKTOP)
    $iRet = DllCall("User32.dll", "int", "SwitchDesktop", "int", $hDesktop[0])
    If IsArray($iRet) Then
        If $iRet[0] = 0 Then
            if $blockctrlaltdel = 1 Then
               Run("rundll32.exe user32.dll,LockWorkStation")
            EndIf
            $iRC = 1
        ElseIf $iRet[0] = 1 Then

            $iRC = 0
        EndIf
    Else

    EndIf
    DllCall("User32.dll", "int", "CloseDesktop", "int", $hDesktop[0]);<-- handle returned by "OpenDesktop"
    ;$iRet = DllCall("User32.dll", "int", "CloseDesktop", "int", $iRet[0])
    Return ($iRC)
 EndFunc   ;==>IsDesktopLocked



Func _EXIT()
   kullanimAc()
   HotKeySet("{ESCAPE}")
   Exit
EndFunc


While 1
   Sleep(100)
WEnd

 

WinLockDll.dll

 

pc-kilitle.au3

Edited by SuleymanTopaloglu

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Darknightx37
      By Darknightx37
      Hay there i try to create a gui and delete them on my secound monitore when i was in a fullscreen application but i noticed that i got tabed out of the application every time i created a new gui
      how to fix that i get tabed out i already tryed with winsetontop("application", "", 1)
      thx
       
      --> @SW_SHOWNOACTIVATE
      sry im stupid
    • wakillon
      By wakillon

      A little animated Screensaver based on FavIcons
    • wakillon
      By wakillon
      A little Screensaver based on FavIcons
      Like this screenshot

      Most websites use 16x16 Icons, so for a better display i used only those who have a 32x32 format.
      Thanks to :
      Ward for his BinaryCall UDF ( for call in memory lzma.dll and titchisid.dll )
      and trancexx for his ResourcesViewerAndCompiler ( for create the huge icons resource dll )
      If you have some time to loose, you can get files in the Download Section 
       
      Edit 1 : Config is available via right click on compiled version.
      Edit 2 : Last version do not use lzma.dll and icons resource dll but an ImageList from a jpg for store the 730 "icons"
    • RTFC
      By RTFC
      Two tiny, simple scripts (secondDesktop & desktopSwitch) that elaborate (slightly) on _WinAPI_CreateDesktop() to create a second workspace with some interesting features:
      Startup: define any number of programmes to be auto-started on the second desktop, hard-coded (by you, in desktopSwitch.au3) or parsed as parameters (from secondDesktop.au3); Full desktop mode: provides acccess to all your desktop shortcuts, start menu (Win7), taskbar, plus a one-button switch in both desktops; Kiosk mode: provides an empty workspace where only your designated startup entries will run; Switch button/GUI is absent; an unadvertised hotkey provides switching to the original desktop (Ctrl-Alt-Del still works, but a task manager started on the second desktop will appear on the original desktop). To enable kiosk mode, set flag $kioskmode=True in secondDesktop.au3; Security: software keyloggers running in your regular environment cannot capture keystrokes on the second desktop, and windows messages cannot be sent between desktops, so your apps won't be hijacked easily through remote control. (NB not extensively tested; use at your own risk!) In full desktop mode, the (red or green) background colour of the Switch GUI shows you whether you are on the exposed or secure desktop. I SecondDesktop.v0.8.7z (first beta release)
      Important: you'll need to compile desktopSwitch before running secondDesktop. You can test your edited version of desktopSwitch.au3 "dry," as a script on your regular desktop first, by setting its internal flag $testing=True; but don't forget to reset that flag again before compiling.
    • Valiante
      By Valiante
      Hi,
      I've searched but can only find posts from people with the opposite problem (asking how to get their GUI to display on top of a full-screen app, usually a game.
      I've created a toolbar which I use in a work environment, creating the GUI with the following styles;
      $hwnd = GUICreate($title, $toolbarWidth, $height, $left, $top, $WS_POPUPWINDOW, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))   I want it to have a TOPMOST style as it's supposed to behave like the Windows taskbar (which it does in all but one scenario).   If I start a full-screen RDP session, I can still see my toolbar and have to close it.  Is there a way I can make it appear on top of all windows *except* full-screen apps (in the same way the taskbar allows full-screen apps on top of it)?   Thanks in advance.   Val.
×