Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

How do I change the behavior of the F12 key?

Status
Not open for further replies.
If you've seen my other help topics you know I'm using a modified version of Near's Keyboard Input Module. I want to use the Fkeys for skills and other things, sort of like Hotkeys. I've been able to disable the default use of the F1 key through modification of the dll thanks to vgvgf, and so now I'm able to use that key in game, but how do I free up F12? I don't want it automatically going to the title screen because when the player quits, I want it to automatically save. I want to either free F12 for another use or force it to autosave before going to the title screen. Any help on this will be appreciated.
 
That's difficult. I know how to remove the F1, F2 and ALT+ENTER hotkeys, but the F12 is more difficult. I know a not very good way to desactive the F12 key, but it can be used and it's a little laggy. Maybe if it is a hotkey, assigned to the proccess, it can be unregistered, but I don't know the id of that hotkey, and if it exists. Or maybe, the F12 key is checked every frame for seeing if it has been pressed. If it is the second thing, it would very difficult to quit it. If the F12 is checked in the Graphics module it will be needed a redone of this class, and if it is checked in a separeted thread, it will be needed to kill that thread.

PD: modified version of Near's Keyboard Input Module? What is that? My Input module is the best one!
 
This is the keyboard input module I'm talking about.
Code:
#==============================================================================
# ** Keyboard Input Module
#==============================================================================
# Near Fantastica # Edited by Draycos Goldaryn
# Version 5       # Version 6
# 29.11.05        # 15.03.07
#==============================================================================
# The Keyboard Input Module is designed to function as the default Input module
# dose. It is better then other methods keyboard input because as a key is 
# tested it is not removed form the list. so you can test the same key multiple
# times the same loop.
#
# Keys added by Draycos:
#   Middle Mouse Button
#   Pause
#   Caps Lock
#   Page Up
#   Page Down
#   End
#   Home
#   Left
#   Up
#   Right
#   Down
#   Print Screen
#   Insert
#   Delete
#   Corrected numberpad values
#   Numberpad["*"]
#   Numberpad["+"]
#   Numberpad["-"]
#   Numberpad["."]
#   Numberpad["/"]
#   Left Windows Button
#   Right Windows Buttons
#   Application Button (The one that right clicks for you)
#   Num Lock
#   Scroll Lock 
#   Left Shift
#   Right Shift
#   Left Ctrl
#   Right Ctrl
#   Left Alt
#   Right Alt
#   Frontslash ( / )
#   Tilde
#   Backslash ( \ )
#   Quote 
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log("Keyboard Input", "Near Fantastica -- Draycos Goldaryn", 6, "15.03.07")

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state("Keyboard Input") == true
  
  module Keyboard
    #--------------------------------------------------------------------------
    @keys = []
    @pressed = []
    Mouse_Left = 1
    Mouse_Right = 2
    Mouse_Middle = 4
    Back= 8
    Tab = 9
    Enter = 13
    Shift = 16
    Ctrl = 17
    Alt = 18
    Pause = 19
    Caps_Lock = 20
    Esc = 27
    Space = 32
    PgUp = 33
    PgDn = 34
    End = 35
    Home = 36
    Left = 37
    Up = 38
    Right = 39
    Down = 40
    Print_Screen = 44
    Insert = 45
    Delete = 46
    Numberkeys = {}
    Numberkeys[0] = 48
    Numberkeys[1] = 49
    Numberkeys[2] = 50
    Numberkeys[3] = 51
    Numberkeys[4] = 52
    Numberkeys[5] = 53
    Numberkeys[6] = 54
    Numberkeys[7] = 55
    Numberkeys[8] = 56
    Numberkeys[9] = 57
    Numberpad = {}
    Numberpad[0] = 96
    Numberpad[1] = 97
    Numberpad[2] = 98
    Numberpad[3] = 99
    Numberpad[4] = 100
    Numberpad[5] = 101
    Numberpad[6] = 102
    Numberpad[7] = 103
    Numberpad[8] = 104
    Numberpad[9] = 105
    Numberpad["*"] = 106
    Numberpad["+"] = 107
    Numberpad["-"] = 109
    Numberpad["."] = 110
    Numberpad["/"] = 111
    Letters = {}
    Letters["A"] = 65
    Letters["B"] = 66
    Letters["C"] = 67
    Letters["D"] = 68
    Letters["E"] = 69
    Letters["F"] = 70
    Letters["G"] = 71
    Letters["H"] = 72
    Letters["I"] = 73
    Letters["J"] = 74
    Letters["K"] = 75
    Letters["L"] = 76
    Letters["M"] = 77
    Letters["N"] = 78
    Letters["O"] = 79
    Letters["P"] = 80
    Letters["Q"] = 81
    Letters["R"] = 82
    Letters["S"] = 83
    Letters["T"] = 84
    Letters["U"] = 85
    Letters["V"] = 86
    Letters["W"] = 87
    Letters["X"] = 88
    Letters["Y"] = 89
    Letters["Z"] = 90
    L_Windows = 91
    R_Windows = 92
    Application = 93
    Fkeys = {}
    Fkeys[1] = 112
    Fkeys[2] = 113
    Fkeys[3] = 114
    Fkeys[4] = 115
    Fkeys[5] = 116
    Fkeys[6] = 117
    Fkeys[7] = 118
    Fkeys[8] = 119
    Fkeys[9] = 120
    Fkeys[10] = 121
    Fkeys[11] = 122
    Fkeys[12] = 123
    NumLock = 144
    Scroll_Lock = 145
    L_Shift = 160
    R_Shift = 161
    L_Ctrl = 162
    R_Ctrl = 163
    L_Alt = 164
    R_Alt = 165
    Collon = 186
    Equal = 187
    Comma = 188
    Underscore = 189
    Dot = 190
    Frontslash = 191
    Tilde = 192
    Lb = 219
    Backslash = 220
    Rb = 221
    Quote = 222
    
    State = Win32API.new("user32","GetKeyState",['i'],'i')
    Key = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
    #--------------------------------------------------------------------------  
    def Keyboard.getstate(key)
      return true unless State.call(key).between?(0, 1)
      return false
    end
    #--------------------------------------------------------------------------
    def Keyboard.testkey(key)
      Key.call(key) & 0x01 == 1
    end
    #--------------------------------------------------------------------------
    def Keyboard.update
      @keys = []
      @keys.push(Keyboard::Mouse_Left) if Keyboard.testkey(Keyboard::Mouse_Left)
      @keys.push(Keyboard::Mouse_Right) if Keyboard.testkey(Keyboard::Mouse_Right)
      @keys.push(Keyboard::Mouse_Middle) if Keyboard.testkey(Keyboard::Mouse_Middle)
      @keys.push(Keyboard::Back) if Keyboard.testkey(Keyboard::Back)
      @keys.push(Keyboard::Tab) if Keyboard.testkey(Keyboard::Tab)
      @keys.push(Keyboard::Enter) if Keyboard.testkey(Keyboard::Enter)
      @keys.push(Keyboard::Shift) if Keyboard.testkey(Keyboard::Shift)
      @keys.push(Keyboard::Ctrl) if Keyboard.testkey(Keyboard::Ctrl)
      @keys.push(Keyboard::Alt) if Keyboard.testkey(Keyboard::Alt)
      @keys.push(Keyboard::Pause) if Keyboard.testkey(Keyboard::Pause)
      @keys.push(Keyboard::Caps_Lock) if Keyboard.testkey(Keyboard::Caps_Lock)
      @keys.push(Keyboard::Esc) if Keyboard.testkey(Keyboard::Esc)
      @keys.push(Keyboard::Space) if Keyboard.testkey(Keyboard::Space)
      @keys.push(Keyboard::PgUp) if Keyboard.testkey(Keyboard::PgUp)
      @keys.push(Keyboard::PgDn) if Keyboard.testkey(Keyboard::PgDn)
      @keys.push(Keyboard::End) if Keyboard.testkey(Keyboard::End)
      @keys.push(Keyboard::Home) if Keyboard.testkey(Keyboard::Home)
      @keys.push(Keyboard::Left) if Keyboard.testkey(Keyboard::Left)
      @keys.push(Keyboard::Up) if Keyboard.testkey(Keyboard::Up)
      @keys.push(Keyboard::Right) if Keyboard.testkey(Keyboard::Right)
      @keys.push(Keyboard::Down) if Keyboard.testkey(Keyboard::Down)
      @keys.push(Keyboard::Print_Screen) if Keyboard.testkey(Keyboard::Print_Screen)
      @keys.push(Keyboard::Insert) if Keyboard.testkey(Keyboard::Insert)
      @keys.push(Keyboard::Delete) if Keyboard.testkey(Keyboard::Delete)
      for key in Keyboard::Numberkeys.values
        @keys.push(key) if Keyboard.testkey(key)
      end
      for key in Keyboard::Numberpad.values
        @keys.push(key) if Keyboard.testkey(key)
      end
      for key in Keyboard::Letters.values
        @keys.push(key) if Keyboard.testkey(key)
      end
      @keys.push(Keyboard::L_Windows) if Keyboard.testkey(Keyboard::L_Windows)
      @keys.push(Keyboard::R_Windows) if Keyboard.testkey(Keyboard::R_Windows)
      @keys.push(Keyboard::Application) if Keyboard.testkey(Keyboard::Application)
      for key in Keyboard::Fkeys.values
        @keys.push(key) if Keyboard.testkey(key)
      end
      @keys.push(Keyboard::NumLock) if Keyboard.testkey(Keyboard::NumLock)
      @keys.push(Keyboard::Scroll_Lock) if Keyboard.testkey(Keyboard::Scroll_Lock)
      @keys.push(Keyboard::L_Shift) if Keyboard.testkey(Keyboard::L_Shift)
      @keys.push(Keyboard::R_Shift) if Keyboard.testkey(Keyboard::R_Shift)
      @keys.push(Keyboard::L_Ctrl) if Keyboard.testkey(Keyboard::L_Ctrl)
      @keys.push(Keyboard::R_Ctrl) if Keyboard.testkey(Keyboard::R_Ctrl)
      @keys.push(Keyboard::L_Alt) if Keyboard.testkey(Keyboard::L_Alt)
      @keys.push(Keyboard::R_Alt) if Keyboard.testkey(Keyboard::R_Alt)
      @keys.push(Keyboard::Collon) if Keyboard.testkey(Keyboard::Collon)
      @keys.push(Keyboard::Equal) if Keyboard.testkey(Keyboard::Equal)
      @keys.push(Keyboard::Comma) if Keyboard.testkey(Keyboard::Comma)
      @keys.push(Keyboard::Underscore) if Keyboard.testkey(Keyboard::Underscore)
      @keys.push(Keyboard::Dot) if Keyboard.testkey(Keyboard::Dot)
      @keys.push(Keyboard::Frontslash) if Keyboard.testkey(Keyboard::Frontslash)
      @keys.push(Keyboard::Tilde) if Keyboard.testkey(Keyboard::Tilde)
      @keys.push(Keyboard::Lb) if Keyboard.testkey(Keyboard::Lb)
      @keys.push(Keyboard::Backslash) if Keyboard.testkey(Keyboard::Backslash)
      @keys.push(Keyboard::Rb) if Keyboard.testkey(Keyboard::Rb)
      @keys.push(Keyboard::Quote) if Keyboard.testkey(Keyboard::Quote)
      @pressed = []
      @pressed.push(Keyboard::Mouse_Left) if Keyboard.getstate(Keyboard::Mouse_Left)
      @pressed.push(Keyboard::Mouse_Right) if Keyboard.getstate(Keyboard::Mouse_Right)
      @pressed.push(Keyboard::Mouse_Middle) if Keyboard.getstate(Keyboard::Mouse_Middle)
      @pressed.push(Keyboard::Back) if Keyboard.getstate(Keyboard::Back)
      @pressed.push(Keyboard::Tab) if Keyboard.getstate(Keyboard::Tab)
      @pressed.push(Keyboard::Enter) if Keyboard.getstate(Keyboard::Enter)
      @pressed.push(Keyboard::Shift) if Keyboard.getstate(Keyboard::Shift)
      @pressed.push(Keyboard::Ctrl) if Keyboard.getstate(Keyboard::Ctrl)
      @pressed.push(Keyboard::Alt) if Keyboard.getstate(Keyboard::Alt)
      @pressed.push(Keyboard::Pause) if Keyboard.getstate(Keyboard::Pause)
      @pressed.push(Keyboard::Caps_Lock) if Keyboard.getstate(Keyboard::Caps_Lock)
      @pressed.push(Keyboard::Esc) if Keyboard.getstate(Keyboard::Esc)
      @pressed.push(Keyboard::Space) if Keyboard.getstate(Keyboard::Space)
      @pressed.push(Keyboard::PgUp) if Keyboard.getstate(Keyboard::PgUp)
      @pressed.push(Keyboard::PgDn) if Keyboard.getstate(Keyboard::PgDn)
      @pressed.push(Keyboard::End) if Keyboard.getstate(Keyboard::End)
      @pressed.push(Keyboard::Home) if Keyboard.getstate(Keyboard::Home)
      @pressed.push(Keyboard::Left) if Keyboard.getstate(Keyboard::Left)
      @pressed.push(Keyboard::Up) if Keyboard.getstate(Keyboard::Up)
      @pressed.push(Keyboard::Right) if Keyboard.getstate(Keyboard::Right)
      @pressed.push(Keyboard::Down) if Keyboard.getstate(Keyboard::Down)
      @pressed.push(Keyboard::Print_Screen) if Keyboard.getstate(Keyboard::Print_Screen)
      @pressed.push(Keyboard::Insert) if Keyboard.getstate(Keyboard::Insert)
      @pressed.push(Keyboard::Delete) if Keyboard.getstate(Keyboard::Delete)
      for key in Keyboard::Numberkeys.values
        @pressed.push(key) if Keyboard.getstate(key)
      end
      for key in Keyboard::Numberpad.values
        @pressed.push(key) if Keyboard.getstate(key)
      end
      for key in Keyboard::Letters.values
        @pressed.push(key) if Keyboard.getstate(key)
      end
      @pressed.push(Keyboard::L_Windows) if Keyboard.getstate(Keyboard::L_Windows)
      @pressed.push(Keyboard::R_Windows) if Keyboard.getstate(Keyboard::R_Windows)
      @pressed.push(Keyboard::Application) if Keyboard.getstate(Keyboard::Application)
      for key in Keyboard::Fkeys.values
        @pressed.push(key) if Keyboard.getstate(key)
      end
      @pressed.push(Keyboard::NumLock) if Keyboard.getstate(Keyboard::NumLock)
      @pressed.push(Keyboard::Scroll_Lock) if Keyboard.getstate(Keyboard::Scroll_Lock)
      @pressed.push(Keyboard::L_Shift) if Keyboard.getstate(Keyboard::L_Shift)
      @pressed.push(Keyboard::R_Shift) if Keyboard.getstate(Keyboard::R_Shift)
      @pressed.push(Keyboard::L_Ctrl) if Keyboard.getstate(Keyboard::L_Ctrl)
      @pressed.push(Keyboard::R_Ctrl) if Keyboard.getstate(Keyboard::R_Ctrl)
      @pressed.push(Keyboard::L_Alt) if Keyboard.getstate(Keyboard::L_Alt)
      @pressed.push(Keyboard::R_Alt) if Keyboard.getstate(Keyboard::R_Alt)
      @pressed.push(Keyboard::Collon) if Keyboard.getstate(Keyboard::Collon)
      @pressed.push(Keyboard::Equal) if Keyboard.getstate(Keyboard::Equal)
      @pressed.push(Keyboard::Comma) if Keyboard.getstate(Keyboard::Comma)
      @pressed.push(Keyboard::Underscore) if Keyboard.getstate(Keyboard::Underscore)
      @pressed.push(Keyboard::Dot) if Keyboard.getstate(Keyboard::Dot)
      @pressed.push(Keyboard::Frontslash) if Keyboard.getstate(Keyboard::Frontslash)
      @pressed.push(Keyboard::Tilde) if Keyboard.getstate(Keyboard::Tilde)
      @pressed.push(Keyboard::Lb) if Keyboard.getstate(Keyboard::Lb)
      @pressed.push(Keyboard::Backslash) if Keyboard.getstate(Keyboard::Backslash)
      @pressed.push(Keyboard::Rb) if Keyboard.getstate(Keyboard::Rb)
      @pressed.push(Keyboard::Quote) if Keyboard.getstate(Keyboard::Quote)
    end
    #--------------------------------------------------------------------------
    def Keyboard.trigger?(key)
      return true if @keys.include?(key)
      return false
    end
    #--------------------------------------------------------------------------
    def Keyboard.pressed?(key)
      return true if @pressed.include?(key)
      return false
    end
  end

#------------------------------------------------------------------------------
# * End SDK Enable Test
#------------------------------------------------------------------------------
end

That F12 key is the only thing that preventing me from doing what I want with the function keys. I want the player to be able to assign skills and/or items to slots that are activated with F1-F12. I've disabled F1,F2, and Alt+Enter already. But whenever I try to assign anything to F12, it runs the "Go to Title" command before anything else. Since it's not in the DLL like F1,F2, and Alt+Enter, then it must be in a script somewhere. The value of the F12 key is 123, I know that much, but that's about it.

PD: What makes yours the best?
 
Yes, I want to use F1-F12 as hotkeys for skills/items. True, it is a useful function, So maybe if I can set it so that it operates if the debug flag is on, and/or set it to a different key, like the tilde.
 
Vanilla!!!;190834":2wbnjbm3 said:
You took the F1-F12 hotkey thing from Ragnarok,didn't you?

I've never played Ragnarok, but many mmorpgs use F1-F12 as hotkeys.

And I just found out, that the way I disabled F1 and F2 is illegal since I modified the dll using ResHack. Thanks alot vgvgf....(not)
 
And I just found out, that the way I disabled F1 and F2 is illegal since I modified the dll using ResHack. Thanks alot vgvgf....(not)
No, that is not ilegal. Ilegal is only when modifing the RPG Maker XP editor, not the games, and how the RGSS dlls are part of the game, and not of the editor, they can be edited freely. Why not, making an option menu, so the player can select what keys to use?


PD: Use my input module, it is better, see my signature!
 
vgvgf;191325":1338t4ql said:
No, that is not ilegal. Ilegal is only when modifing the RPG Maker XP editor, not the games, and how the RGSS dlls are part of the game, and not of the editor, they can be edited freely.

Please, Explain your logic. Do you have proof that it is not illegal?
 
I think I've found workarounds to not being able to edit the dll.

I was going to use F1-F12 as hotkeys, and use the number keys to switch between "pages". Instead I will use the number keys as the hotkeys, and use Tab to turn the "pages". I also was going to disable Alt+Enter and use a script to change between windowed and fullscreen, but now I will still use the script, but set it to supersede Alt+Enter, thus, if the game is in fullscreen and the player hits Alt+Enter, the game will flicker, because Alt+Enter will activate, but then the script will force it back to fullscreen(visa versa in windowed mode). also, I will set F11 to toggle windowed and fullscreen. (I do have a valid reason for this.)
 
This topic has been resolved. If DraycosGoldaryn or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top