Jump to content

Fullscreen CMD


Titurofox
 Share

Recommended Posts

Hi, i've made a little piece of code for all ones that want to put a console window in fullscreen.

I'va made that becaus in Windows 7, the command "ALT+ENTER" (i think), is not working like in XP or other...

With this script, you can put a console window in fullscreen in Windws 7 !

Here's the function :

NOTE: If it's not correcly on all the screen, open a normal cmd, right click the titlebar, go to config, property or thing like that, goto the third tab and put the first value at the top to a number like 1000 and voila !

#include <GUIConstants.au3>

Func ConsoleSetFS($Title = "[CLASS:ConsoleWindowClass]", $Fullscreen = True)
    AutoitSetOption("WinTitleMatchMode", 2)
    $hWin = WinGetHandle($Title)
    If @error == 0 Then
        If $Fullscreen = True Then
            WinSetOnTop($hWin, "", 1)
            $hWnd = $hWin
            $Style = $WS_POPUP
            $ExStyle = 0
            Local $GWL_STYLE = -16
            Local $GWL_EXSTYLE = -20
            Local $SWP_NOMOVE = 0x2
            Local $SWP_NOSIZE = 0x1
            Local $SWP_SHOWWINDOW = 0x40
            Local $SWP_NOZORDER = 0x4
            Local $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER)
            If $Style = -1 Then $Style = $WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU
            DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $Style)
            DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $ExStyle)
            DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, _
                    "int", 0, "int", 0, "int", $iFlags)
            WinMove($hWin, "", 0, 0, @DesktopWidth+64, @DesktopHeight+32)
            sleep(100)
            MouseWheel("down", 10)
            MouseWheel("up", 10)
        Else
            WinSetOnTop($hWin, "", 0)
            $hWnd = $hWin
            $Style = -1
            $ExStyle = 0
            Local $GWL_STYLE = -16
            Local $GWL_EXSTYLE = -20
            Local $SWP_NOMOVE = 0x2
            Local $SWP_NOSIZE = 0x1
            Local $SWP_SHOWWINDOW = 0x40
            Local $SWP_NOZORDER = 0x4
            Local $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER)
            If $Style = -1 Then $Style = $WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU
            DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $Style)
            DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $ExStyle)
            DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, _
                    "int", 0, "int", 0, "int", $iFlags)
            WinMove($hWin, "", @DesktopWidth/2, @DesktopHeight/2, 640, 320)
            sleep(100)
        EndIf
    EndIf
EndFunc

And an usage example :

#include <GUIConstants.au3>

Run("cmd.exe", "C:\")
WinWait("[CLASS:ConsoleWindowClass]")
MsgBox(0, "Warning", "The console appeared is going to toggle fullscreen, type exit in the console to close."&@CRLF&"If you do anything during 5 seconds, it's going to turn windowed.")
ConsoleSetFS("[CLASS:ConsoleWindowClass]")
Sleep(5000)
ConsoleSetFS("[CLASS:ConsoleWindowClass]", False)

Func ConsoleSetFS($Title = "[CLASS:ConsoleWindowClass]", $Fullscreen = True)
    AutoitSetOption("WinTitleMatchMode", 2)
    $hWin = WinGetHandle($Title)
    If @error == 0 Then
        If $Fullscreen = True Then
            WinSetOnTop($hWin, "", 1)
            $hWnd = $hWin
            $Style = $WS_POPUP
            $ExStyle = 0
            Local $GWL_STYLE = -16
            Local $GWL_EXSTYLE = -20
            Local $SWP_NOMOVE = 0x2
            Local $SWP_NOSIZE = 0x1
            Local $SWP_SHOWWINDOW = 0x40
            Local $SWP_NOZORDER = 0x4
            Local $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER)
            If $Style = -1 Then $Style = $WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU
            DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $Style)
            DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $ExStyle)
            DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, _
                    "int", 0, "int", 0, "int", $iFlags)
            WinMove($hWin, "", 0, 0, @DesktopWidth+64, @DesktopHeight+32)
            sleep(100)
            MouseWheel("down", 10)
            MouseWheel("up", 10)
        Else
            WinSetOnTop($hWin, "", 0)
            $hWnd = $hWin
            $Style = -1
            $ExStyle = 0
            Local $GWL_STYLE = -16
            Local $GWL_EXSTYLE = -20
            Local $SWP_NOMOVE = 0x2
            Local $SWP_NOSIZE = 0x1
            Local $SWP_SHOWWINDOW = 0x40
            Local $SWP_NOZORDER = 0x4
            Local $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER)
            If $Style = -1 Then $Style = $WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU
            DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $Style)
            DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $ExStyle)
            DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, _
                    "int", 0, "int", 0, "int", $iFlags)
            WinMove($hWin, "", @DesktopWidth/2, @DesktopHeight/2, 640, 320)
            sleep(100)
        EndIf
    EndIf
EndFunc

Enjoy ! :)

PS : Sorry if i'va made some faults, i am french :D

Edited by Titurofox
Link to comment
Share on other sites

Trong, to make full, open a windowed cmd, right click the titlebar, go to config, property or thing like that, goto the third tab and put the first value at the top to a number like 1000. JohnOne, 2 is for match any substring in the title of the window and the 4... no reason, you can delete this one (i'm going to edit my post.)

Edited by Titurofox
Link to comment
Share on other sites

I ask because you are not matching the title, you are matching the class.

For reference though, if you want to switch that option then switch it back to whatever it was, you can do it like so.

$WinTitleMatchMode = AutoitSetOption("WinTitleMatchMode", 2)
; code
AutoitSetOption("WinTitleMatchMode", $WinTitleMatchMode)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...