 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
savage
Joined: 02 Jul 2004 Posts: 206
|
Posted: Fri Aug 13, 2004 10:14 pm Post subject: Input Proxy |
|
|
Coasting on the wave of motivation that resulted from my little translation doohicky, when I got back from work I sat down and finally polished off a script I've been using for a while, though I'm not sure if it will be all that useful for anyone .
I run a dual monitor rig, and I play games. I almost always have a console window open on one monitor while I'm playing. Unfortunately, to get to this thing that I can see right in front of me, I have to minimize the game. As you may know, most 3d games don't like to be minimized, so I wrote this script to allow me to type into the console window from within games (or anything for that matter). After some refining it now echos character by character, rather than line by line, and you can backspace. Basically hit the key, do your thing, than hit escape to jump out of the proxy. Sexy.
The only problem is that shift is reaaaally dodgy, and rarely works. I'd like a little help on getting that to work, if anyone can offer some insight.
| Code: |
!#C::
SetTitleMatchMode, 2
SetKeyDelay, 1
title = cmd.exe
ControlSend, ahk_parent ,echo "Input Proxy Enabled."{Enter}, %title%
loop
{
Input, UserInput, B L1,{enter}{esc}{backspace}
endkey=%errorlevel%
ifequal,endkey, Endkey:Escape, break
ControlSend, ahk_parent ,%userinput%, %title%
ifequal,endkey, Endkey:Enter, ControlSend, ahk_parent ,{Enter}, %title%
ifequal,endkey, Endkey:backspace, ControlSend, ahk_parent ,{bs}, %title%
}
ControlSend, ahk_parent ,echo "Input Proxy Disabled."{Enter}, %title%
return
|
You might need to change the title variable to make it work. I typically am using Console or 4nt, so I use one of those.
Last edited by savage on Sun Aug 15, 2004 5:13 pm; edited 1 time in total |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Sat Aug 14, 2004 2:29 pm Post subject: |
|
|
| Quote: | | The only problem is that shift is reaaaally dodgy, and rarely works. |
Although that doesn't surprise me given the history of ControlSend, I have trouble actually reproducing the problem on my XP system. Maybe you can give this short test script a try.
| Code: | Sleep, 500 ; Give time for user to release keyboard.
SetTitleMatchMode, 2
IfWinNotExist, cmd.exe
{
Run, %comspec% /k
WinWait, cmd.exe
}
WinActivate ; uses the "last found" window
Send, !{tab} ; Switch away from the window for testing purposes.
Sleep, 200
SetKeyDelay, 0
ControlSend, ahk_parent, UPPERCASE lowercase UPPERCASE
Sleep, 200
WinActivate ; show the window to see the result |
Maybe the shift key fails to work only on certain operating systems or under certain conditions. It might also be sensitive to the value of SetKeyDelay. |
|
| Back to top |
|
 |
savage
Joined: 02 Jul 2004 Posts: 206
|
Posted: Sat Aug 14, 2004 4:40 pm Post subject: |
|
|
That test script worked fine. I think the problem is Input not picking up the shift key correctly the way I have the loop set up.
On second thought, if I turn on capslock, then start the proxy and hold down a key, it shows up some caps, some not like so: OOOOOoooOOooOOooOO |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Sun Aug 15, 2004 12:53 am Post subject: |
|
|
I tried your proxy script on my system and couldn't get it to produce unexpected capitalization regardless of the combination of shifted or unshifted keys I typed. Still, it doesn't surprise me that ControlSend fails to reliably reproduce the shift state -- perhaps especially when sending to the command prompt -- since others on the AutoIt forum have mentioned similar behavior.
I did notice that the Input command does not allow you to change the state of Capslock (and probably other such keys) during an invisible input, which is probably something that should be changed.
| Quote: | | I think the problem is Input not picking up the shift key correctly |
That would be interesting if true, so if you find more evidence of this, please let me know.
Also, I noticed in your script that in this one line, you refer to the window as Console rather than %title%. Maybe that's intentional:
ControlSend, ahk_parent ,%userinput%, Console
Finally, have you tried altering the value of KeyDelay to see if that helps? |
|
| Back to top |
|
 |
savage
Joined: 02 Jul 2004 Posts: 206
|
Posted: Sun Aug 15, 2004 5:15 pm Post subject: |
|
|
| Quote: | | Also, I noticed in your script that in this one line, you refer to the window as Console rather than %title%. |
Oops, missed one.
| Quote: | | Finally, have you tried altering the value of KeyDelay to see if that helps? |
Cool! I changed keydelay to 1 and everything seems to work perfectly! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|