Dear AHK peers, interested in Midi input,
I would like to share with you my
(earlier named
Midi2Kb) program
FpMidiToKb. The reason for this new name is:
It avoids name conflicts in the big userlib of Keykit
CamelCase makes it easier to refer and discuss it in wikis
My initials show, who is (currently) the author
Should there be enough peer programmers here (or if there is not enough interest here), I move the program to the free
https://sourceforge.net, for collaborative work, supported by a version control system. Then of course it would be convenient for the team to drop the Prefix and we could call it simply
MidiToKb.
The program is functional, but currently it is not yet comfortable enough for the unexperienced enduser, but all the same useful for peer developers. saving them many hours of work, which I already have done for you.
For your convenience, I leave a copy of my programfiles here, that can be
annotated by the free Webannotation service of
http://Diigo.com.
Code:
######################### file 1/5 FpMidiToKbMain.k ################################
#
# FpMidiToKbMain Version 0.1 2006-12-04 (CommunityWiki:FridemarPache)
#
# by Fridemar Pache as my thankyou to the Keykit and the Autohotkey community,
# especially to the author of the Midi language system Keykit Tim Thompson and
# the the author(s) Chris Mallett as well as all the other peers.
# Special thanks to the authors of WikidPad and its community.
#
# I had reserved the domain name Metamidi.net as an incentive for those authors
# in Keykit/Autohotkey who would like to implement my sketched MidiKb-ideas.
# As nobody showed up yet, I didn't prolong the domain registration, but dear
# successor author feel free to take (or leave) it.
#
# With the ample power of (at least) the two mentionned communities, I hope that
# we get an incredible nice and useful system.. :-)
#
# Disclaimer: Use and tinker with the code at your own risk.
# On my systems it works anyhow.
# Note: The Layout of the fp_pitchmap is made for a 5 octave MidiKb.
# If you have less octaves, you must choose another EXIT_KEY
# Use:
# 1. Install Keykit (highly recommended) in your favorite directory
# For simplicity I took for the installation directory the following
# InstallDir="C:\\KeyKit7.4c"
# 1.0 Consult the Keykit manual how to connect your Midi-keyboard
# Ask Keykit specific questions in the KeyKit community.
# 1.1 Make sure, that your Midi-keyboard works in Keykit
# 2. add the following files in the system library, such that
# you have there:
# 2.0 InstallDir\lib\FpMidi2Kb.k (this is the current file, you are looking at)
# 2.1 InstallDir\lib\FpSendkeys.k
# 2.2 InstallDir\lib\FpPitchmap.k
# 2.3 InstallDir\lib\FpTextDict.txt
# 3. Add the macros of FpMidiToKb.ini to your AutoHotkey.ini
# 4. Install the free Wikidpad.exe in WikidPadInstDir="C:\Programme\WikidPad\"
# 4.1 Create your own personal desktop wiki "WikiPadWiki" (highly recommended) as
# "WkidPadInstDir"+"\\WikidPadWiki" as WikidPadCompact (relational mode)
# The data is stored in a single file with extension ".sli" under the data
# directory of the directory, your Wiki config is stored in. This
# database file is created by the Sqlite database engine.
#
# Reason: This way you can store thousands of AHK macros with excellent user main-
# tainability and optimal use of storage.
# 4.2 Study the manual, practice, ask questions in the WikiPad community
# Refer in AutoHotKey.ini to the lexicon, in which your macros are stored as
# LexWiki="C:\Programme\WikidPad\WikiPadWiki\WikiPadWiki.wiki
# 5. Start Keykit
# 6. input "MAINTASK=Task Midi2Kb()" (without the quotes in the commandline of
# Keykit; for convenience you can use the "Winhotkey x" macro
# #x::
# Send MAINTASK=task Midi2Kb(){enter}
# return
# Don't erase the following i nclude statements (these are no comments but
# compilerdirectives)
#include FpMidiToKbSendKeys.k
#include FpMidiToKbPitchMap.k
# #include fp-TextDict.k
InstallDir="C:\\KeyKit7.4c"
Debug=0
# TextDict=InstallDir+ "\\lib\\fp-TextDict.k"
TextDict=InstallDir+ "\\lib\\FpMidiToKbTextDict.txt"
MAX_Repeat=30
global IS_REPEAT
IS_REPEAT=0
RF_TASK=-1
QUOTE="\""
NEWLINE="\n"
LEFT_TD="TD" +"[" + QUOTE
MIDDLE_TD=QUOTE + "]" +"=" + QUOTE
RIGHT_TD=QUOTE
TD=[]
############################
# function temp_lx(key,text) {
# eval(LEFT_TD + key + MIDDLE_TD + text + RIGHT_TD)
# }
# function lx(key,text) {
# st=NEWLINE + LEFT_TD + key + MIDDLE_TD + text + RIGHT_TD
# f = open(TextDict,"a")
# put(f,st)
# close(f)
# }
function KeyReset() {
First=1 Nn="" Str="" VoiceCount=0 Voices=1 Modifiers=""
Merge=0 IsCr=0
Chord="" Duration=0
IsCmd = IsShift = IsBS = IsSP= IsCR= IsUndo= IsRedo= IsDouble=0 pkey="a"
}
function IsForte(m) {if (m.vol>64) return(1) else return(0)}
function IsLong(m) {if (m.dur>2b) return(1) else return(0)}
function IsShort(LastDuration) {if (LastDuration<1b) return(1) else return(0)}
Delimiters = ",.-( [{*=</|´"
function IsDelimiter(pkey) {
isdelimiter=0
len = sizeof(Delimiters)
for ( n=0; n<len; n++ ) {
if ( pkey==(substr(Delimiters,n+1,1)) ) { isdelimiter=1 break }
}
# print ("pkey=",pkey,isdelimiter)
return( isdelimiter)
}
function IsAlfa(pkey) { return ( (pkey>="a" && pkey<="z") ) }
function IsNum(pkey) { return ( (pkey>="0" && pkey<="9") ) }
function IsAlfaNum(pkey) { return ( IsAlfa(pkey) || IsNum(pkey) ) }
function IsEmphasizedAlfaNum(pkey,m) { return ( IsAlfaNum(pkey) && IsForte(m) ) }
function IsRepeatable(pkey,m) {
return ( IsDelimiter(pkey) || IsEmphasizedAlfaNum(pkey,m) )
}
function DoIntegerControlkeys(m,pkey) {
if (m.type==NOTEON) {
if (pkey==VK_SHIFT) { SingleShiftDown() return() }
if (pkey==CMD_KEY) { SingleCmdDown() return() }
if (pkey==VK_MENU) { AltDown() return() }
if (pkey==VK_CONTROL) { CtrDown() return() }
if (pkey==VK_RMENU) { GrAltDown() return() }
if (pkey==VK_LWIN) { WinDown() return() }
if (pkey==VK_SPACE) {fun=SendKey if (IsForte(m)) pkey=VK_TAB}
if (pkey==VK_OEM_102) { if (IsForte(m)) fun=SendKey else fun=SendKey}
if (pkey==VK_OEM_6) { if (IsForte(m)) fun=SendSKey else fun=SendKey}
if (pkey==VK_OEM_5) { if (IsForte(m)) fun=SendSKey else fun=SendKey}
if (pkey==VK_Z) { if (IsForte(m)) fun=SendCSKey else fun=SendCKey }
if (pkey==VK_LEFT || pkey==VK_RIGHT || pkey==VK_UP || pkey==VK_DOWN ) {
if(IsForte(m)) fun=SendSKey else fun=SendKey
}
if (pkey==VK_BACK || pkey==VK_DELETE ) {
if(IsForte(m)) fun=SendCKey else fun=SendKey
}
AUTOKEY_TASK= task autoKey(fun,pkey)
} else if (m.type==NOTEOFF) {
if (pkey==VK_MENU) AltUp()
if (pkey==VK_CONTROL) CtrUp()
if (pkey==VK_RMENU) GrAltUp()
if (pkey==VK_LWIN) WinUp()
}
}
# associative array with function values
EmphasizedKey=[
"a"=CR,
"b"=BS,
"c"=CR,
"d"=SP,
"e"=End,
"f"= SP,
"g"= SP,
"h"=Down,
"i"= SP,
"j"= SP,
"k"= SP,
"l"=Left,
"m"=Right,
"n"=Up,
"o"=Home,
"p"= SP,
"q"= SP,
"r"=Redo,
"s"= SP,
"t"= Tab,
"u"=Undo,
"v"= SP,
"w"= SP,
"x"= SP,
"y"= SP,
"z"= ReadTextDictionary,
" "= SP,
"0"= SP,
"1"= SP,
"2"= SP,
"3"= SP,
"4"= SP,
"5"= SP,
"6"= SP,
"7"= SP,
"8"= SP,
"9"= SP
]
function DoEmphasizedKeys(pkey) {
# SplitTest()
fun=EmphasizedKey[pkey]
if (fun!="")
RF_TASK = task RepeatFunction(fun,ascii(pkey))
else
print("the empasized pkey",pkey, "is not assigned")
return()
# The author has left enough SPace to make your own assignments.
# Fill in your preferences and publish it in the autokey-forum
# for discussion
}
function Midi2Kb() {
RF_TASK= AUTOSHIFT_TASK= AUTOPITCH_TASK= MK= AUTOKEY_TASK=-1
fun=SendKey
ReadTextDictionary()
Midiin[$] = f = open()
onexit(closemidi,$)
KeyReset()
while ( (m=get(f)) != Eof ) {
kill(AUTOPITCH_TASK)
kill(AUTOKEY_TASK)
kill(RF_TASK)
IsOldPkey=0
#print("IsShift=",IsShift,"OldPkey=",OldPkey)
# EXIT_KEY
# print(m.pitch) kill(MAINTASK)
# exit
if (m.pitch == 36 ) {
# kill(MAINTASK)
return()
}
if (m.pitch == DOUBLE_KEY){
if (m.type==NOTEOFF) IsDouble=0
if (m.type==NOTEON) IsDouble=1
pkey=OldPkey
isOldPkey=1
}
else {
pkey=Fp_Pitchmap[m.pitch]
if (typeof(pkey)=="integer") {
DoIntegerControlkeys(m,pkey)
continue
}
}
if (m.type==NOTEON) {
IsOldPkey=1
OldPkey=pkey # it's a valid noninteger key
if (IsShift) OldPkey=uppercase(OldPkey)
}
if (m.dur==0) {
if (Debug==1) { if (VoiceCount == 0) Nn += "(" }
#pkey=qualifiedNote(m)
if (IsDouble==0) {
# uncomment the following line, if you have trained enough in
# the pressure insensitive-mode and you have studied the fp-Pitchmap table!!:
if ( IsForte(m)) { DoEmphasizedKeys(pkey) continue }
if (IsRepeatable(pkey,m)) {
if (pkey==".") IsShift=1 else {
if (pkey!=" " && pkey!=VK_RETURN) IsShift=0
}
# DoRepeatable(pkey,m)
continue
}
if (IsShift) { pkey=uppercase(pkey) SingleShiftDown() }
if (pkey!=VK_SPACE && pkey!=VK_RETURN && pkey!= " ") IsShift=0
} else { if (IsShift) SingleShiftDown()
}
Nn += pkey
# print ("Nn=",Nn)
Chord += pkey
if (Chord==".") IsShift=1
VoiceCount +=1
continue
}
# if (Debug==1) {print("VoiceCount=",VoiceCount,"Nn=",Nn)}
if (m.dur>0) {
Duration=1 #default for Isdouble
LastDuration=m.dur
if (IsDouble==0) {if (m.dur>Duration) Duration=m.dur}
if (VoiceCount == 1) {
VoiceCount=0
# legato chord feature
if (Chord!="") {
SendEdit(Chord,Voices,IsCmd,LastDuration)
if (Chord==".") IsShift=1 else IsShift=0
Chord="" Duration=0
if (Debug==1) { Nn += ")" print("<",Nn,">")}
Voices=1
}
}
if (VoiceCount > 1) { VoiceCount -=1 Voices +=1 }
SingleShiftUp()
}
} #while
} #function
#####################################
# SendEdit sends string nn in the editor or calls macroname nn for special processing,
# depending on IsCmd, which controls the respective send mode.
# In this version we use preferably the PSPad.
# The simplest macros are replacements, handled via the associative array TD
# If TD has no entry, a possibly more complex macro is handled in Autohotkey
# Think of nn as (arpeggiated) chord with
# Voices=1 single Midi keypress
# Voices>1 a chord with the number "Voices" of voices on the Midi keyboard
# IsShort(..)=1 means, the last keypress has a short duration
# IsShort(..)=0 means, the last keypress has a long duration
function SendEdit(nn,Voices,IsCmd,LastDuration) {
if (IsShort(LastDuration)) {
if (IsCmd) SendMacro(nn)
else {
if (Voices>1) nn=nn+" "
SendKeys(nn)
}
}
else {
if (TD[nn]=="") {
SendMacro(nn) }
else {
st=TD[nn]
# SendKeys(st)
SendKeysAndPosition(st)
}
}
}
function SingleShiftDown() {
if (IsShift) SingleShiftUp() else {
IsShift=1
AUTOSHIFT_TASK=realtime( repeat('c4',160 ))
}
}
function SingleShiftUp() {
# IsShift=0
kill(AUTOSHIFT_TASK)
}
function SingleCmdDown() {
if (IsCmd) SingleCmdUp() else {
IsCmd=1
ASCO=realtime( repeat('d3 f3 a3',160 ))
}
}
function SingleCmdUp() {
IsCmd=0
kill(ASCO)
}
function DoRepeatable(pkey) {
ic=ascii(pkey)
fun=SendKey
AUTOKEY_TASK=task autoKey(fun,ic)
return()
}
function RepeatFunction(fun,ic) {
fun()
p=makenote(ic)
realtime(p)
sleeptill(Now+1b/2)
for (i=1;i<=MAX_Repeat;i++) {
realtime(p)
fun()
sleeptill(Now+1b/8)
}
return()
}
function autoKey(fun,ic) {
fun(ic)
p=makenote(ic)
realtime(p)
sleeptill(Now+1b/2)
for (i=1;i<=MAX_Repeat;i++) {
realtime(p)
fun(ic)
sleeptill(Now+1b/8)
}
return()
}
function TranslateEscapes(s) {
trans=""
for(i=1;i<=sizeof(s)-1;i++) {
ss= substr(s,i,1)
if (ss=="\\") {
i+=1
ss= substr(s,i,1)
if ( ss=="n" ) trans += VK_RETURN
} else
trans += ss
}
return(trans)
}
function TailOf(LineAsArray) {
tail=LineAsArray[1]
for(i=2;i<sizeof(LineAsArray);i++) {
tail +=" "+ TranslateEscapes(LineAsArray[i])
}
return(tail)
}
function ReadTextDictionary() {
print("read ",TextDict," !")
tr= task realtime('d,f,a,d')
f = open(TextDict)
if ( f < 0 ) {
return("")
}
for ( n=1; (v=get(f)) != Eof; n++ ) {
LineAsArray=split(v)
head=LineAsArray[0]
tail=TailOf(LineAsArray)
TD[head]=tail
# print(head,sizeof(head),"=",tail)
}
close(f)
wait(100)
kill(tr)
return()
}
Code:
######################### FpMidiToKbPitchMap 0.1 2/5 ##########################
Fp_Pitchmap=[
0="c-2", #c-2------------------
1="i-2", #i-2
2="d-2", #d-2
3="s-2", #s-2
4="e-2", #e-2
5="f-2", #f-2
6="j-2", #j-2
7="g-2", #g-2
8="k-2", #k-2
9="a-2", #a-2
10="b-2", #b-2
11="h-2", #h-2
12="c-1", #c-1------------------
13="i-1", #i-1
14="d-1", #d-1
15="s-1", #s-1
16="e-1", #e-1
17="f-1", #f-1
18="j-1", #j-1
19="g-1", #g-1
20="k-1", #k-1
21="a-1", #a-1
22="b-1", #b-1
23="h-1", #h-1
24="c0", #c0------------------
25="i0", #i0
26="d0", #d0
27="s0", #s0
28="e0", #e0
29="f0", #f0
30="j0", #j0
31="g0", #g0
32="k0", #k0
33="a0", #a0
34="b0", #b0
35="h0", #h0
36=EXIT_KEY, #c1================== exit ==========================
37=CMD_KEY, #i1 User key to introduce Macro Command
38=VK_DELETE, #d1 VK_DELETE 46 2E Delete Key
39=VK_SPACE, #s1 VK_SPACE 32 20 Spacebar
40=VK_BACK, #e1 VK_BACK 8 8 Backspace Key
41="f", #f1 VK_SHIFT 16 10 Shift Key
42=VK_SHIFT, #j1 VK_SHIFT 16 10 Shift Key
43=VK_DOWN, #g1 VK_DOWN 40 28 Down Key
44=VK_CONTROL, #k1 VK_CONTROL 17 11 Control Key
45=VK_UP, #a1 VK_UP 38 26 Up Key
46=VK_MENUE, #b1 VK_MENUE 18 12 Alt Key
47=DOUBLE_KEY, #h1 User key to double the last char, typed in
48="c", #c2------------------
49="i", #i2
50="d", #d2
51="s", #s2
52="e", #e2
53="f", #f2
54="j", #j2
55="g", #g2
56="k", #k2
57="a", #a2
58="b", #b2
59="h", #h2
60="l", #c3------------------
61="m", #i3
62="n", #d3
63="o", #s3
64="p", #e3
65="q", #f3
66="r", #j3
67="s", #g3
68="t", #k3
69="u", #a3
70="v", #b3
71="w", #h3
72="x", #c4------------------
73="y", #i4
74="z", #d4
75=" ", #s4 / understroke
76=",", #e4 / semicolon
77=".", #f4 / colon
78="-", #j4 / +
79="(", #g4 / )
80="[", #k4 / ]
81="{", #a4_ / }
82="<", #b4 / >
83="|", #h4 / ?
84="0", #c5------------------ / =
85="1", #i5 / !
86="2", #d5 / quote
87="3", #s5 / §
88="4", #e5 / $
89="5", #f5 / %
90="6", #j5 / &
91="7", #g5 / /
92="8", #k5 / (
93="9", #a5 / )
94="*", #b5 Vertical bar / ?
95=VK_OEM_6, #h5 French accent ´ / `
96=VK_OEM_5, #c6================== ^ / ° ============================
97="i6", #i6
98="d6", #d6
99="s6", #s6
100="e6", #e6
101="f6", #f6
102="j6", #j6
103="g6", #g6
104="k6", #k6
105="a6", #a6
106="b6", #b6
107="h6", #h6
108="c7", #c7------------------
109="i7", #i7
110="d7", #d7
111="s7", #s7
112="e7", #e7
113="f7", #f7
114="j7", #j7
115="g7", #g7
116="k7", #k7
117="a7", #a7
118="b7", #b7
119="h7", #h7
120="c8", #c8------------------
121="i8", #i8
122="d8", #d8
123="s8", #s8
124="e8", #e8
125="f8", #f8
126="j8", #j8
127="g8", #g8
"0"=[0=SendSKey, 1=VK_0],
"1"=[0=SendSKey, 1=VK_1],
"2"=[0=SendSKey, 1=VK_2],
"3"=[0=SendSKey, 1=VK_3],
"4"=[0=SendSKey, 1=VK_4],
"5"=[0=SendSKey, 1=VK_5],
"6"=[0=SendSKey, 1=VK_6],
"7"=[0=SendSKey, 1=VK_7],
"8"=[0=SendSKey, 1=VK_8],
"9"=[0=SendSKey, 1=VK_9],
"a"=[0=SendGKey, 1=VK_Q], # / @
"b"=[0=SendKey, 1=VK_BACK], # / backspace
"c"=[0=SendSKey, 1=VK_C],
"d"=[0=SendKey, 1=VK_DELETE], # / delete
"e"=[0=SendSKey, 1=VK_E],
"f"=[0=SendSKey, 1=VK_F],
"g"=[0=SendSKey, 1=VK_G],
"h"=[0=SendKey, 1=VK_HOME], # / Cursor home
"i"=[0=SendSKey, 1=VK_I],
"j"=[0=SendSKey, 1=VK_J],
"k"=[0=SendSKey, 1=VK_K],
"l"=[0=SendKey, 1=VK_LEFT], # / Cursor left
"m"=[0=SendKey, 1=VK_RIGHT], # / Cursor right
"n"=[0=SendKey, 1=VK_END], # / End
"o"=[0=SendKey, 1=VK_DOWN], # / Cursor down
"p"=[0=SendKey, 1=VK_UP], # / Cursor up
"q"=[0=SendSKey, 1=VK_Q],
"r"=[0=SendCSKey,1=VK_Z], # / Redo in PS Pad
"s"=[0=SendKey, 1=VK_SPACE], # / Spacebar
"t"=[0=SendKey, 1=VK_RETURN], # / Enter
"u"=[0=SendCKey, 1=VK_Z], # / Undo in PS Pad
"v"=[0=SendSKey, 1=VK_V],
"w"=[0=SendSKey, 1=VK_W],
"x"=[0=SendKey, 1=VK_OEM_2], # / #
"y"=[0=SendSKey, 1=VK_OEM_2], # / '
"z"=[0=SendGKey, 1=VK_OEM_PLUS], # / ~
" "=[0=SendKey, 1=VK_SPACE, 2=SendSKey, 3=VK_OEM_MINUS], # Underscore
","=[0=SendKey, 1=VK_OEM_COMMA, 2=SendSKey, 3=VK_OEM_COMMA], # ;
"."=[0=SendKey, 1=VK_OEM_PERIOD, 2=SendSKey, 3=VK_OEM_PERIOD], # :
"-"=[0=SendKey, 1=VK_OEM_MINUS, 2=SendKey, 3=VK_OEM_PLUS], # +
"("=[0=SendSKey, 1=VK_8, 2=SendSKey, 3=VK_9], # )
"["=[0=SendKey, 1=VK_OEM_3, 2=SendSKey, 3=VK_OEM_3], # ]
"{"=[0=SendKey, 1=VK_OEM_7, 2=SendSKey, 3=VK_OEM_7], # }
"*"=[0=SendSKey, 1=VK_OEM_PLUS, 2=SendSKey, 3=VK_OEM_PERIOD], # :
"="=[0=SendSKey, 1=VK_0, 2=SendSKey, 3=VK_OEM_PLUS], # *
"<"=[0=SendKey, 1=VK_OEM_102, 2=SendSKey, 3=VK_OEM_102], # >
"/"=[0=SendSKey, 1=VK_7, 2=SendSKey, 3=VK_OEM_1], # Backslash
"|"=[0=SendKey, 1=VK_OEM_4, 2=SendSKey, 3=VK_OEM_4], # ?
"||"=[0=SendKey, 1=VK_OEM_4, 2=SendSKey, 3=VK_OEM_4] # not yet
]
NonAlfaNumMap = [
DOUBLE_KEY= [0=SendSKey, 1=VK_OEM_MINUS],
VK_SPACE= [0=SendKey, 1=VK_SPACE, 2=SendKey, 3=VK_TAB],
VK_BACK= [0=SendKey, 1=VK_BACK, 2=SendCKey, 3=VK_BACK]
]
####################################################################
Code:
########################## FpMidiToKbSendKeys.k 1.0 3/5 ########################
################################## #user-constants !!
EXIT_KEY=36 #c1
CMD_KEY=37 #i1
DOUBLE_KEY=47 #h1
####################################
# These are the transferred MacroTypes for Macro RControl:: in AutoIni.ahs
# for the Authotkey system
PASTE_IT="1"
CALL_WIKIPAD_MACRO="2"
EDIT_WIKIPAD_MACRO="3"
VK_0=48 #30 Key 0
VK_1=49 #31 Key 1
VK_2=50 #32 Key 2
VK_3=51 #33 Key 3
VK_4=52 #34 Key 4
VK_5=53 #35 Key 5
VK_6=54 #36 Key 6
VK_7=55 #37 Key 7
VK_8=56 #38 Key 8
VK_9=57 #39 Key 9
VK_F1=112 #70 F1 Key
VK_F2=113 #71 F2 Key
VK_F3=114 #72 F3 Key
VK_F4=115 #73 F4 Key
VK_F5=116 #74 F5 Key
VK_F6=117 #75 F6 Key
VK_F7=118 #76 F7 Key
VK_F8=119 #77 F8 Key
VK_F9=120 #78 F9 Key
VK_F10=121 #79 F10 Key
VK_F11=122 #7A F11 Key
VK_F12=123 #7B F12 Key
VK_A=65 #41 A letter
VK_B=66 #letter
VK_BACK=8 #08 Backspace Key
VK_C=67 #letter
VK_CONTROL=17 #11 Control Key
VK_D=68 #letter
VK_DELETE=46 #2E Delete Key
VK_DOWN=40 #28 Down Key
VK_E=69 #letter
VK_END=35 #23 End Key
VK_F=70 #letter
VK_G=71 #letter
VK_H=72 #letter
VK_HOME=36 #24 Home Key
VK_I=73 #letter
VK_J=74 #letter
VK_K=75 #letter
VK_L=76 #letter
VK_LEFT=37 #25 Left Key
VK_LSHIFT=160 #A Left Shift
VK_LWIN=0x5B #5B Left Windows Key
VK_M=77 #letter
VK_MENU=18 #12 Alt Key
VK_LMENU = 164
VK_N=78 #letter
VK_O=79 #letter
VK_OEM_COMMA=188 #BC ',' Key
VK_OEM_PERIOD=190 #BE '.' Key
VK_OEM_PLUS=187 #BB '+' Key
VK_OEM_MINUS=189 #BD '-' Key
VK_OEM_102=226 #E2 '|' Key, Misc chars. <,>
VK_OEM_1=186 #BA Misc chars. US: ';:' Key
VK_OEM_2=191 #BF Misc chars. US: '/?' Key
VK_OEM_3=192 #C0 Misc chars. US: '`~' key
VK_OEM_4=219 #DB ß Beta Key, Misc chars.
VK_OEM_5=220 #DC Misc chars. US: '\^^ °' Key
VK_OEM_6=221 #DD Misc chars. US: ']}' Key
VK_OEM_7=222 #DE Misc chars. US: Quotes Key
VK_OEM_8=223 #DF Misc chars
VK_PIPE=226
VK_BACKSLASH=VK_OEM_4
VK_AT=64
VK_P=80 #letter
VK_Q=81 #letter
VK_R=82 #letter
VK_RCONTROL=163 #A3 Right Control Key
VK_RETURN=13 #VK_D Enter Key
VK_RIGHT=39 #27 Right Key
VK_RMENU=165 #165 Altr Graphics (A5)
VK_S=83 #letter
VK_SHIFT=16 #10 Shift Key
VK_SPACE=32 #20 Spacebar
VK_T=84 #letter
VK_TAB=9 #Tabulator
VK_U=85 #letter
VK_UP=38 #26 Up Key
VK_V=86 #letter
VK_W=87 #letter
VK_X=88 #letter
VK_Y=89 #letter
VK_Z=90 #letter
VK_NUMPAD0 =96 #60
VK_NUMPAD1 =97 #61
VK_NUMPAD2 =98 #62
VK_NUMPAD3 =99 #63
VK_NUMPAD4 =100 #64
VK_NUMPAD5 =101 #65
VK_NUMPAD6 =102 #66
VK_NUMPAD7 =103 #67
VK_NUMPAD8 =104 #68
VK_NUMPAD9 =105 #69
VK_MULTIPLY =106 #6A
VK_ADD =107 #6B
VK_SUBTRACT =109 #6D
VK_DECIMAL =110 #6E
VK_DIVIDE =111 #6F
IsShift=0
KEYDOWN=0
KEYUP=1
LOWA = ascii("a")
LOWZ = ascii("z")
UPA = ascii("A")
UPZ = ascii("Z")
DIGIT0 = ascii("0")
DIGIT9 = ascii("9")
function uppercase(c) {
ac = ascii(c)
if ( LOWA<=ac && ac<=LOWZ )
c = ascii( ac - LOWA + UPA )
return(c)
}
function StringUppercase(s){
retv=""
for (i=1;i<=sizeof(s);i++) {
retv+=uppercase(substr(s,i,1))
}
return(retv)
}
function wait(ms){sleeptill(Now+ms)}
function SendKeydown(c) { mdep("sendinput","keyboard",c,KEYDOWN)}
function SendKeyup(c) { mdep("sendinput","keyboard",c,KEYUP)}
function SendKey(c) { SendKeydown(c) SendKeyup(c)}
function RMDown() { SendKeydown(VK_RMENU) }
function RMUp() { SendKeyup(VK_RMENU) }
function ShiftDown() { SendKeydown(VK_SHIFT) }
function LShiftDown() { SendKeydown(VK_LSHIFT) }
function ShiftUp() { SendKeyup(VK_SHIFT)}
function LShiftUp() { SendKeyup(VK_LSHIFT)}
function CtrDown() { SendKeydown(VK_CONTROL)}
function CtrUp() { SendKeyup(VK_CONTROL)}
function AltDown() { SendKeydown(VK_MENU)}
function AltUp() { SendKeyup(VK_MENU)}
function AllModifiersDown() { ShiftDown() CtrDown() AltDown()}
function AllModifiersUp() { AltUp() CtrUp() ShiftUp()}
function GrAltDown() { SendKeydown(VK_RMENU) }
function GrAltUp() { SendKeyup(VK_RMENU) }
function WinDown() { SendKeydown(VK_LWIN) }
function WinUp() { SendKeyup(VK_LWIN) }
function RControl() { SendKey(VK_RCONTROL) }
function SendRMKey(c) { RMDown() SendKey(c) RMUp() }
function SendGKey(c) { GrAltDown() SendKey(c) GrAltUp() }
function SendAKey(c) { AltDown() SendKey(c) AltUp() }
function SendACKey(c) { AltDown() SendCKey(c) AltUp() }
function SendACSKey(c) { AltDown() SendCSKey(c) AltUp() }
function SendASKey(c) { AltDown() SendSKey(c) AltUp() }
function SendCKey(c) { CtrDown() SendKey(c) CtrUp() }
function SendCSKey(c) { CtrDown() SendSKey(c) CtrUp() }
function SendSKey(c) { ShiftDown() SendKey(c) ShiftUp() }
function CR() { SendKey(VK_RETURN)}
function BS() { SendKey(VK_BACK)}
function SP() { SendKey(VK_SPACE)}
function Undo() { SendCKey(VK_Z)} # e.g. for PSPad
function Redo() { SendCSKey(VK_Z)} # e.g. for PSPad
function Left() { SendKey(VK_LEFT)}
function Right() { SendKey(VK_RIGHT)}
function ShiftRight() { SendMacro("!rs")} # a test for right select
#function ShiftRight() { SendSKey(VK_A)}
function Down() { SendKey(VK_DOWN)}
function Up() { SendKey(VK_UP)}
function Home() { SendKey(VK_HOME)}
function End() { SendKey(VK_END)}
function Tab() { SendKey(VK_TAB)}
# function SplitTest() {
# x=split("Null Eins zwei drei")
# for (i=0;i<4;i++) print(x[i])
# print("Das wars.")
# }
# time it to your convenience
function SendMacro(nn) {
RControl() # starting "remote control" in AutoKey
sleeptill(Now+10)
SendKeys("2") # Currently only this evaluate mode for WikidMacros is used
sleeptill(Now+10)
SendKeys(nn)
sleeptill(Now+10)
CR() # to leave the RControl loop in AutoKey.
}
# This routine needs perhaps some completion and systematization
function SendKeys(s) {
if ( Machine != "win" ) {
print("SendKeys() only works on Windows, sorry!")
return()
}
len = sizeof(s)
for ( n=0; n<len; n++ ) {
c = ascii(substr(s,n+1,1))
if ( LOWA <= c && c <= LOWZ ) {c += (UPA-LOWA) SendKey(c)}
else if ( c >= UPA && c <= UPZ ) {SendSKey(c)}
else if ( c >= DIGIT0 && c <= DIGIT9 ) {SendKey(c)}
else if ( c == ascii("\n") ) {SendKey(VK_RETURN)}
else if ( c == ascii(" ") ) {SendKey(VK_SPACE)}
else if ( c == ascii("@") ) {SendRMKey(VK_Q)}
else if ( c == ascii("!") ) {SendSKey(ascii("1"))}
else if ( c == ascii(",") ) {SendKey(VK_OEM_COMMA)}
else if ( c == ascii(".") ) {SendKey(VK_OEM_PERIOD)}
else if ( c == ascii("-") ) {SendKey(VK_OEM_MINUS)}
else if ( c == ascii(";") ) {SendSKey(VK_OEM_COMMA)}
else if ( c == ascii(":") ) {SendSKey(VK_OEM_PERIOD)}
else if ( c == ascii("_") ) {SendSKey(VK_OEM_MINUS)}
else if ( c == ascii("+") ) {SendKey(VK_OEM_PLUS)}
else if ( c == ascii("*") ) {SendSKey(VK_OEM_PLUS)}
else if ( c == ascii("=") ) {SendSKey(VK_0)}
else if ( c == ascii("(") ) {SendSKey(VK_8)}
else if ( c == ascii(")") ) {SendSKey(VK_9)}
else if ( c == ascii("[") ) {SendGKey(VK_8)}
else if ( c == ascii("|") ) {SendRMKey(VK_PIPE)}
else if ( c == ascii("]") ) {SendGKey(VK_9)}
else if ( c == ascii("{") ) {SendGKey(VK_7)}
else if ( c == ascii("}") ) {SendGKey(VK_0)}
else if ( c == ascii("/") ) {SendSKey(VK_7)}
else if ( c == ascii("<") ) {SendKey(VK_OEM_102)}
else if ( c == ascii(">") ) {SendSKey(VK_OEM_102)}
else if ( c == ascii("\"") ) {SendSKey(VK_2)}
else if ( c == ascii("\\") ) {
c = substr(s,n+2,1)
if (c=="n") {CR() n+=1} else {SendGKey(VK_BACKSLASH)}
}
else
{
SendSKey(VK_OEM_4)
print("\nSorry, unvalid char: ",c,"[",ascii(c),"]\n")
}
}
}
function PositionOnPipe(s) {
for(i=sizeof(s); i>0; i--){
ss=substr(s,i,1)
if (ss=="|") {
for(j=sizeof(s); i<=j; j--) {Left()}
#sleeptill(Now+1b/32)
ShiftRight()
return()
}
}
return()
}
function SendKeysAndPosition(s) {
SendKeys(s)
PositionOnPipe(s)
#for(i=1;i<3;i++) Left()
}
function OEM_Test() {
CR()
CR()
SendKeys("===========================================>")
CR()
SendKey(VK_OEM_COMMA ) #BC ',' Key
SendKey(VK_OEM_PLUS ) #BB '+' Key
SendKey(VK_OEM_MINUS ) #BD '-' Key
SendKey(VK_OEM_102 ) #E2 '|' Key, Misc chars. <,>
SendKey(VK_OEM_1 ) #BA Misc chars. US: ';:' Key
SendKey(VK_OEM_2 ) #BF Misc chars. US: '/?' Key
SendKey(VK_OEM_3 ) #C0 Misc chars. US: '`~' key
SendKey(VK_OEM_4 ) #DB ß Beta Key, Misc chars.
SendKey(VK_OEM_5 ) #DC Misc chars. US: '\^^ °' Key
SendKey(VK_OEM_6 ) #DD Misc chars. US: ']}' Key
SendKey(VK_OEM_7 ) #DE Misc chars. US: Quotes Key
SendKey(VK_OEM_8 ) #DF Misc chars
SendKey(VK_OEM_PERIOD ) #BE '.' Key
CR()
SendKeys("*********")
CR()
SendSKey(VK_OEM_COMMA ) #BC ',' Key
SendSKey(VK_OEM_PLUS ) #BB '+' Key
SendSKey(VK_OEM_MINUS ) #BD '-' Key
SendSKey(VK_OEM_102 ) #E2 '|' Key, Misc chars. <,>
SendSKey(VK_OEM_1 ) #BA Misc chars. US: ';:' Key
SendSKey(VK_OEM_2 ) #BF Misc chars. US: '/?' Key
SendSKey(VK_OEM_3 ) #C0 Misc chars. US: '`~' key
SendSKey(VK_OEM_4 ) #DB ß Beta Key, Misc chars.
SendSKey(VK_OEM_5 ) #DC Misc chars. US: '\^^ °' Key
SendSKey(VK_OEM_6 ) #DD Misc chars. US: ']}' Key
SendSKey(VK_OEM_7 ) #DE Misc chars. US: Quotes Key
SendSKey(VK_OEM_8 ) #DF Misc chars
SendSKey(VK_OEM_PERIOD ) #BE '.' Key
CR()
SendKeys("*********")
CR()
SendGKey(VK_OEM_COMMA ) #BC ',' Key
SendGKey(VK_OEM_PLUS ) #BB '+' Key # / squiggle ~
SendGKey(VK_OEM_MINUS ) #BD '-' Key
SendGKey(VK_OEM_102 ) #E2 '|' Key, Misc chars. <,>
SendGKey(VK_OEM_1 ) #BA Misc chars. US: ';:' Key
SendGKey(VK_OEM_2 ) #BF Misc chars. US: '/?' Key
SendGKey(VK_OEM_3 ) #C0 Misc chars. US: '`~' key
SendGKey(VK_OEM_4 ) #DB ß Beta Key, Misc chars.
SendGKey(VK_OEM_5 ) #DC Misc chars. US: '\^^ °' Key
SendGKey(VK_OEM_6 ) #DD Misc chars. US: ']}' Key
SendGKey(VK_OEM_7 ) #DE Misc chars. US: Quotes Key
SendGKey(VK_OEM_8 ) #DF Misc chars
SendGKey(VK_OEM_PERIOD ) #BE '.' Key
CR()
SendKeys("*********")
CR()
SendKeys("<======================================================")
CR()
}
################################################################################
Code:
################ FpMidiToKbTextDictionary.txt 0.1 4/5 ###without Hash signed lines ############
abf \nAlltheBest\n\nFridemar\n\n
da http://www.diigo.com/tag/
by BhaktiYoga
d http://www.diigo.com/tag
lpf \nLove and Peace\nFridemar\Pache\n\n
rc RecentChanges
mbp Meatball:
mbbl DiiGo: wiki annotation communication skills CategoryConflict
mbu http://www.usemod.com/cgi-bin/mb.pl?
ta ThisWikiPageIsDiigoAnnotated
wan wiki annotation fridemar
fan forum |annotation fridemar
df Diigo annotations: http://www.diigo.com/user/fridemar
Code:
######### FpMidiToKbMacros.ini 0.1 5/5 #########################
#p::
run,"C:\Programme\PSPad editor\PSPad.exe"
return
!^r::
Reload
return
;!^l::
;Loop, 1000
;{
; Send, {DOWN}
; Sleep, 1500
;}
;return
ß::Sendraw |
ö::Sendraw [
Ö::Sendraw ]
ä::Sendraw {
Ä::Sendraw }
ü::Sendraw /
Ü::Sendraw \
; !8::Sendraw |
#r::
Sendraw #include fpRepeater.k
Send {enter}
return
#s::
Sendraw #include fp-ssort.k
Send {enter}
return
#t::
msgbox 'test'
return
#w::
run C:\Programme\WikidPad\WikidPad.exe
return
#x::
; Send MAINTASK=Task Midi2Kb(){enter}
Send Midi2Kb(){enter}
return
#y::
Sendraw #include FpMidiToKbMain.k
Send {enter}
return
:?*: .::.{space}
:?*: ,::,{space}
:?*: `;::{;}{space}
:?*: `?::{?}{space}
:?*: `!::{!}{space}
ToStartOfBody(){
Send {CTRLDOWN}{HOME}{CTRLUP}{DOWN}{DOWN}
return
}
SelectToEnd(){
Send {SHIFTDOWN}{CTRLDOWN}{END}{CTRLUP}{SHIFTUP}
return
}
CopyToClipboard() {
clipboard = ; Empty the clipboard
Send, ^c
ClipWait, 2
if ErrorLevel <> 0
{
MsgBox, The attempt to copy text onto the clipboard failed.
return
}
;msgBox, clipboard = %clipboard%
return
}
CopyWikiBody(){
ToStartOfBody()
Sleep 10
SelectToEnd()
CopyToClipboard()
Sleep, 100
return
}
PasteIt() {
Send {CTRLDOWN}v{CTRLUP}
}
OpenWikiWord(WikiName) {
Send, {CTRLDOWN}o{CTRLUP}
;IfWinNotActive, Open Wiki Word, , WinActivate, Open Wiki Word,
;WinWaitActive, Open Wiki Word,
sleep, 100
Send, %WikiName%{ENTER}
}
PasteOrEvalClip(val) {
if val=1
PasteIt()
if val=2
EvalClip()
return
}
;val=1 paste, val=2 evaluate, val=3 edit
WWWord(WikiName,val) {
LexWiki:="C:\Programme\WikidPad\WikiPadWiki\WikiPadWiki.wiki"
LexWikiCaption=Wiki: %LexWiki%
;Save Edit Context
WinGetActiveTitle, Title
;Switch to LexWiki
IfWinNotExist, %LexWikiCaption%
Run, %LexWiki%
IfWinNotActive %LexWikiCaption%
WinActivate %LexWikiCaption%
WinWaitActive %LexWikiCaption%
; Enter Wiki Word
OpenWikiWord(WikiName)
if val>=3
return
; Get WikiPageBody
IfWinNotActive, %LexWikiCaption% - %WikiName%,
WinActivate, %LexWikiCaption% - %WikiName%,
;WinWaitActive, %LexWikiCaption% - %WikiName%, ,1
sleep, 100
CopyWikiBody()
;Restore Edit Context
IfWinNotActive, %Title%, , WinActivate, %Title%,
;WinWaitActive, %Title%,
sleep, 10
PasteOrEvalClip(val)
return
}
;Remote Control subroutine and RControl key
RControl::
input Cmd,,{enter}
; msgbox %Cmd%
StringMid Macro, Cmd, 2
StringMid Macrotype, Cmd, 1, 1
; msgbox %MacroType%
; msgbox %Macro%
if (Macro=="!rs") {
Send, {SHIFTDOWN}{RIGHT}{SHIFTUP}
} else
WWWord(Macro,Macrotype)
return
RunMacro(name) {
MacroDir=C:\Programme\AutoHotkey\AutoScriptWriter\
MacroExt=.ahk
Run %MacroDir%%name%%MacroExt%
return
}
^!t::
WikiName:="Lpfa"
WWWord(WikiName,"0")
return
^!z::
WikiName:="Cwg"
WWWord(WikiName,"0")
return
Numpad0 & Numpad1::
Send ^s
Reload
return
MoveCaret:
IfWinNotActive, New Hotstring
return
; Otherwise, move the InputBox's insertion point to where the user will type the abbreviation.
Send {Home}{Right 3}
SetTimer, MoveCaret, Off
return
;=============================================
!r::
;Eval Clipboard in a temp file
EvalClip()
return
EvalClip() {
;Thank you VxE in the AHK-community.
MyClipExecuteLifespan = 15
SetWorkingDir %A_ScriptDir%
MyClipExecuteLifespan *= 1000
script = %clipboard%
IfExist, mtemp.ahk
Filedelete, mtemp.ahk
header = `; header for dynamic miniscript executor;`r`n`;if you are looking at this , it probably means the script bugged out for some reason`r`n#singleinstance force`r`nsendmode event`r`nFileDelete, `%A_ScriptFullPath`%`r`nSetTimer, lifespan, %MyClipExecuteLifespan% `; give this script an expiration date`r`ngoto next`r`nreturn`r`nlifespan:`r`nexitapp`r`n`; end of header, commands go below this line`r`nnext:`r`n`r`n
FileAppend, %header%%script%, mtemp.ahk
sleep 200
run, mtemp.ahk
}
;===============================================