Win32 Console to Fullscreen

For the past 72 hours I have searched all over the internet, looked at source code, and did some guess 'n check code for making a console application FULL SCREEN. Since there was limited code on the internet (All that I found didn't work for me) I thought I should post the code here for people to see.

Manually to get a console application full screen you would either edit the properties or ALT+ENTER. Someone on the internet had the right idea to simulate those keys. Unfortunately the code (In C++) didn't work for me after I translated it to pascal. It most likely had to of been the fact that he was using C++. (Windows.h has same function names as Windows.pas) The following code is very similar to the translated C++ that I found. The only difference is the scan code. After many trials and errors I blindly shot and hit the target, the scan code is NEEDED.

Using Windows.pas.

keybd_event(virtual-key code, scan code, flag, extraI);

Arg 1. virtual-key code : find all key code [link=http://delphi.about.com/od/objectpascalide/l/blvkc.htm]here[/link]
Arg 2. scan code : Unfortunately I cannot find on the internet a website with the exact scan code that I used. I'm not sure if different computers will have the same scan code, so, this code may not work on your machine. Try changing the scan code.
Arg 3. flag : KEYEVENTF_EXTENDEDKEY (To my understanding... it repeats the key over and over) KEYEVENTF_KEYUP (Key is no longer pressed) 0 (Key is being pressed).
Arg 4. extraI : Must be a 32bit variable... I have no clue. Don't need it. Leave as 0.

[code]
PROGRAM FullScreen;
USES
Windows;
BEGIN
keybd_event(VK_MENU,56,0,0);
//VK_MENU is virtual-key code of ALT.
//56 is scan code of ALT.
keybd_event(VK_RETURN,28,0,0);
//VK_RETURN is virtual-key code of ENTER.
//28 is scan code of ENTER.
//Both Alt and Enter are being 'pressed.'
keybd_event(VK_MENU,56,
KEYEVENTF_KEYUP,0);
//Alt is up.
keybd_event(VK_RETURN,28,
KEYEVENTF_KEYUP,0);
//Enter is up.
Readln;//Wait for enter.
END.
[/code]

Comments

  • : For the past 72 hours I have searched all over the internet, looked
    : at source code, and did some guess 'n check code for making a
    : console application FULL SCREEN. Since there was limited code on the
    : internet (All that I found didn't work for me) I thought I should
    : post the code here for people to see.
    :
    : Manually to get a console application full screen you would either
    : edit the properties or ALT+ENTER. Someone on the internet had the
    : right idea to simulate those keys. Unfortunately the code (In C++)
    : didn't work for me after I translated it to pascal. It most likely
    : had to of been the fact that he was using C++. (Windows.h has same
    : function names as Windows.pas) The following code is very similar to
    : the translated C++ that I found. The only difference is the scan
    : code. After many trials and errors I blindly shot and hit the
    : target, the scan code is NEEDED.
    :
    : Using Windows.pas.
    :
    : keybd_event(virtual-key code, scan code, flag, extraI);
    :
    : Arg 1. virtual-key code : find all key code
    : [link=http://delphi.about.com/od/objectpascalide/l/blvkc.htm]here[/li
    : nk]
    : Arg 2. scan code : Unfortunately I cannot find on the internet a
    : website with the exact scan code that I used. I'm not sure if
    : different computers will have the same scan code, so, this code may
    : not work on your machine. Try changing the scan code.
    : Arg 3. flag : KEYEVENTF_EXTENDEDKEY (To my understanding... it
    : repeats the key over and over) KEYEVENTF_KEYUP (Key is no longer
    : pressed) 0 (Key is being pressed).
    : Arg 4. extraI : Must be a 32bit variable... I have no clue. Don't
    : need it. Leave as 0.
    :
    : [code]:
    : PROGRAM FullScreen;
    : USES
    : Windows;
    : BEGIN
    : keybd_event(VK_MENU,56,0,0);
    : //VK_MENU is virtual-key code of ALT.
    : //56 is scan code of ALT.
    : keybd_event(VK_RETURN,28,0,0);
    : //VK_RETURN is virtual-key code of ENTER.
    : //28 is scan code of ENTER.
    : //Both Alt and Enter are being 'pressed.'
    : keybd_event(VK_MENU,56,
    : KEYEVENTF_KEYUP,0);
    : //Alt is up.
    : keybd_event(VK_RETURN,28,
    : KEYEVENTF_KEYUP,0);
    : //Enter is up.
    : Readln;//Wait for enter.
    : END.
    : [/code]:
    You can also use the MapVirtualKey() to find the scan-codes of the virtual key codes. For more info see: http://msdn2.microsoft.com/en-us/library/ms646306(VS.85).aspx
  • The easiest way is to switch to a graphics mode, then back to text. Windows will not allow a windowed graphics mode, so it automatically switches to Full screen.

    [code]
    Begin
    ASM
    Mov Ax, $0013 { $00 = Set Mode, $13 = 320x200 256 Colors }
    Int $10 { $10 = Graphics Interrupt }
    Mov Ax, $0003 { $00 = Set Mode, $03 = 80x25 Text }
    Int $10 { $10 = Graphics Interrupt }
    End;
    End.
    [/code]

    Full screen. WHAMMO!

    Phat Nat


  • Hi,

    Acutally, I am using the API - "keybd_event(virtual-key code, scan code, flag, extraI);". In my code the enter key is working fine(using scan code value is 28). But "Left Windows Key" is not working, because the scan code is not correct. So If you know any of the scan code value, please share with me.

    Thanks.....
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories