Save-Point
Disable F1, Alt+Enter and F12 - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker VX/VXAce (RGSS2/3) Engines (https://www.save-point.org/forum-117.html)
+---- Thread: Disable F1, Alt+Enter and F12 (/thread-9058.html)



Disable F1, Alt+Enter and F12 - DerVVulfman - 07-14-2019

Disable F1, Alt+Enter and F12
by Chainsawkitten
Original thread found by DerVVulfman at RPGMaker Central


Introduction
"I made this for Clandestinity of Elsie, which released a year ago, and finally thought "hey, maybe someone else could use it too"." - Chainsawkitten (June 26, 2016)

This script, combined with an accompanying DLL file, allows you to disable certain keys in your RPG Maker game. How?  It sets a hook for key input which catches those keypresses, making sure the game never receives them (and thus those things don't trigger). Since RPG Maker also checks keyboard status directly for F12, we also fake that it isn't pressed by using 'SetKeyboardState'.



Features
  • Allows the user to disable the [F1] key
  • Allows the user to disable the [Alt]+[Enter] combination which toggles fullscreen/window mode
  • Allows the user to disable the [F12] key (RPGMaker VXAce Only)



Limitations
Since the hook completely devours that input, you won't be able to use F1, F12 or Alt+Enter for anything else. (If you want to disable a key so you could use it for something else, that's not too difficult. Just change messageHandling so it stores that the key has been pressed and then implement a function to get that value (which also clears it). Anyone with some basic C knowledge should be able to do that.)



Why Disable F1?
The default control settings suck so we decided to do our own (with support for other keys and "better" gamepad (subjective, we used XInput)). If you don't implement your own settings to replace them, you probably shouldn't disable it.

Set DISABLE_F1 = 0 if you don't want to disable it.



Why Disable F12?
F12 may be useful for debugging but some scripters and users find it an annoyance when some players wish to reset their game and find a 'stack error' if some script didn't alias code properly (ie they generated an F12 bug).

Set DISABLE_F12 = 0 if you don't want to disable it.



Why disable Alt+Enter?
Because we wanted to use another (better) fullscreen implementation.

Set DISABLE_ALT_ENTER = 0 if you don't want to disable it.



Script
Actually... no.  Surprisingly simple to use.



Script
All the script really does is simply call the DLL, which registers the hook. The code assumes your project has folders for Data, Graphics, Audio and System (a new folder) in your project's root.
"The Script"



Required DLL
Attachment found here:
https://www.save-point.org/attachment.php?aid=1156
The source code for the DLL can be found HERE.



Instructions
Create a new folder in your project called 'System'. And in the system folder, paste a copy of the required DLL.  After that, paste the above script in your Scripts Database, typically below Scene_Debug and above Main and configure in the CskDisable module as noted above.



Compatability
This can work with RPGMaker XP, VX and VXAce.  However, only VXAce permits the F12 key to be blocked.  The F12 feature is not blocked by this system for the older two engines.



Requirements
Besides the DLL above, this requires the Microsoft Visual C++ 2013 Redistributables (x86) to be installed. Your end-user will have to install it too. You can compile the DLL from source if you want a different vesion of MSVC or if you want to port it to MinGW or whatever. The project consists of a single .c file so that part shouldn't be much work. Other than that, I hardcoded in the wrangled function name of the hook-function "_messageHandling@12", you may have to change that if you use a different compiler.



Terms and Conditions
Do whatever you want to:



License
Open to read