08-30-2007, 01:00 PM
Keyboard (optimal version)
by corbaque
Aug 30 2007
Hehe, hello :P
You have some enough of scripts which can't make anything ?
You want innovation, truth ?
Now, add this script before main :
Exemple of utilising ?
Hop, full screen ^^
Enjoy it =)
by corbaque
Aug 30 2007
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
Hehe, hello :P
You have some enough of scripts which can't make anything ?
You want innovation, truth ?
Now, add this script before main :
Code:
#===================================
# Keyboard
#---------------------------------------------------------------
# Created by Corbaque and TLN - 09/07/07
#---------------------------------------------------------------
# English conversion by Corbaque
#---------------------------------------------------------------
# Methods :
# - press
# - trigger
# - dbtrigger
# - repeat => press 1 of 3
# - hold => bloc note press
# - release
# - active => like caps lock
# - getpress
#---------------------------------------------------------------
# Update :
# - Key.update
#=> Classical
# - Key.update("enter", "esc")
#=> Only enter and escap
# - Key.update(*$arraykeys)
#=> Only the keys included on $arraykeys
#===> Think to define it before using :P
#---------------------------------------------------------------
# QWERTY version
#===================================
# Win32API constant
Key = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
State = Win32API.new("user32","GetKeyState",['i'],'i')
GetPress = Win32API.new('user32', 'keybd_event', ['i', 'i', 'i'], ' ')
#---------------------------------------------------------------
# Pressed ?
#---------------------------------------------------------------
def press(n)
R[n][0]
end
#---------------------------------------------------------------
# Clicked ?
#---------------------------------------------------------------
def trigger(n)
R[n][1] >= 1
end
#---------------------------------------------------------------
# Double Clicked ?
#---------------------------------------------------------------
def dbtrigger(n)
R[n][1] == 2
end
#---------------------------------------------------------------
# Pressed ?, false, false, false, Pressed ?...
#---------------------------------------------------------------
def repeat(n)
R[n][2] %= 4; R[n][2].zero? and R[n][0]
end
#---------------------------------------------------------------
# Like when you write anything with pressing
#---------------------------------------------------------------
def hold(n)
(R[n][2] % 20).zero? and R[n][0]
end
#---------------------------------------------------------------
# Released ?
#---------------------------------------------------------------
def release(n)
R[n][1] == -1
end
#---------------------------------------------------------------
# Actived ? (Like caps lock)
#---------------------------------------------------------------
def active(n)
State.call(TAB_KEY[n]) & 1 == 1
end
#---------------------------------------------------------------
# Get pressing
#---------------------------------------------------------------
def getpress(*a)
a.each do |n|
GetPress.call(TAB_KEY[n], 0, 0)
end
a.each do |n|
GetPress.call(TAB_KEY[n], 0, 2)
end
end
#---------------------------------------------------------------
# Update keys state
#---------------------------------------------------------------
class Keys
def Keys.update(*tab)
if tab != []
tab.each do |n|
m = R[n][0]
pr = Key.call(TAB_KEY[n]) != 0
tr = m == pr ? 0 : (pr ? (R[n][2].between?(1, 9) ? 2 : 1) : -1)
count = tr > 0 ? 0 : [R[n][2]+1, 20].min
R[n] = [pr, tr, count]
end
else
TAB_KEY.keys.each do |n|
m = R[n][0]
pr = Key.call(TAB_KEY[n]) != 0
tr = m == pr ? 0 : (pr ? (R[n][2].between?(1, 9) ? 2 : 1) : -1)
count = tr > 0 ? 0 : [R[n][2]+1, 20].min
R[n] = [pr, tr, count]
end
end
end
end
# All Keys
TAB_KEY = {
"click gauche" => 1,
"sg" => 1,
"click droit" => 2,
"sd" => 2,
"click milieu" => 4,
"sm" => 4,
"del" => 8,
"tab" => 9,
"enter" => 13,
"shift" => 16,
"ctrl" => 17,
"alt" => 18,
"pause" => 19,
"caps lock" => 20,
"esc" => 27,
"space" => 32,
"pg up" => 33,
"pg down" => 34,
"end" => 35,
"home" => 36,
"left" => 37,
"up" => 38,
"right" => 39,
"down" => 40,
"impr" => 44,
"insert" => 45,
"suppr" => 46,
"0" => 48,
"1" => 49,
"2" => 50,
"3" => 51,
"4" => 52,
"5" => 53,
"6" => 54,
"7" => 55,
"8" => 56,
"9" => 57,
"a" => 65,
"b" => 66,
"c" => 67,
"d" => 68,
"e" => 69,
"f" => 70,
"g" => 71,
"h" => 72,
"i" => 73,
"j" => 74,
"k" => 75,
"l" => 76,
"m" => 77,
"n" => 78,
"o" => 79,
"p" => 80,
"q" => 81,
"r" => 82,
"s" => 83,
"t" => 84,
"u" => 85,
"v" => 86,
"w" => 87,
"x" => 88,
"y" => 89,
"z" => 90,
"lwin" => 91,
"rwin" => 92,
"apps" => 93,
"n0" => 96,
"n1" => 97,
"n2" => 98,
"n3" => 99,
"n4" => 100,
"n5" => 101,
"n6" => 102,
"n7" => 103,
"n8" => 104,
"n9" => 105,
"n*" => 106,
"+" => 107,
"num" => 108,
"n-" => 109,
"n." => 110,
"n/" => 111,
"F1" => 112,
"F2" => 113,
"F3" => 114,
"F4" => 115,
"F5" => 116,
"F6" => 117,
"F7" => 118,
"F8" => 119,
"F9" => 120,
"F10" => 121,
"F11" => 122,
"F12" => 123,
"vernum" => 144,
"verdefil" => 145,
"lmaj" => 160,
"rmaj" => 161,
"lctrl" => 162,
"rctrl" => 163,
"lalt" => 164,
"ralt" => 165,
"]" => 186,
"=" => 187,
";" => 188,
"," => 190,
"." => 191,
"'" => 192,
"-" => 219,
'\\' => 220,
"[" => 221,
"`" => 222,
"/" => 223,
"|" => 226
}
R = TAB_KEY.clone
R.keys.each { |k| R[k] = [false, false, 10]}
Exemple of utilising ?
Code:
getpress("alt", "enter")
Hop, full screen ^^
Enjoy it =)