Sign in to follow this  
Followers 0
Titurofox

Fullscreen CMD

7 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Full ?

image.png


Regards,
 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Ho, here, i'm matching the class, it's true.

But if the user want to put a title, he can and if he want to put a class, he also can !

Are you understanding why now ?

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
Sign in to follow this  
Followers 0