Disabling ALT+Enter Discussion

Started by KK20, January 16, 2014, 04:03:24 pm

Previous topic - Next topic

KK20

January 16, 2014, 04:03:24 pm Last Edit: January 17, 2014, 08:10:49 pm by KK20
Current Conclusion:

In Main, right under the line that says begin, paste this:

 # Disable ALT+Enter
 reghotkey = Win32API.new('user32', 'RegisterHotKey', 'LIII', 'I')
 reghotkey.call(0, 1, 1, 0x0D)

If you are using the script that puts the game into fullscreen by simulating an ALT+Enter keypress, make sure that is placed before this.




People have been asking for ways to disable the player's ability to press ALT+Enter to go into (or get out of) fullscreen-mode for years now. I am unsure if there really is a "fix-all" for this, but I have taken action to see if perhaps there is.

I found a DLL made by Cremno that can disable ALT+Enter.
Spoiler: ShowHide

Get the DLL here: http://www.mediafire.com/download/ffr36fml1cua73r/NoF12.dll
Put the file into a blank test project.

Replace Main with this:

begin
 # Disable ALT+Enter
 noaltenter = Win32API.new('NoF12', 'NoAltEnter', 'L', nil)
 noaltenter.call(1)
 # Prepare for transition
 Graphics.freeze
 # Make scene object (title screen)
 $scene = Scene_Title.new
 # Call main method as long as $scene is effective
 while $scene != nil
   $scene.main
 end
 # Fade out
 Graphics.transition(20)
rescue Errno::ENOENT
 # Supplement Errno::ENOENT exception
 # If unable to open file, display message and end
 filename = $!.message.sub("No such file or directory - ", "")
 print("Unable to find file #{filename}.")
end

Now testplay and see if you can get into fullscreen.





Coming from this post, I believed to have found a solution.
My Discovery and Trial Tests: ShowHide

You can copy this script and replace Main with it. The change is only the first few lines. Try this out in a new project.

begin
 # Disable ALT+Enter
 reghotkey = Win32API.new('user32', 'RegisterHotKey', 'LIII', 'I')
 result = reghotkey.call(0, 1, 0x4001, 0x0D)
 if result != 0 then print 'RegisterHotKey successfully completed' end
 # Prepare for transition
 Graphics.freeze
 # Make scene object (title screen)
 $scene = Scene_Title.new
 # Call main method as long as $scene is effective
 while $scene != nil
   $scene.main
 end
 # Fade out
 Graphics.transition(20)
rescue Errno::ENOENT
 # Supplement Errno::ENOENT exception
 # If unable to open file, display message and end
 filename = $!.message.sub("No such file or directory - ", "")
 print("Unable to find file #{filename}.")
end

If the method was successful, you should have a message window pop-up to confirm that. Try using ALT+Enter and see if it does anything. If you cannot toggle between fullscreen and windowed mode, insert this little snippet in just above Main:

class Scene_Map
 alias check_for_alt_enter update
 def update
   if Input.trigger?(Input::ALT) && Input.trigger?(Input::C)
     $game_system.se_play($data_system.decision_se)
   end
   check_for_alt_enter
 end
end

Try pressing ALT+Enter and ALT+C (or whatever is your confirm button). If you pressed these buttons at the same time, you should hear the beep for ALT+C but not for ALT+Enter.

Now try running another game with this one still open. Can you ALT+Enter into fullscreen? I couldn't, not until I closed this game's window first.





However, LiTTleDRAgo reported that this method did not work for him. To help with this investigation, I would like you, the users, to help me out. Please try the two methods above and report whether or not ALT+Enter was disabled. Also, please provide your OS and keyboard model. For me, I have tested this only on a NV59 Gateway laptop with the built-in keyboard running on Windows 7.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

ForeverZer0

Worked here. For some reason, using UnegisterHotKey using Win32API didn't seem to work for me.

Dell XPS L502 (Built-in keyboard)(BTW, I don't think the keyboard has anything to do with this not working...)
Windows 7 Ultimate x64
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

KK20

Quote from: ForeverZer0 on January 16, 2014, 04:19:36 pm
For some reason, using UnegisterHotKey using Win32API didn't seem to work for me.

How and where did you use it? I did something stupid like

module Thing
  def self.unregister
    removehotkey = Win32API.new('user32', 'UnregisterHotKey', 'LI', 'I')
    removehotkey.call(0, 1)
  end
end

And had an event use a script call. Talking to the event allowed me to use ALT+Enter again.

Also, I'm not sure if putting the handle to the window is important or not. I still got the same results.

Quote
(BTW, I don't think the keyboard has anything to do with this not working...)

Yeah, I thought that too. Oh well, doesn't hurt, right? :P

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Blizzard

January 16, 2014, 04:40:41 pm #3 Last Edit: January 16, 2014, 04:46:38 pm by Blizzard
*scratches ass*

The NoF12.dll references SetWindowsHookExA(), UnhookWindowsEx() and CallNextHookEx() (all found in user32.dll). Why don't you just take a look at their API reference and what they can do?

EDIT: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990(v=vs.85).aspx

"WH_KEYBOARD: Installs a hook procedure that monitors keystroke messages. For more information, see the KeyboardProc hook procedure."
"WH_KEYBOARD_LL: Installs a hook procedure that monitors low-level keyboard input events. For more information, see the LowLevelKeyboardProc hook procedure."

I think this might be a much better lead than RegisterHotKey().

EDIT: Even with some instructions, lol! http://stackoverflow.com/a/2562158
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

KK20

January 16, 2014, 05:30:33 pm #4 Last Edit: January 16, 2014, 10:56:37 pm by KK20
Been reading this over. I'm not entirely sure what to put in the parameters though. I'll just keep playing with it. Nice find! (as expected :roll:)

EDIT:

After looking into it more, it seems there's more to it than just those three calls, and I don't think you can do it in Ruby. Someone can prove me wrong though; I'm still fairly new into understanding these API calls.

I could still use some more feedback regarding the first post, especially you LiTTleDRAgo since you are, at this moment, the only odd one out.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

LiTTleDRAgo

eeeh~ I'm the odd one?
currently I'm using notebook e-machines D725 running on Windows XP Professional SP3 version 2002, built-in keyboard.
I tested your method and still can change the game to fullscreen with Alt + Enter / Alt Gr + Enter.

if I can say, the closest one to prevent fullscreen without NoF12.dll is this script: >>Link<<
although it only prevent Left Alt + Enter (Alt Gr + Enter still switch the game to fullscreen)



KK20

January 17, 2014, 12:48:16 am #6 Last Edit: January 17, 2014, 12:57:31 am by KK20
Windows XP huh? It sure does mention that a lot:
Quote
MOD_NOREPEAT
0x4000

Changes the hotkey behavior so that the keyboard auto-repeat does not yield multiple hotkey notifications.
Windows Vista and Windows XP/2000:  This flag is not supported.

Quote
Windows Server 2003, Windows XP, and Windows 2000:  If a hot key already exists with the same hWnd and id parameters, it is replaced by the new hot key.

When calling RegisterHotKey, you are returned zero, correct?
I wish I still had a Windows XP computer to test this out.
Also, I know you didn't say it explicitly, but from the way you wrote, it sounded like NoF12 works for you.

And I dunno about that script. I plugged it into an empty VXA project (Disable_VX_Fullscreen = true) and I was still able to use the left alt just fine. Did as he suggested to G_G about changing the line to

release_alt if Disable_VX_Fullscreen

and, if I pressed the two keys at the same time, was successful.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

LiTTleDRAgo

yeah, NoF12.dll is worked, but RegisterHotkey didn't (returns 0)

about fullscreen++, I noticed that too, but it seems that Zeus81 used keyboard that different from our standard.

KK20

So Zeus's fix is out of the question.

Have you tried playing with the RegisterHotKey a bit? This part
Quote
MOD_NOREPEAT
0x4000

Windows Vista and Windows XP/2000:  This flag is not supported.

has been bothering me a bit. So, what if you were to remove it?

result = reghotkey.call(0, 1, 0x0001, 0x0D)

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

LiTTleDRAgo

@^ it works

result: ShowHide
Alt + Enter = didn't do anything
Alt Gr + Enter = didn't do anything
Alt + Alt Gr + Enter = didn't do anything

Alt + F4 = quit
Alt Gr + F4 = quit

Input.trigger?(Input::ALT) = works
Input.repeat?(Input::ALT) = works
Input.press?(Input::ALT) = works


It seems that only disable Alt + Enter, everything aside that is work normally
Opening another project without closing the first also make that project unable to use Alt + Enter

KK20

January 17, 2014, 08:07:19 pm #10 Last Edit: January 17, 2014, 09:21:36 pm by KK20
:D :D :D :D :D

I think we just found our disable ALT + Enter. I used the same line in my game and got the same results despite using Windows 7.
If you want to disable ALT+F4, that's
reghotkey.call(0, 1, 1, 0x73)

where 0x73 is the code for F4. Of course, same rules apply: as long as the game is open, it disables ALT+F4 on everything else.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!