falconv Posted October 13, 2005 Posted October 13, 2005 Hi everyone, I'm trying to remap my keyboard almost entirely, but the easiest way (using HotKeySet()) is limited to 64, but I need 94 to map any and all lowercase, uppercase, and symbols (I just need those, I don't need to remap any function keys, shift, enter, alt, control, etc). For an example of what I'm trying to do, let's say I want to remap the letters F, a, l, c, o, n, and V to (respectively) V, n, o, c, l, a, F (okay, so 'c' isn't really changed, but this is just for an example), then if the program is running, if someone were to try to type FalconV, it would actually come out as VnoclaF. See? I actually just tried to make a quick script to do the above example, but kept getting a buffer overrun when I tried to run it, so maybe it's not as simple as I was hoping. Any ideas would be great. I've tried _IsPressed, but have just started so I haven't figured out yet how to get it to first of all *not* put the key I pressed on the document, but also it repeats the key I map it to too much (so the above example would output something like "FVVVVVVVVannnnnnnnnnnnlooooooooooccccccccccollllllllllllllllllllllnaaaaaaaaaaaVFFFFFFFFFFFFFFFF ") I'll be trying out ideas, but any suggestions would be really helpful. Thanks in advance!
falconv Posted October 13, 2005 Author Posted October 13, 2005 Okay, I've figured out how to keep it from repeatingCase _IsPressed("46") ;F key Send("V") Do Sleep(100) Until _IsPressed("46") = 0But I still can't figure out how to prevent it from typing the F. Is there any way to do this without HotKeySet??
TK_Incorperate Posted October 13, 2005 Posted October 13, 2005 Okay, I've figured out how to keep it from repeatingCase _IsPressed("46") ;F key Send("V") Do Sleep(100) Until _IsPressed("46") = 0But I still can't figure out how to prevent it from typing the F. Is there any way to do this without HotKeySet??try this....Case _IsPressed("46") ;F key Send("{DEL}V") Do Sleep(100) Until _IsPressed("46") = 0it should delete the last thing you typed (witch would be F) and even tho it's a kinda sucky fix, it should work until you figure out how to do it the real way.... depending on if F gets typed before or after the V, you might hafta change the location of the {DEL} or possibly even set a sleep for 100 and then add a new line for Send("{DEL}")..... of course thats only if the F gets typed AFTER the V lol, anyways im sorry i cant be of more help
falconv Posted October 13, 2005 Author Posted October 13, 2005 (edited) Hey, I appreciate the effort! I did actually just come up with a way to keep my HotKeySet()s, I'll show you below, but it's still coming up with the "Recursion level has been exceeded - AutoIt will quit to prevent stack overflow." (as reported by SciTE), so I'm thinking I might use a hybrid. Here's how I'm getting around the HotKeySet limit:While 1 Switch _IsPressed("A0") OR _IsPressed("A1") Case 1 HotKeySet("F", "KeyPressed_uprF") Case 0 HotKeySet("f", "KeyPressed_lwrf") EndSwitch WEnd Func KeyPressed_uprF() Send("V") EndFunc Func KeyPressed_lwrF() Send("v") EndFuncSo this way, only 1/2 of the hotkeys I need are active at a time, and it switches to the other set of hotkeys when I'm holding down shift. So if I want to do a capital F, it unsets the lowercase hotkeys and sets the uppercase hotkeys. I'm trying to figure out how to prevent the stack overflow so I can see if this works. Edit: I forgot to explain what I meant by "hybrid", I was thinking of trying to figure out a way to switch between the hotkeysets, but still use _IsPressed instead of functions. But I'm beginning to wonder if that'd just be more of a mess. Edited October 13, 2005 by falconv
seandisanti Posted October 13, 2005 Posted October 13, 2005 Hey, I appreciate the effort!I did actually just come up with a way to keep my HotKeySet()s, I'll show you below, but it's still coming up with the "Recursion level has been exceeded - AutoIt will quit to prevent stack overflow." (as reported by SciTE), so I'm thinking I might use a hybrid. Here's how I'm getting around the HotKeySet limit:While 1 Switch _IsPressed("A0") OR _IsPressed("A1") Case 1 HotKeySet("F", "KeyPressed_uprF") Case 0 HotKeySet("f", "KeyPressed_lwrf") EndSwitch WEnd Func KeyPressed_uprF() Send("V") EndFunc Func KeyPressed_lwrF() Send("v") EndFuncSo this way, only 1/2 of the hotkeys I need are active at a time, and it switches to the other set of hotkeys when I'm holding down shift. So if I want to do a capital F, it unsets the lowercase hotkeys and sets the uppercase hotkeys. I'm trying to figure out how to prevent the stack overflow so I can see if this works.Edit: I forgot to explain what I meant by "hybrid", I was thinking of trying to figure out a way to switch between the hotkeysets, but still use _IsPressed instead of functions. But I'm beginning to wonder if that'd just be more of a mess.here's a little code i got from this forum (sorry i can't find the post again to credit the original writer) and modified. it used to take key inputs and output "i'm an idiot" or something, mine is one that i use for work, i have it setup to run when the computer starts, and whatever you type it says "i'm using sean's computer without his permission" pause is currently setup to be an exit keyexpandcollapse popup;this is a script that changes all entered text to new text #include <GUIConstants.au3> Global $Count = 1 opt("TrayIconHide",1) $InputBox = "I AM USING SEAN'S COMPUTER WITHOUT HIS PERMISSION" If @Error Then Exit $SenLen = StringLen($InputBox) $SplitSen = StringSplit($InputBox,"") SetOn() HotKeySet("{PAUSE}", "Togglepause") #region - KEYS While 1 Sleep(20) $msg = GUIGetmsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Func _a() HotKeySet ( "a") _write() HotKeySet ( "a" , "_a" ) EndFunc Func _a1() HotKeySet ( "+a") _Write() HotKeySet ( "+a" , "_a1" ) EndFunc Func _b() HotKeySet ( "b") _Write() HotKeySet ( "b" , "_b" ) EndFunc Func _b1() HotKeySet ( "+b") _Write() HotKeySet ( "+b" , "_b1" ) EndFunc Func _c() HotKeySet ( "c") _Write() HotKeySet ( "c" , "_c" ) EndFunc Func _c1() HotKeySet ( "+c") _Write() HotKeySet ( "+c" , "_c1" ) EndFunc Func _d() HotKeySet ( "d") _Write() HotKeySet ( "d" , "_d" ) EndFunc Func _d1() HotKeySet ( "+d") _Write() HotKeySet ( "+d" , "_d1" ) EndFunc Func _e() HotKeySet ( "e") _Write() HotKeySet ( "e" , "_e" ) EndFunc Func _e1() HotKeySet ( "+e") _Write() HotKeySet ( "+e" , "_e1" ) EndFunc Func _f() HotKeySet ( "f") _Write() HotKeySet ( "f" , "_f" ) EndFunc Func _f1() HotKeySet ( "+f") _Write() HotKeySet ( "+f" , "_f1" ) EndFunc Func _g() HotKeySet ( "g") _Write() HotKeySet ( "g" , "_g" ) EndFunc Func _g1() HotKeySet ( "+g") _Write() HotKeySet ( "+g" , "_g1" ) EndFunc Func _h() HotKeySet ( "h") _Write() HotKeySet ( "h" , "_h" ) EndFunc Func _h1() HotKeySet ( "+h") _Write() HotKeySet ( "+h" , "_h1" ) EndFunc Func _i() HotKeySet ( "i") _Write() HotKeySet ( "i" , "_i" ) EndFunc Func _i1() HotKeySet ( "+i") _Write() HotKeySet ( "+i" , "_i1" ) EndFunc Func _j() HotKeySet ( "j") _Write() HotKeySet ( "j" , "_j" ) EndFunc Func _j1() HotKeySet ( "+j") _Write() HotKeySet ( "+j" , "_j1" ) EndFunc Func _k() HotKeySet ( "k") _Write() HotKeySet ( "k" , "_k" ) EndFunc Func _k1() HotKeySet ( "+k") _Write() HotKeySet ( "+k" , "_k1" ) EndFunc Func _l() HotKeySet ( "l") _Write() HotKeySet ( "l" , "_l" ) EndFunc Func _l1() HotKeySet ( "+l") _Write() HotKeySet ( "+l" , "_l1" ) EndFunc Func _m() HotKeySet ( "m") _Write() HotKeySet ( "m" , "_m" ) EndFunc Func _m1() HotKeySet ( "+m") _Write() HotKeySet ( "+m" , "_m1" ) EndFunc Func _n() HotKeySet ( "n") _Write() HotKeySet ( "n" , "_n" ) EndFunc Func _n1() HotKeySet ( "+n") _Write() HotKeySet ( "+n" , "_n1" ) EndFunc Func _o() HotKeySet ( "o") _Write() HotKeySet ( "o" , "_o" ) EndFunc Func _o1() HotKeySet ( "+o") _Write() HotKeySet ( "+o" , "_o1" ) EndFunc Func _p() HotKeySet ( "p") _Write() HotKeySet ( "p" , "_p" ) EndFunc Func _p1() HotKeySet ( "+p") _Write() HotKeySet ( "+p" , "_p1" ) EndFunc Func _q() HotKeySet ( "q") _Write() HotKeySet ( "q" , "_q" ) EndFunc Func _q1() HotKeySet ( "+q") _Write() HotKeySet ( "+q" , "_q1" ) EndFunc Func _r() HotKeySet ( "r") _Write() HotKeySet ( "r" , "_r" ) EndFunc Func _r1() HotKeySet ( "+r") _Write() HotKeySet ( "+r" , "_r1" ) EndFunc Func _s() HotKeySet ( "s") _Write() HotKeySet ( "s" , "_s" ) EndFunc Func _s1() HotKeySet ( "+s") _Write() HotKeySet ( "+s" , "_s1" ) EndFunc Func _t() HotKeySet ( "t") _Write() HotKeySet ( "t" , "_t" ) EndFunc Func _t1() HotKeySet ( "+t") _Write() HotKeySet ( "+t" , "_t1" ) EndFunc Func _u() HotKeySet ( "u") _Write() HotKeySet ( "u" , "_u" ) EndFunc Func _u1() HotKeySet ( "+u") _Write() HotKeySet ( "+u" , "_u1" ) EndFunc Func _v() HotKeySet ( "v") _Write() HotKeySet ( "v" , "_v" ) EndFunc Func _v1() HotKeySet ( "+v") _Write() HotKeySet ( "+v" , "_v1" ) EndFunc Func _w() HotKeySet ( "w") _Write() HotKeySet ( "w" , "_w" ) EndFunc Func _w1() HotKeySet ( "+w") _Write() HotKeySet ( "+w" , "_w1" ) EndFunc Func _x() HotKeySet ( "x") _Write() HotKeySet ( "x" , "_x" ) EndFunc Func _x1() HotKeySet ( "+x") _Write() HotKeySet ( "+x" , "_x1" ) EndFunc Func _y() HotKeySet ( "y") _Write() HotKeySet ( "y" , "_y" ) EndFunc Func _y1() HotKeySet ( "+y") _Write() HotKeySet ( "+y" , "_y1" ) EndFunc Func _z() HotKeySet ( "z") _Write() HotKeySet ( "z" , "_z" ) EndFunc Func _z1() HotKeySet ( "+z") _Write() HotKeySet ( "+z" , "_z1" ) EndFunc Func _aa() HotKeySet ( "æ") _Write() HotKeySet ( "æ" , "_aa" ) EndFunc Func _aa1() HotKeySet ( "+æ") _Write() HotKeySet ( "+æ" , "_aa1" ) EndFunc Func _bb() HotKeySet ( "ø") _Write() HotKeySet ( "ø" , "_bb" ) EndFunc Func _bb1() HotKeySet ( "+ø") _Write() HotKeySet ( "+ø" , "_bb1" ) EndFunc Func _cc() HotKeySet ( "å") _Write() HotKeySet ( "å" , "_cc" ) EndFunc Func _cc1() HotKeySet ( "+å") _Write() HotKeySet ( "+å" , "_cc1" ) EndFunc Func _Space() HotKeySet ( "{SPACE}") _Write() HotKeySet ( "{SPACE}" , "_Space" ) EndFunc Func _Enter() HotKeySet ( "{ENTER}") _Write() HotKeySet ( "{ENTER}" , "_Enter" ) EndFunc Func _Backspace() HotKeySet ( "{BACKSPACE}") _Write() HotKeySet ( "{BACKSPACE}" , "_backspace" ) EndFunc Func _Del() HotKeySet ( "{DEL}") _Write() HotKeySet ( "{DEL}" , "_Del" ) EndFunc Func _Dot() HotKeySet ( ".") _Write() HotKeySet ( "." , "_Dot" ) EndFunc Func _Comma() HotKeySet ( ",") _Write() HotKeySet ( "," , "_Comma" ) EndFunc #endregion Func Togglepause() Exit EndFunc ;~ Func _Streg() ;~ HotKeySet ( "-") ;~ _Write() ;~ HotKeySet ( "-" , "_Streg" ) ;~ EndFunc Func _Write() If $Count-1 = $SenLen Then Global $Count = 0 SetOff() Send(" ") SetOn() $Count = $Count + 1 Else SetOff() Send($SplitSen[$Count]) SetOn() $Count = $Count + 1 EndIf EndFunc Func SetOff() BlockInput(1) HotKeySet ( "a") HotKeySet ( "+a") HotKeySet ( "b") HotKeySet ( "+b") HotKeySet ( "c") HotKeySet ( "+c") HotKeySet ( "d") HotKeySet ( "+d") HotKeySet ( "e") HotKeySet ( "+e") HotKeySet ( "f") HotKeySet ( "+f") HotKeySet ( "g") HotKeySet ( "+g") HotKeySet ( "h") HotKeySet ( "+h") HotKeySet ( "i") HotKeySet ( "+i") HotKeySet ( "j") HotKeySet ( "+j") HotKeySet ( "k") HotKeySet ( "+k") HotKeySet ( "l") HotKeySet ( "+l") HotKeySet ( "m") HotKeySet ( "+m") HotKeySet ( "n") HotKeySet ( "+n") HotKeySet ( "o") HotKeySet ( "+o") HotKeySet ( "p") HotKeySet ( "+p") HotKeySet ( "q") HotKeySet ( "+q") HotKeySet ( "r") HotKeySet ( "+r") HotKeySet ( "s") HotKeySet ( "+s") HotKeySet ( "t") HotKeySet ( "+t") HotKeySet ( "u") HotKeySet ( "+u") HotKeySet ( "v") HotKeySet ( "w") HotKeySet ( "+w") HotKeySet ( "x") HotKeySet ( "+x") HotKeySet ( "y") HotKeySet ( "+y") HotKeySet ( "z") HotKeySet ( "+z") HotKeySet ( "æ") HotKeySet ( "+æ") HotKeySet ( "ø") HotKeySet ( "+ø") HotKeySet ( "å") HotKeySet ( "+å") HotKeySet ( "{SPACE}") HotKeySet ( "{ENTER}") HotKeySet ( "{BACKSPACE}") HotKeySet ( "{DEL}") HotKeySet ( "{BACKSPACE}") HotKeySet ( ".") HotKeySet ( ",") ;HotKeySet ( "-") EndFunc Func SetOn() HotKeySet ( "a" , "_a") HotKeySet ( "+a" , "_a1" ) HotKeySet ( "b" , "_b" ) HotKeySet ( "+b" , "_b1" ) HotKeySet ( "c" , "_c" ) HotKeySet ( "+c" , "_c1" ) HotKeySet ( "d" , "_d" ) HotKeySet ( "+d" , "_d1" ) HotKeySet ( "e" , "_e" ) HotKeySet ( "+e" , "_e1" ) HotKeySet ( "f" , "_f" ) HotKeySet ( "+f" , "_f1" ) HotKeySet ( "g" , "_g" ) HotKeySet ( "+g" , "_g1" ) HotKeySet ( "h" , "_h" ) HotKeySet ( "+h" , "_h1" ) HotKeySet ( "i" , "_i" ) HotKeySet ( "+i" , "_i1" ) HotKeySet ( "j" , "_j" ) HotKeySet ( "+j" , "_j1" ) HotKeySet ( "k" , "_k" ) HotKeySet ( "+k" , "_k1" ) HotKeySet ( "l" , "_l" ) HotKeySet ( "+l" , "_l1" ) HotKeySet ( "m" , "_m" ) HotKeySet ( "+m" , "_m1" ) HotKeySet ( "n" , "_n" ) HotKeySet ( "+n" , "_n1" ) HotKeySet ( "o" , "_o" ) HotKeySet ( "+o" , "_o1" ) HotKeySet ( "p" , "_p" ) HotKeySet ( "+p" , "_p1" ) HotKeySet ( "q" , "_q" ) HotKeySet ( "+q" , "_q1" ) HotKeySet ( "r" , "_r" ) HotKeySet ( "+r" , "_r1" ) HotKeySet ( "s" , "_s" ) HotKeySet ( "+s" , "_s1" ) HotKeySet ( "t" , "_t" ) HotKeySet ( "+t" , "_t1" ) HotKeySet ( "u" , "_u" ) HotKeySet ( "+u" , "_u1" ) HotKeySet ( "v" , "_v" ) HotKeySet ( "+v" , "_v1" ) HotKeySet ( "w" , "_w" ) HotKeySet ( "+w" , "_w1" ) HotKeySet ( "x" , "_x" ) HotKeySet ( "+x" , "_x1" ) HotKeySet ( "y" , "_y" ) HotKeySet ( "+y" , "_y1" ) HotKeySet ( "z" , "_z" ) HotKeySet ( "+z" , "_z1" ) HotKeySet ( "æ" , "_aa" ) HotKeySet ( "+æ" , "_aa1" ) HotKeySet ( "ø" , "_bb" ) HotKeySet ( "+ø" , "_bb1" ) HotKeySet ( "å" , "_cc" ) HotKeySet ( "+å" , "_cc1" ) HotKeySet ( "{SPACE}" , "_Space" ) HotKeySet ( "{ENTER}" , "_Enter" ) HotKeySet ( "{BACKSPACE}" , "_Backspace" ) HotKeySet ( "{DEL}" , "_Del" ) HotKeySet ( "{BACKSPACE}" , "_Backspace" ) HotKeySet ( "." , "_Dot" ) HotKeySet ( "," , "_comma" ) ;HotKeySet ( "-" , "_Streg" ) BlockInput(0) EndFunc
falconv Posted October 13, 2005 Author Posted October 13, 2005 Eureka!! I have figured out the Stack Overflow!! Thanks for the code, Cameronsdad! The Overflow was caused because whatever I pressed, the script would simulate another keypress that was mapped as a hotkey, so it caused an endless loop as soon as I pressed a key. For example, say Hotkey F is set to V, and V is set to F, then the Function for F is Send("V"), it sends V, but that triggers HotKey V which is set to Send("F"), and continues in an endless loop. Which is why it never gave an output when I pressed a key, and would end after a few seconds with the overflow. So now that I know that, I suppose I need to go into each function and unset the hotkey, send the key, and then reset the hotkey (like you have in the code above). Is there a faster, more efficient way of doing this? I'll make up an example of my idea below to give you a visual to work with. Thanks in advance! expandcollapse popup#include <Misc.au3> HotKeySet("{Esc}", "_Terminate") While 1 Switch _IsPressed("A0") OR _IsPressed("A1") Case 1 HotKeySet("a") HotKeySet("l") HotKeySet("c") HotKeySet("o") HotKeySet("n") HotKeySet("+f", "_F") ;note, I only did the letters I want to. In the actual script, I'd have all keys mapped. HotKeySet("+v", "_V") Case 0 HotKeySet("+f") HotKeySet("+v") HotKeySet("a", "_a") HotKeySet("l", "_l") HotKeySet("c", "_c") HotKeySet("o", "_o") HotKeySet("n", "_n") EndSwitch WEnd Func _F() HotKeySet("+v") Send("+v") HotKeySet("+v", "_V") EndFunc Func _a() HotKeySet("n") Send("n") HotKeySet("n", "_n") EndFunc Func _l() HotKeySet("o") Send("o") HotKeySet("o", "_o") EndFunc Func _c() HotKeySet("c") Send("c") HotKeySet("c", "_c") EndFunc Func _o() HotKeySet("l") Send("l") HotKeySet("l", "_l") EndFunc Func _n() HotKeySet("a") Send("a") HotKeySet("a", "_a") EndFunc Func _V() HotKeySet("+f") Send("+f") HotKeySet("+f", "_F") EndFunc Func _Terminate() Exit EndFunc
jefhal Posted October 13, 2005 Posted October 13, 2005 Is there a faster, more efficient way of doing this?This is OTTOMH, but could you use the ASCII equivalent number for each letter to build a loop using numeric values rather than all 26 letters? Not sure how to do this (tired), but For $i = 1 to 26: func$i() = blah blah and so on... Tell me I'm clueless, please... ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
falconv Posted October 13, 2005 Author Posted October 13, 2005 (edited) rofl!! I came to reply, and a bunch of garbage started spewing across the edit box before I realized I forgot to turn off the script XP anyway, that's a great idea! I will give it a shot and tell you if you're clueless or not Thanks Edit: It didn't work. I could be wrong, but I'm pretty sure you can't run a For...Next loop on creating Functions. If you can get one to work let me know and tell me how you did it. Here's what I tried:HotKeySet("{Esc}", "_Terminate") HotKeySet("a", "KeyPressed1") HotKeySet("b", "KeyPressed2") ; blah blah blah, the actual script had the rest, but I didn't want you to have to scroll through it all. HotKeySet("y", "KeyPressed25") HotKeySet("z", "KeyPressed26") While 1 WEnd For $n = 1 to 26 Step 1 Func KeyPressed$n() MsgBox(0,"Test","Pressed key: " & $n) EndFunc Next Func _Terminate() Exit EndFunc Edited October 13, 2005 by falconv
falconv Posted October 14, 2005 Author Posted October 14, 2005 I'm excited, this is coming along quite nicely. I have, however, run into another problem, and I'm not sure that this one can be solved, but just in case someone here has an idea here's what's wrong: When I am holding down shift, my script will Send() another character besides what's being pressed. The problem is that Shift is being held down still, so being a modifier, it modifies the Send() as well, so if I haveFunc KeyPressed_uprA() HotKeySet("v") Send("v") HotKeySet("v", "KeyPressed_lwrV") EndFuncalthough I tell it to send a lowercase v, because shift is being held down still, it ends up being a capital V. I read the readme, and it says Shift can't be set as a hotkey, so is there any other way to block it? or will I have to block all input from the keyboard for the split second it's sending the character? I'll give it a try, any input's still appreciated, and thanks for the input given so far.
falconv Posted October 15, 2005 Author Posted October 15, 2005 Worked on it all day (well, in between my running all over the place, it was a hectic day), and it looks like AutoIt can't do it natively, so I was looking into two alternatives: either 1. call an AutoHotKey script (similar to AutoIt, or so it claims), but I haven't been able to get it to completely work. or 2. use DllCall to tell the computer ShiftUp while sending, then go back to normal when returning to the script. But I'm not very experienced with DllCall yet, any pointers? I've tried to read through M$'s documentation, but I just get lost in it and feel helpless. A nudge in the right direction might (hopefully) help. Thanks again.
theguy0000 Posted October 15, 2005 Posted October 15, 2005 cameronsdad - i - and most of the other members, i would think - would appeeciate it if you post code that long as an attachment The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now