 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
miscman
Joined: 25 Apr 2004 Posts: 13
|
Posted: Mon Apr 26, 2004 8:28 pm Post subject: |
|
|
| thank you |
|
| Back to top |
|
 |
miscman
Joined: 25 Apr 2004 Posts: 13
|
Posted: Wed Apr 28, 2004 12:50 am Post subject: |
|
|
/me lets out a triumphant cry
nice!!!
the mouse macros work!!! and text can be sent from the script into the game. Although im not sure how the heck i can get the script to read in keypresses. :-/
Good for now though... definatly good for now!! |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Wed Apr 28, 2004 12:55 am Post subject: |
|
|
That's good news. It was a longshot, since I figured any game that prevents hook hotkeys from working might also defeat mouse hotkeys.
If you get a chance, try using GetKeyState while the game is running to see if the state of keyboard keys can be reliably detected. If it can, a whole new set of possibilities opens up. For example, you could have a mouse hotkey perform a different action if you are holding down some keyboard key. |
|
| Back to top |
|
 |
miscman
Joined: 25 Apr 2004 Posts: 13
|
Posted: Wed Apr 28, 2004 1:05 am Post subject: |
|
|
yes that is a good idea. now that i think of it... there was mention about how the game makers went to great lengths to disable the windows key.... it caused toe game to minimize, thus terminating your connection. ( i would have prefered they just let us minimize it without killing the game, but who am i to complain... just a customer...)
So that may be why that isnt working... also.. the ctrl and alt keys have significance in the game as well... those also did not work... I will ry your idea, but i may need to look into how to get a low lvl hook in place.
BTW: launching the script from a timer causes me to lose connection to the game :( |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Wed Apr 28, 2004 1:33 am Post subject: |
|
|
| Quote: | | but i may need to look into how to get a low lvl hook in place. |
AHK already uses a low level hook (which is why it doesn't work on Win9x); I believe you already tried enabling it without success.
If GetKeyState works while in the game, you can create your own hotkeys by using a keyboard polling loop. Just as an example for a single key:
| Code: | Loop
{
; Get the logical state, not the physical, since we already
; know the hook's tracking of keys doesn't work in the game:
GetKeyState, state, ``
if state = U
{
Sleep, 10
continue
}
; Otherwise:
Gosub, AccentKeyAction ; Your action subroutine.
; Wait for the key to be released so that the action doesn't
; keep firing while the key is held down:
KeyUp = ``
Gosub, WaitForKeyUp
}
return
WaitForKeyUp:
Loop
{
GetKeyState, down_or_up, %KeyUp%
if down_or_up = U
return
Sleep, 10
}
return |
|
|
| Back to top |
|
 |
miscman
Joined: 25 Apr 2004 Posts: 13
|
Posted: Wed Apr 28, 2004 1:49 am Post subject: |
|
|
| and this polling loop doesnt hose the cpu? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Wed Apr 28, 2004 2:11 am Post subject: |
|
|
Since you're only checking one key, it should use a miniscule amount of CPU time. This is because of the "Sleep 10", which probably rests the CPU for about a million times longer than the body of the loop takes to execute.
Even checking a lot of keys would probably be very low overhead, but I have yet to confirm that. One of my ideas to implement "string hotkeys" is to using a polling loop in the program. The reason for this is that it will work on Win9x (and on XP/2k it avoids the use of the hook). However, if I discover that polling all keys every 10ms is a high overhead operation, I will definitely not do it that way.
Also, I'm not thrilled about the polling method for general use by the program because it feels unreliable. For example, if the system is under heavy load, the polling might not be able to check the keys at the desired frequency, and thus it might "miss" some keypresses. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sun May 02, 2004 2:38 pm Post subject: |
|
|
Here is my tentative design for what Rajat calls "string hotkeys". It's based on miscman's idea as well as the ideas of Jay D. Novak, Rajat, and others. Comments are welcome.
Input [, OutputVar , MaxLength, Timeout, Options, EndKeys, MatchList]
OutputVar: This receives the string that the user typed.
MaxLength: The input will be terminated when the user enters this number of characters.
Timeout: The input will be terminated after this amount of time.
EndKeys: A list of keys such as {Enter}{Esc}, any of which will terminate the input.
MatchList: A comma-separated list of key phrases, any of which will immediately terminate the input.
Options:
(V)isible: Whether the user's keystrokes are echoed back out to the system (normally they are hidden/suppressed).
(C)ase sensitive: affects MatchList and maybe also EndKeys.
(M)ouse button input is included in OutputVar (e.g. as {LButton} or {LButton down})
(E)ndKey is included in OutputVar if it's what terminated the input.
(B)ackspace is included in OutputVar (normally backspace performs its native undo function).
(S)pecial/invisible characters such as control-C, Escape, etc. are included in OutputVar as ^c, {Esc}, etc.
(H)otkeys are included in OutputVar (hook/registered hotkeys should normally be excluded?)
NOTES:
The hotkey used as the lead key for the above could be made pass-through to have it be a visible replace. For example:
~[:: ; The tilde makes it a pass-through (non-suppressed) hotkey.
Input, OutputVar, 5, 3000, V, , btw, ahk, otoh, afaik
if OutputVar = btw
Send, {backspace 4}by the way
return
Default timeout: somewhere around 3000
Have escape always be an EndKey unless overridden by an option?
If given no parameters, any in-progress Input (i.e. in an underlying thread) is terminated.
If another thread does an Input while there's already one in progress?
For flexibility, translate any keys pressed while others are still down as {firstkey down}abc{firstkey up} ... same for mouse buttons. Oops, I don't think this will work for keyboard keys because it is very common for people to press new keys (in the course of typing) while others are still down.
Hook gives precedence to a hotkey such as #z rather than including it in OutputVar?
Use actual newline char in lieu of {Enter}? Same for tab. But what about ESC, modifiers, home/end/pgup, arrows, etc? Maybe the best policy is to tranlate into a visible char whenever possible (e.g. newline) but otherwise just store it for possible use with the Send command, e.g. {HOME}.
Install hook dynamically (if needed) when the Input command is first encountered. |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1718
|
Posted: Sun May 02, 2004 7:34 pm Post subject: |
|
|
| Quote: | | Have escape always be an EndKey unless overridden by an option? |
may i suggest ESC to be he default cancel key (it cancels the 'string hotkeys' operation & makes visible the earlier keystrokes to system if hidden untill now)
ENTER the default endkey.
| Quote: | | If another thread does an Input while there's already one in progress? |
(if possible) let them both receive the input, only one of them will trigger the action, as the scriptor will be intelligent enough not to assign different actions to same hotkey and same 'string hotkey' !
| Quote: | | Maybe the best policy is to tranlate into a visible char whenever possible (e.g. newline) |
i don't think this hybrid method is a nice one... better stick to Send syntax only.
and btw instead of 'String HotKeys' u can call these 'HotStrings' (gels well with the word HotKeys!)
and Chris, this post should've been in thread u've started in the announcements section... here u should've put a link to it. i just chanced upon this important post! ... better move it there, so that more ppl see it. _________________
 |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sun May 02, 2004 8:37 pm Post subject: |
|
|
| Quote: | | may i suggest ESC to be he default cancel key and ENTER the default endkey. |
It doesn't seem necessary to differentiate between an "end" and a "cancel" key in light of the fact that there is an option to include the EndKey in the OutputVar.
| Quote: | | (it cancels the 'string hotkeys' operation & makes visible the earlier keystrokes to system if hidden untill now) |
That doesn't make sense to me because if the keys are set to be invisible, they should never be sent through under any circumstances. If they were set to be visible, they'd have already been sent through as the user types them.
| Quote: | | (if possible) let them both receive the input, only one of them will trigger the action, as the scriptor will be intelligent enough not to assign different actions to same hotkey and same 'string hotkey' ! |
I think it's most flexible to terminate the prior thread's input -- putting whatever's in the buffer into its OutputVar -- And then reset the buffer for the new input. That way, a user could end one input and begin another, all with the press of a single hotkey (two birds with one stone).
| Quote: | | i don't think this hybrid method is a nice one... better stick to Send syntax only. |
Maybe; I'll give it some thought.
| Quote: | | and btw instead of 'String HotKeys' u can call these 'HotStrings' (gels well with the word HotKeys!) |
At first I didn't see a need for a name since it's just a command. But maybe the name can be used in the Hotkeys section to refer to some of the things the command can do.
| Quote: | | and Chris, this post should've been in thread u've started in the announcements section... |
I'd prefer to leave it here since this is where the topic started. If this topic (or any other) interests you, you probably know that you can set it to notify you via e-mail when a new reply is posted. |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1718
|
Posted: Sun May 02, 2004 10:28 pm Post subject: |
|
|
| Quote: | | That doesn't make sense to me because if the keys are set to be invisible, they should never be sent through under any circumstances |
This was suggested to take care of the situation where one accidentally (or literally) pressed the hotkey and keystrokes (the ones that are part of hotstrings) start getting invisible ... then one can press ESC to get them back....
| Quote: | | I think it's most flexible to terminate the prior thread's input |
i feel that letting both threads have the keys is better coz this way the input command won't stop accidently... it'll stop only when the conditions set by user (maxlength / timeout etc.) are met.
| Quote: | | I'd prefer to leave it here since this is where the topic started. If this topic (or any other) interests you, you probably know that you can set it to notify you via e-mail when a new reply is posted. |
well this was kind of an 'announcement' of a future addition and its details, so i thought it'd better go to its proper place... ah well!
anyways... maybe i'll suggest less and wait more. _________________
 |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Mon May 03, 2004 12:38 am Post subject: |
|
|
| Thanks for the analysis, and for the "hotstrings" buzzword. It's rather catchy. |
|
| Back to top |
|
 |
miscman
Joined: 25 Apr 2004 Posts: 13
|
Posted: Thu May 20, 2004 9:05 am Post subject: |
|
|
Finals and a host of new and unexpected problems have prevented me from playing my games much.. and as a result i almost forgot about my request here. I gotta say i didnt expect you to have it working so soon.
Kudos to everyone who made this possible. I cannot wait to try it out :D |
|
| 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
|