Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

RapidHotkey()


  • Please log in to reply
101 replies to this topic
harryporter
  • Members
  • 9 posts
  • Last active: May 15 2010 09:51 AM
  • Joined: 07 May 2010
Here is a part of code. My question is how to make first label permanent without time delay.
I tryed both of Your examples but none work for me.
d::RapidHotkey ("keyd""keydd",,,1)
return
keyd: 
GetKeyState, state, CapsLock, T
{
If state=D 
Send, {U+0414}
else if state=U
Send, {U+0434}
}
return
keydd:
GetKeyState, state, CapsLock, T
{
If state=D 
Send, {U+0402}
else if state=U
Send, {U+0452}
}
Return
+d::RapidHotkey("key+d""key+dd", 1,, 1)
key+d:
Send, {U+0414}
return
key+dd:
Send, {U+0402}
Return


Onesimus Prime
  • Members
  • 10 posts
  • Last active: Jun 19 2010 01:39 PM
  • Joined: 18 May 2010
1) When doing non-character keys (like a double-tapped Alt), RapidHotkey still seems to backspace--thus erasing things that I don't want erased! Maybe check to see whether the multiple-tapped key actually produces a character or not?
2) In some programs (Windows Explorer and Internet Explorer at least), Backspace itself is a shortcut key. In Vista's Explorer, for example, backspace seems to toggle between going up a folder and returning to the original one. Maybe check for the window class and don't do Backspace at all in these types of programs?

Thanks for a helpful function!

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

Here is a part of code. My question is how to make first label permanent without time delay.
I tryed both of Your examples but none work for me.

d::RapidHotkey ("keyd""keydd",,,1)
return
keyd: 
GetKeyState, state, CapsLock, T
{
If state=D 
Send, {U+0414}
else if state=U
Send, {U+0434}
}
return
keydd:
GetKeyState, state, CapsLock, T
{
If state=D 
Send, {U+0402}
else if state=U
Send, {U+0452}
}
Return
+d::RapidHotkey("key+d""key+dd", 1,, 1)
key+d:
Send, {U+0414}
return
key+dd:
Send, {U+0402}
Return

What about this?
SendMode Input
d::
Send % GetKeyState("CapsLock", "T") ? "{U+0414}" : "{U+0434}"
RapidHotkey("keydd",2,0.15,1)
return
keydd:
Send % "{BackSpace}" . (GetKeyState("CapsLock", "T") ? "{U+0402}" : "{U+0452}")
Return

+d::
Send, {U+0414}
RapidHotkey("key+dd", 2,0.15, 1)
Return
key+dd:
Send, {BackSpace}{U+0402}
Return


HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

1) When doing non-character keys (like a double-tapped Alt), RapidHotkey still seems to backspace--thus erasing things that I don't want erased! Maybe check to see whether the multiple-tapped key actually produces a character or not?
2) In some programs (Windows Explorer and Internet Explorer at least), Backspace itself is a shortcut key. In Vista's Explorer, for example, backspace seems to toggle between going up a folder and returning to the original one. Maybe check for the window class and don't do Backspace at all in these types of programs?

Thanks for a helpful function!

The problem is that different applications have different functions for any key. For example you can have Enter assigned to OK button so it would not produce a character, same for Tab, in notepad or any other editor it is a character. I do not think there is a way to fix it globally.

In explorer Backspace is only a shortcut if you are not editing a file or address bar so you would need to check for this as well.
Try changing this lines to make it work for explorer
Loop % times
		backspace .= "{Backspace}"
to
ControlGetFocus,control,A
WinGetClass,class,A
If (class!="ExploreWClass" or !InStr(control,"Edit"))
	Loop % times
		backspace .= "{Backspace}"


Onesimus Prime
  • Members
  • 10 posts
  • Last active: Jun 19 2010 01:39 PM
  • Joined: 18 May 2010
Wow, that was quick! Thanks for your reply.

The code actually didn't seem to work. I used AU3_Spy.exe, which reported the Explorer window as being CabinetWClass - so I tried changing one line of yours to:
If (class!="ExploreWClass" or class!="CabinetWClass" or class!="IEFrame" or !InStr(control,"Edit")) 
Still no luck. Did I do something wrong?

About non-character keys: it still seems that there are keys that I've never seen produce a character (e.g. Alt, Ctrl, Shift, Win, Esc, the three "-lock" keys, etc.). Maybe it's more trouble than it's worth (I have no idea, I don't know what I'm doing in AHK!), but I'm not sure backspacing would ever make sense after these.

Thanks!

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

Wow, that was quick! Thanks for your reply.

The code actually didn't seem to work. I used AU3_Spy.exe, which reported the Explorer window as being CabinetWClass - so I tried changing one line of yours to:

If (class!="ExploreWClass" or class!="CabinetWClass" or class!="IEFrame" or !InStr(control,"Edit")) 
Still no luck. Did I do something wrong?

About non-character keys: it still seems that there are keys that I've never seen produce a character (e.g. Alt, Ctrl, Shift, Win, Esc, the three "-lock" keys, etc.). Maybe it's more trouble than it's worth (I have no idea, I don't know what I'm doing in AHK!), but I'm not sure backspacing would ever make sense after these.

Thanks!

Keys like Alt and Win, -lock and many others are already considered.

Try this
If ((class!="CabinetWClass" and class!="IEFrame") or InStr(control,"Edit"))


Onesimus Prime
  • Members
  • 10 posts
  • Last active: Jun 19 2010 01:39 PM
  • Joined: 18 May 2010
I just changed it to
If ((class!="CabinetWClass" and class!="ExploreWClass" and class!="IEFrame") or InStr(control,"Edit"))
I don't know what ExploreWClass is, but since it's in your original, I feel safer keeping it. :wink:

In your original, "InStr" had a ! before it, but not in your most recent--was that intentional?

Also, I was just able to re-confirm my double-Alt problem:
With the code
~Alt::RapidHotkey("{TAB}", 2, 0.2)
I open a new instance of notepad, type "new", double-tap Alt, and I'm left with only an "n" with a tab after it. Sure looks like it's backspacing twice...
Ctrl doesn't seem to have that problem (I have now switched them out). Looks like I just got unlucky on my first choice!

Thanks for your help!

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Thanks for testing, I have fixed Alt key.

! was my mistake.

So does it work for you now in Explorer and Internet Explorer?

Onesimus Prime
  • Members
  • 10 posts
  • Last active: Jun 19 2010 01:39 PM
  • Joined: 18 May 2010
It does seem to work, thank you. Were you saying that including or not including the ! was the mistake? I got a bit confused.
What does the InStr(control,"Edit") part do, anyway?

*edit - I spoke way too soon! The current version of RapidHotkey with the addition of the Windows/Internet Explorer exception doesn't work at all!

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
I have posted now the function I use in the first post.
It looks to work fine for me using this:
[color=red]ControlGetFocus,control,A
WinGetClass,class,A
If ((class!="CabinetWClass" and class!="ExploreWClass" and class!="IEFrame") or InStr(control,"Edit"))[/color]
	Loop % times
		backspace .= "{Backspace}"


Onesimus Prime
  • Members
  • 10 posts
  • Last active: Jun 19 2010 01:39 PM
  • Joined: 18 May 2010
Oops! :oops:
Don't know what I messed up before, but it is working now. Thanks for your patience.

Perhaps one more non-critical feature request that, again, I don't know how hard it would be to implement: right now I have something triggered by triple-hitting "e". I'm a fairly fast typist, so this is also unfortunately triggered by typing things such as the word "between"! If there's an intervening keypress (like the "tw" in "between"), could this "reset" the keypress count to help avoid false triggers?

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
That (between) should work now so invalid key will not trigger an action, just download the function in first post again ;)

Onesimus Prime
  • Members
  • 10 posts
  • Last active: Jun 19 2010 01:39 PM
  • Joined: 18 May 2010
It's certainly much better! Typing the word "whenever", for example, sometimes still triggers the triple-e hotkey, but only about one time out of every three. I'm using the following:
~e::RapidHotkey("#z""#r""#e",3, 0.2)

Shoobis
  • Members
  • 9 posts
  • Last active: Jun 05 2010 06:10 AM
  • Joined: 20 Sep 2006
Awesome script HotKeyIt thanks a lot for sharing it, this really can make my life better, just i'm having problems trying to use it with joystick buttons.

I've tried simple things like ..

~Joy7::RapidHotkey("#r""#e""#f")

or

Joy7::RapidHotkey("#r""#e""#f")

even "tried to patch" adding it to the list in this line of your script..

. "Browser_Search|Browser_Favorites|Browser_Home|Volume_Mute|Volume_Down|Volume_Up|MButton|RButton|LButton|[color=red]Joy7|[/color]"

But nothing happens, the joystick it's fine works great with AHK and i've tested your script with Lbutton and works.

What can i do to make the script recognize the joystick buttons?

Mayday
  • Guests
  • Last active:
  • Joined: --
they say your work is cool,,,
can you help me make a script that should work like this,
if i hold the F9 key,,, it will spam F9 lots of times,,, and when i release the hold it will stop spamming... and can repeat this many times...
and if possible to make it lower delay than 50ms or no delay at all...
thanks so much in advance

this is what ive only got...

#UseHook ;
F9::
keyPress:=analyseKeyPress("F9")
tooltip %F9%
if (keypress=1)
send {%a_F9%} ;
return
F9::
keyPress:=analyseKeyPress("F9")
tooltip %F9%
if (keypress=1)
send {%a_F9%}
return