Disable F1, Alt+Enter and F12
#1
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:
.zip   F1AltEnterF12.zip (Size: 3.8 KB / Downloads: 7)
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
Reply }
#2
Quote: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.

I've been thinking that F12 should just let the player make a hidden call to $scene = Scene_Title.new
Yeah, I know, not everybody will use the Scene_Title script, but then we could use some Module function to let you edit the actual call if needed.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Advanced Enter Hero Name Window RPG Advocate 0 4,990 03-02-2008, 08:10 AM
Last Post: RPG Advocate



Users browsing this thread: 2 Guest(s)