09-02-2008, 01:00 PM
New Faster Input module
azrith001
Sep 2 2008
Just read the script instructions, call Input.trigger?(Key) like Hit.trig?(Hit::La) for a
azrith001
Sep 2 2008
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given.
No support is given.
Just read the script instructions, call Input.trigger?(Key) like Hit.trig?(Hit::La) for a
Code:
#======================================
# Hit Keyboard Module
#---------------------------------------------------------------------------
# By: Azrith001
# Modified: 9/1/08 (m/d/y)
# Description:
=begin
This script allows those scripters out there to call the input function faster
for every key!
-------------------------------------------------------------------
How to use:
simply use Hit.V(Hit::"X")
replace "X" with one of the below Keys
replace V with a call function like trig? or hit?(Key, number of times sent back)
----------------------------------------------
Mouse_Left # left mouse button
Mouse_Right # right mouse button
Mouse_Mid # middle mouse button
Mouse_4 # 4th mouse button
Mouse_5 # 5th mouse button
Back # BACKSPACE key
Tab # TAB key
Enter # ENTER key
Shift # SHIFT key
Ctrl # CTLR key
Alt # ALT key
Pause # PAUSE key
Caps # CAPS LOCK key
Esc # ESC key
Space # SPACEBAR
Pg_Up # PAGE UP key
Pg_Dn # PAGE DOWN key
End # END key
Home # HOME key
Left # LEFT ARROW key
Up # UP ARROW key
Right # RIGHT ARROW key
Down # DOWN ARROW key
Select # SELECT key
Print # PRINT key
Prt_Scrn # PRINT SCREEN key
Ins # INS key
Del # DEL key
N[0] # 0 key
N[1] # 1 key
N[2] # 2 key
N[3] # 3 key
N[4] # 4 key
N[5] # 5 key
N[6] # 6 key
N[7] # 7 key
N[8] # 8 key
N[9] # 9 key
La # A key
Lb # B key
Lc # C key
Ld # D key
Le # E key
Lf # F key
Lg # G key
Lh # H key
Li # I key
Lj # J key
Lk # K key
Ll # L key
Lm # M key
Ln # N key
Lo # O key
Lp # P key
Lq # Q key
Lr # R key
Ls # S key
Lt # T key
Lu # U key
Lv # V key
Lw # W key
Lx # X key
Ly # Y key
Lz # Z key
Lwin # Left Windows key (Microsoft Natural keyboard)
Rwin # Right Windows key (Natural keyboard)
App # Applications key (Natural keyboard)
NP[0] # Numeric keypad 0 key
NP[1] # Numeric keypad 1 key
NP[2] # Numeric keypad 2 key
NP[3] # Numeric keypad 3 key
NP[4] # Numeric keypad 4 key
NP[5] # Numeric keypad 5 key
NP[6] # Numeric keypad 6 key
NP[7] # Numeric keypad 7 key
NP[8] # Numeric keypad 8 key
NP[9] # Numeric keypad 9 key
NPMult # Multiply key (*)
NPAdd # Add key (+)
NPSep # Separator key
NPSub # Subtract key (-)
NPDec # Decimal key
NPDiv # Divide key (/)
F1 # F1 key
F2 # F2 key
F3 # F3 key
F4 # F4 key
F5 # F5 key
F6 # F6 key
F7 # F7 key
F8 # F8 key
F9 # F9 key
F10 # F10 key
F11 # F11 key
F12 # F12 key
Num # NUM LOCK key
Scoll # SCROLL LOCK key
LShift # Left SHIFT key
RShift # Right SHIFT key
LCtrl # Left CONTROL key
RCtrl # Right CONTROL key
LAlt # Left ALT key
RAlt # Right ALT key
Com # , key
Hyph # - key
Dot # . key
=end
#======================================
# * Hit Module Don't Edit Below
# For real XD
#======================================
module Hit
#--------------------------------------------------------------------------
Mouse_Left = 0x01 # left mouse button
Mouse_Right = 0x02 # right mouse button
Mouse_Mid = 0x04 # middle mouse button
Mouse_4 = 0x05 # 4th mouse button
Mouse_5 = 0x06 # 5th mouse button
#--------------------------------------------------------------------------
Back = 0x08 # BACKSPACE key
Tab = 0x09 # TAB key
Enter = 0x0D # ENTER key
Shift = 0x10 # SHIFT key
Ctrl = 0x11 # CTLR key
Alt = 0x12 # ALT key
Pause = 0x13 # PAUSE key
Caps = 0x14 # CAPS LOCK key
Esc = 0x1B # ESC key
Space = 0x20 # SPACEBAR
Pg_Up = 0x21 # PAGE UP key
Pg_Dn = 0x22 # PAGE DOWN key
End = 0x23 # END key
Home = 0x24 # HOME key
Left = 0x25 # LEFT ARROW key
Up = 0x26 # UP ARROW key
Right = 0x27 # RIGHT ARROW key
Down = 0x28 # DOWN ARROW key
Select = 0x29 # SELECT key
Print = 0x2A # PRINT key
Prt_Scrn = 0x2C # PRINT SCREEN key
Ins = 0x2D # INS key
Del = 0x2E # DEL key
#--------------------------------------------------------------------------
N = {}
N[0] = 0x30 # 0 key
N[1] = 0x31 # 1 key
N[2] = 0x32 # 2 key
N[3] = 0x33 # 3 key
N[4] = 0x34 # 4 key
N[5] = 0x35 # 5 key
N[6] = 0x36 # 6 key
N[7] = 0x37 # 7 key
N[8] = 0x38 # 8 key
N[9] = 0x39 # 9 key
#--------------------------------------------------------------------------
La = 0x41 # A key
Lb = 0x42 # B key
Lc = 0x43 # C key
Ld = 0x44 # D key
Le = 0x45 # E key
Lf = 0x46 # F key
Lg = 0x47 # G key
Lh = 0x48 # H key
Li = 0x49 # I key
Lj = 0x4A # J key
Lk = 0x4B # K key
Ll = 0x4C # L key
Lm = 0x4D # M key
Ln = 0x4E # N key
Lo = 0x4F # O key
Lp = 0x50 # P key
Lq = 0x51 # Q key
Lr = 0x52 # R key
Ls = 0x53 # S key
Lt = 0x54 # T key
Lu = 0x55 # U key
Lv = 0x56 # V key
Lw = 0x57 # W key
Lx = 0x58 # X key
Ly = 0x59 # Y key
Lz = 0x5A # Z key
#--------------------------------------------------------------------------
Lwin = 0x5B # Left Windows key (Microsoft Natural keyboard)
Rwin = 0x5C # Right Windows key (Natural keyboard)
App = 0x5D # Applications key (Natural keyboard)
#--------------------------------------------------------------------------
NP = {}
NP[0] = 0x60 # Numeric keypad 0 key
NP[1] = 0x61 # Numeric keypad 1 key
NP[2] = 0x62 # Numeric keypad 2 key
NP[3] = 0x63 # Numeric keypad 3 key
NP[4] = 0x64 # Numeric keypad 4 key
NP[5] = 0x65 # Numeric keypad 5 key
NP[6] = 0x66 # Numeric keypad 6 key
NP[7] = 0x67 # Numeric keypad 7 key
NP[8] = 0x68 # Numeric keypad 8 key
NP[9] = 0x69 # Numeric keypad 9 key
NPMult = 0x6A # Multiply key (*)
NPAdd = 0x6B # Add key (+)
NPSep = 0x6C # Separator key
NPSub = 0x6D # Subtract key (-)
NPDec = 0x6E # Decimal key
NPDiv = 0x6F # Divide key (/)
#--------------------------------------------------------------------------
F1 = 0x70 # F1 key
F2 = 0x71 # F2 key
F3 = 0x72 # F3 key
F4 = 0x73 # F4 key
F5 = 0x74 # F5 key
F6 = 0x75 # F6 key
F7 = 0x76 # F7 key
F8 = 0x77 # F8 key
F9 = 0x78 # F9 key
F10 = 0x79 # F10 key
F11 = 0x7A # F11 key
F12 = 0x7B # F12 key
#--------------------------------------------------------------------------
Num = 0x90 # NUM LOCK key
Scoll = 0x91 # SCROLL LOCK key
#--------------------------------------------------------------------------
LShift = 0xA0 # Left SHIFT key
RShift = 0xA1 # Right SHIFT key
LCtrl = 0xA2 # Left CONTROL key
RCtrl = 0xA3 # Right CONTROL key
LAlt = 0xA4 # Left ALT key
RAlt = 0xA5 # Right ALT key
#--------------------------------------------------------------------------
Com = 0xBC # , key
Hyph = 0xBD # - key
Dot = 0xBE # . key
#--------------------------------------------------------------------------
GetKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
GetKeyboardState = Win32API.new("user32","GetKeyState",['i'],'i')
GetSetKeyState = Win32API.new("user32","SetKeyboardState",['i'],'i')
#--------------------------------------------------------------------------
module_function
#--------------------------------------------------------------------------
def notrigger?(rkey)
if GetKeyState.call(rkey) != 0
return 1
end
return 0
end
#--------------------------------------------------------------------------
def notrig?(rkey)
if GetKeyState.call(rkey) != 0
return 1
end
return 0
end
#--------------------------------------------------------------------------
def press?(rkey)
GetKeyState.call(rkey) & 0x01 == 1 #
end
#--------------------------------------------------------------------------
def prs?(rkey)
GetKeyState.call(rkey) & 0x01 == 1 #
end
#--------------------------------------------------------------------------
def trigger?(rkey)
GetKeyState.call(rkey) & 0x01 == 1 #
end
#--------------------------------------------------------------------------
def trig?(rkey)
GetKeyState.call(rkey) & 0x01 == 1 #
end
#--------------------------------------------------------------------------
def repeat?(rkey, key = 0)
GetKeyboardState.call(rkey) & 0x01 == key #
end
#--------------------------------------------------------------------------
def rpt?(rkey, key = 0)
GetKeyboardState.call(rkey) & 0x01 == key #
end
#--------------------------------------------------------------------------
def hit?(rkey, key = 0)
GetKeyboardState.call(rkey) & 0x01 == key #
end
end