Jump to content

Recommended Posts

Posted (edited)

This function is in SciTE - if you use this program, press F11. I asked Neil from SciTE to tell me how it is done, and he gave me the code of this function. I used API functions from this code and this is my effect - Fullscreen / Kiosk Mode in AutoIT3!

#include <GUIConstants.au3>
#include <GuiStatusBar.au3>
Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC", 0)
$WorkArea = DllStructCreate("int;int;int;int")
DllCall("user32.dll", "int", "SystemParametersInfo", "int", 0x30, "int", 0, "ptr", DllStructGetPtr($WorkArea), "int", 0)
$WorkAreaX = DllStructGetData($WorkArea,3)
$WorkAreaY = DllStructGetData($WorkArea,4)
$TaskBar = DllCall("user32.dll","int","FindWindow","str","Shell_TrayWnd","str","")
$KioskMode = 0
$Pressed = 0

$Main = GUICreate("FullScreen GUI",900,700,@DesktopWidth/2-450,@DesktopHeight/2-350,$WS_CAPTION+$WS_SYSMENU+$WS_SIZEBOX+$WS_MAXIMIZEBOX+$WS_MINIMIZEBOX)
GUISetOnEvent(-3, "SpecialEvents")
GUISetOnEvent(-4, "SpecialEvents")
GUISetOnEvent(-5, "SpecialEvents")
GUISetOnEvent(-6, "SpecialEvents")
GUISetOnEvent(-11, "SpecialEvents")
GUISetOnEvent(-12, "SpecialEvents")

$filemenu = GUICtrlCreateMenu("&File")
$fileitem = GUICtrlCreateMenuItem("Open",$filemenu)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$helpmenu = GUICtrlCreateMenu("?")
$saveitem = GUICtrlCreateMenuItem("Save",$filemenu)
GUICtrlSetState(-1,$GUI_DISABLE)
$infoitem = GUICtrlCreateMenuItem("Info",$helpmenu)
$exititem = GUICtrlCreateMenuItem("Exit",$filemenu)
$recentfilesmenu = GUICtrlCreateMenu("Recent Files",$filemenu,1)
$separator1 = GUICtrlCreateMenuItem("",$filemenu,2)
$viewmenu = GUICtrlCreateMenu("View",-1,1)
$viewstatusitem = GUICtrlCreateMenuitem("Statusbar",$viewmenu)
GUICtrlSetState(-1,$GUI_CHECKED)

$StatusBar = _GuiCtrlStatusBarCreate($Main, -1, "StatusBar")
GUISetState(@SW_SHOW)

Func FullScreen()
Select
    Case $KioskMode = 0
        Global $Size = WinGetPos($Main)
        DllCall("user32.dll","int","ShowWindow","hwnd",$TaskBar[0],"int",@SW_HIDE)
        $NewArea = DllStructCreate("int;int;int;int")
        DllStructSetData($NewArea,1,0)
        DllStructSetData($NewArea,2,0)
        DllStructSetData($NewArea,3,@DesktopHeight)
        DllStructSetData($NewArea,4,@DesktopWidth)
        DllCall("user32.dll","int","SystemParametersInfo","int",0x2F,"int",0,"ptr",DllStructGetPtr($NewArea),"int",0)
        DllCall("user32.dll","int","SetWindowLong","hwnd",$Main,"int",-16,"long",$WS_POPUP)
        GUISetState(@SW_HIDE,$Main)
        GUISetState(@SW_SHOW,$Main)
        WinMove($Main,"",0,0)
        GUISetState(@SW_MAXIMIZE,$Main)
        _GuiCtrlStatusBarResize($StatusBar)
    ;WinSetOnTop($Main,"",1)
        Global $KioskMode = 1
    Case $KioskMode = 1
        DllCall("user32.dll","int","ShowWindow","hwnd",$TaskBar[0],"int",@SW_SHOW)
        $NewArea = DllStructCreate("int;int;int;int")
        DllStructSetData($NewArea,1,0)
        DllStructSetData($NewArea,2,0)
        DllStructSetData($NewArea,3,$WorkAreaX)
        DllStructSetData($NewArea,4,$WorkAreaY)
        DllCall("user32.dll","int","SystemParametersInfo","int",0x2F,"int",0,"ptr",DllStructGetPtr($NewArea),"int",0)
        DllCall("user32.dll","int","SetWindowLong","hwnd",$Main,"int",-16,"long",$WS_CAPTION+$WS_SYSMENU+$WS_SIZEBOX+$WS_MAXIMIZEBOX+$WS_MINIMIZEBOX)
        GUISetState(@SW_HIDE,$Main)
        GUISetState(@SW_SHOW,$Main)
        GUISetState(@SW_RESTORE,$Main)
        WinMove($Main,"",$Size[0],$Size[1],$Size[2],$Size[3])
        _GuiCtrlStatusBarResize($StatusBar)
    ;WinSetOnTop($Main,"",0)
        Global $KioskMode = 0
EndSelect
EndFunc

While 1
    If Pressed(0x7A) <> 0 AND $Pressed = 0 Then
        If WinGetHandle(WinGetTitle("")) = $Main Then FullScreen()
        $Pressed = 1
    Else
        If Pressed(0x7A) = 0 Then $Pressed = 0
    EndIf
Sleep(1)
Wend

Func Pressed($hexKey)
    $result = DllCall("user32.dll","int","GetAsyncKeyState","int",$hexKey)
    Return $result[0]
EndFunc
    
Func SpecialEvents()
    Select
        Case @GUI_CTRLID = -3
            Exit
        Case @GUI_CTRLID = -4
            _GuiCtrlStatusBarResize($StatusBar)
        Case @GUI_CTRLID = -5
            _GuiCtrlStatusBarResize($StatusBar)
        Case @GUI_CTRLID = -6
            _GuiCtrlStatusBarResize($StatusBar)
        Case @GUI_CTRLID = -12
            _GuiCtrlStatusBarResize($StatusBar)
    EndSelect
EndFunc

Big thanks to Neil, because without his help I couldn't make this.

Any modifications / bugfixes would be nice to see.

Edited by rysiora

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
×
×
  • Create New...