Jump to content


Weird Yet Simple Problem


  • Please log in to reply
8 replies to this topic

#1 Tahki

Tahki
  • Guests

Posted 15 April 2012 - 12:23 AM

Why is it that when I run a script with like 1::8, sometimes it will type both 1 and 8.
For example, sometimes it works fine, I press 1, and 8 appears. Other times I press 1, and 18 appears.

I tried researching this but it seems I failed, I apologize if it's really obvious.
Thanks for any help. :)

#2 Zeereen

Zeereen
  • Members
  • 29 posts

Posted 15 April 2012 - 12:53 AM

1::
keywait, 1 ;Waits for key "1" to be released/unpressed.
send 8 ; Sends/presses key "8"
return ; Tells AHK that this is finished, no more commands to be sent unless you press "1" again.


Edited:

Or simpler...

*1::8 ;The "*" tells ahk to send "8" after the "1" key is released.

Why didn't I think of this simpler way earlier. :roll: :lol:

#3 Guests

  • Guests

Posted 15 April 2012 - 10:06 AM

Working great so far, thank you very much. :D

#4 Tahki

Tahki
  • Guests

Posted 16 April 2012 - 05:56 PM

Turns out this didn't work out over time, it seems alt-tabbing and typing in different places(browser, chat clients, in games, etc) gives me the same issue again.

I'd rather it actually not be when the key is released since that will also slow down response times, just would appreciate a simple key remapped to another.

Is there any way to fix the issue? Thanks again.

#5 Ohnitiel

Ohnitiel
  • Members
  • 664 posts

Posted 16 April 2012 - 06:16 PM

I tested it and no such event happens with me, the only time that it happened was when i pressed one before the script was opened. lol

#6 Er0ck

Er0ck
  • Members
  • 18 posts

Posted 16 April 2012 - 06:31 PM

*1::8 ;The "*" tells ahk to send "8" after the "1" key is released.

i think that is untrue
*#c means Win+C, Shift+Win+C, Ctrl+Win+C, etc. will all trigger this hotkey because the "*" operates as a wildcard so you most likely never effected the problem with a "*"
i believe there is a simple fix. first if i were u i'd try:
#InstallKeybdHook 
SendMode Event 
#UseHook
then i'd try:
Hotkey, 1, Label1
return

Label1:
sendinput 8
return
one other quick fix off the top of my head:
if you could use a firing key that didnt effect what you were doing if it wasn't blocked by the script.
i dont know what u r doing but if u were sending 8 by pressing f12 there would be no draw back to your script mistakenly firing both

also reading from the ahk help i found:
Remapping via the Registry's "Scancode Map"
Advantages:

Registry remapping is generally more pure and effective than AutoHotkey's remapping. For example, it works in a broader variety of games, it has no known alt-tab issues, and it is capable of firing AutoHotkey's hook hotkeys (whereas AutoHotkey's remapping requires a workaround).
If you choose to make the registry entries manually (explained below), absolutely no external software is needed to remap your keyboard. Even if you use KeyTweak to make the registry entries for you, KeyTweak does not need to stay running all the time (unlike AutoHotkey).
Disadvantages:

Registry remapping is relatively permanent: a reboot is required to undo the changes or put new ones into effect.
Its effect is global: it cannot create remappings specific to a particular user, application, or locale.
It cannot send keystrokes that are modified by Shift, Control, Alt, or AltGr. For example, it cannot remap a lowercase character to an uppercase one.
It is not supported on Windows 95/98/Me (AutoHotkey can do some limited Win9x remapping).
It supports only the keyboard (AutoHotkey has mouse remapping and some limited joystick remapping).
How to Apply Changes to the Registry: There are at least two methods to remap keys via the registry:

Use a program like KeyTweak (freeware) to visually remap your keys. It will change the registry for you.
Remap keys manually by creating a .reg file (plain text) and loading it into the registry. This is demonstrated at <!-- m -->http://www.autohotke...6216.html#56216<!-- m -->

ill check back to see if i can be of any help

#7 Tahki

Tahki
  • Guests

Posted 16 April 2012 - 07:32 PM

For clarification, a game has a main actionbar that I cannot remap, so I'm using AHK to remap those buttons. E.g. 1-0 are the keybinds for the actionbar in game, so I remap my t button to give 1, g to 2, etc., making my own keybinds.

The simple code I had was:
F8::Suspend
#IfWinActive ahk_class RAPTURE
t::1
g::2
v::3
q::4
e::5
z::6
c::7
1::8
2::9
3::0

That workaround looks very sound, I'll try it out and post back if any issues - thank you lots for the quick help and replies again. ^^

#8 Tahki

Tahki
  • Guests

Posted 19 April 2012 - 07:27 AM

Sigh, still no use. Wish I knew why this was so complicated. >.<

It's only for the game, so remapping through registry isn't an option - guess I'll just keep reloading the script when I get errors, at least that works for now..

Thanks a lot for all the help, just really curious as to why all the trouble for a simple remap, I suppose it'll forever bug me.

#9 Er0ck

Er0ck
  • Members
  • 18 posts

Posted 30 May 2012 - 04:34 PM

Sigh, still no use. Wish I knew why this was so complicated. >.<

It's only for the game, so remapping through registry isn't an option - guess I'll just keep reloading the script when I get errors, at least that works for now..

Thanks a lot for all the help, just really curious as to why all the trouble for a simple remap, I suppose it'll forever bug me.

First i wanna say that the fact that its for a game in no way precludes remapping through registry.
To answer why so difficult; In my opinion its most often with games that you find complications for a number of reasons including...
Some games use DirectInput exclusively. As a side-effect, they might ignore all simulated keystrokes and mouse clicks.
There is always a way around any block, they are really just preventative measures (In the end my input could come from a device emulating a kybrd to guess passwords or whatev). In other words if a particular software had security concerns surrounding macros, then preventing them wouldn't cut it. But if the concern is fairness in a game, prevention is good enough.
Also i'm pretty sure AutoHotkey is mainly used for saving time assisting user's control in nongamming scenarios- just happens to be pretty handy for that... sometimes