I just finished converting an extensive non AHK macro script (contains 4 sub menus, 2 subsub menus and over 70 macros) into an AHK menu script that is now working flawlessly
I know that I can insert a SetKeyDelay line before a SEND line so that the keystroke output can be slowed down.
What I wonder is if I can execute something within this script that toggles the setkeydelay so that it will remain in effect for subsequent menu uses until it is toggled back.
fwiw, I am running into websites that restrict the rate that characters are typed into form fields so that pasting and macros cannot be used to fill in web form fields.
The two apparent options would be something to toggle the key delay globally until it is turned off OR have a menu selection that would toggle the delay on but the menu would stay in place for a subsequent macro selection.
Thanks in advance for any wisdom to meet this need.
Beverly Howard
SetKeyDelay in Menu?
- waetherman
- Posts: 112
- Joined: 05 Feb 2016, 17:00
Re: SetKeyDelay in Menu?
Do you mean something like this?
Hope this helps,
Marek Smoliński
Code: Select all
flag := true
#q::
if ( flag ) {
SetKeyDelay, 0, 0
} else {
SetKeyDelay, 100, 100
}
Send 0123456789
return
#Space::
flag := !flag
if ( flag ) {
Tooltip, Fast typing
} else {
Tooltip, Slow typing
}
Sleep, 2000
Tooltip
return
Marek Smoliński
Re: SetKeyDelay in Menu?
>> Do you mean something like this? <<
Exactly. But bear with me as I am a rank beginner with ahk and don't really understand the process flow.
Your example makes sense and works. However, In this menu script I have over 70 send routines, so, my question is if there is a way to SetKeyDelay before a selection is made or do I have to add the command above every SEND command line?
Also, your example makes the toggle depending on the hotkey used to trigger the script. Is that the best way to do it rather than adding a menu selection to toggle the state?
Thanks again, and thanks in advance,
Beverly Howard
Exactly. But bear with me as I am a rank beginner with ahk and don't really understand the process flow.
Your example makes sense and works. However, In this menu script I have over 70 send routines, so, my question is if there is a way to SetKeyDelay before a selection is made or do I have to add the command above every SEND command line?
Also, your example makes the toggle depending on the hotkey used to trigger the script. Is that the best way to do it rather than adding a menu selection to toggle the state?
Thanks again, and thanks in advance,
Beverly Howard
Re: SetKeyDelay in Menu?
This help file info seems to relate to my need;
>> The built-in variable A_KeyDelay contains the current setting of Delay for Send/SendEvent mode. [v1.1.23+]: A_KeyDuration contains the setting for PressDuration, while A_KeyDelayPlay and A_KeyDurationPlay contain the settings for SendPlay <<
Can "built-in variable" values be changed within a script or are they for reference only?
Beverly Howard
>> The built-in variable A_KeyDelay contains the current setting of Delay for Send/SendEvent mode. [v1.1.23+]: A_KeyDuration contains the setting for PressDuration, while A_KeyDelayPlay and A_KeyDurationPlay contain the settings for SendPlay <<
Can "built-in variable" values be changed within a script or are they for reference only?
Beverly Howard
- waetherman
- Posts: 112
- Joined: 05 Feb 2016, 17:00
Re: SetKeyDelay in Menu?
SetKeyDelay
I couldn't find how to change the default outside of the auto-execute section. I guess it can't be done. Some hacky method could accomplish that, for example saving desired state (like the desired key delay and maybe something else) into a file, restarting the script and loading the state from the file. It's probably easier and better to just auto replace every "::\n" with "::\nSetKeyDelay, %keyDelay%, %pressDuration%\n".Every newly launched thread (such as a hotkey, custom menu item, or timed subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).
- waetherman
- Posts: 112
- Joined: 05 Feb 2016, 17:00
Re: SetKeyDelay in Menu?
Code: Select all
;======= above goes autoexecute part of your script
flag = %1% ;first parameter
paramNum = %0%
if ( !flag ) {
if ( paramNum ) { ;at least one parameter was passed, so the flag was just switched
Tooltip, Fast typing
}
SetKeyDelay, 0, 0
} else {
Tooltip, Slow typing
SetKeyDelay, 200, 200
}
Sleep, 2000
Tooltip
#Space::
flag := !flag
Run "%A_AhkPath%" /r "%A_ScriptFullPath%" %flag%
return
;=============== below go your hotkeys
#q::
Send 0123456789
return
Take care,
Marek Smolinski
Re: SetKeyDelay in Menu?
>> You asked about hotkeys vs Menu - I noticed you like the menu, I don't use it at all, but I guess it depends on one's preference. <<
When you pass a certain number of keyboard macros that you use every day, then many others that you use several times a week, hotkeys become hard to manage as well as hard to remember whereas in a menu they are fast and the hotkeys are visible when learning new entries.
In another thread here I mentioned that during my ahk learning process that there was no documentation about creating hotkeys _within_ ahk menus... i.e. underlining letters in menu selections so that they execute with a single keypress. So, the most used macros need two keypresses, the menu trigger and the menu item trigger. Less used macros put in submenus take one more keypress per submenu item... fast, very fast.
The good news, is that when I tried the same syntax for the ahk menu labels, it works! ...just put an asterisk "&" in front of the label letter anywhere in the label you want to use as a trigger... i.e. "Rebe&ka" to trigger "Rebeka" As long as that labeled letter is a unique within any one menu, it will trigger the label by simply pressing that key.
There is also a new factor at play... windows based tablets when used without hardware keyboards. The windows tablet osk has neither an <alt> nor <win> key, so, there are almost no available <ctrl> keys for ahk use.
I just purchased a lenovo Miix700 as a replacement for my 2006 fujitsu laptop and quickly found that win10 and especially it's tablet mode finally defeated the menu based macro program I have been using for a decade, so, it was time to pull out ahk and start stirring up the grey cells by learning a new language... it's been a fun and productive few days, ...but, my brain hurts
Thanks for the response. Your posts have given me some additional ideas to test. I will experiment and report my findings.
Beverly Howard
When you pass a certain number of keyboard macros that you use every day, then many others that you use several times a week, hotkeys become hard to manage as well as hard to remember whereas in a menu they are fast and the hotkeys are visible when learning new entries.
In another thread here I mentioned that during my ahk learning process that there was no documentation about creating hotkeys _within_ ahk menus... i.e. underlining letters in menu selections so that they execute with a single keypress. So, the most used macros need two keypresses, the menu trigger and the menu item trigger. Less used macros put in submenus take one more keypress per submenu item... fast, very fast.
The good news, is that when I tried the same syntax for the ahk menu labels, it works! ...just put an asterisk "&" in front of the label letter anywhere in the label you want to use as a trigger... i.e. "Rebe&ka" to trigger "Rebeka" As long as that labeled letter is a unique within any one menu, it will trigger the label by simply pressing that key.
There is also a new factor at play... windows based tablets when used without hardware keyboards. The windows tablet osk has neither an <alt> nor <win> key, so, there are almost no available <ctrl> keys for ahk use.
I just purchased a lenovo Miix700 as a replacement for my 2006 fujitsu laptop and quickly found that win10 and especially it's tablet mode finally defeated the menu based macro program I have been using for a decade, so, it was time to pull out ahk and start stirring up the grey cells by learning a new language... it's been a fun and productive few days, ...but, my brain hurts
Thanks for the response. Your posts have given me some additional ideas to test. I will experiment and report my findings.
Beverly Howard
- waetherman
- Posts: 112
- Joined: 05 Feb 2016, 17:00
Re: SetKeyDelay in Menu?
I think it's Windows' implementation. I remember this ampersand functionality from my experience in Borland Delphi almost 20 years ago.bevhoward wrote:The good news, is that when I tried the same syntax for the ahk menu labels, it works! ...just put an asterisk "&" in front of the label letter anywhere in the label you want to use as a trigger... i.e. "Rebe&ka" to trigger "Rebeka" As long as that labeled letter is a unique within any one menu, it will trigger the label by simply pressing that key.
Also, the menu functionality can be easily reproduced by hotkeys by just putting hotkeys on all keys (not just rarely used combinations), but enabling them only after first hotkey or only when e.g. scroll lock is ON.
Marek Smolinski
Re: SetKeyDelay in Menu?
>> putting hotkeys on all keys (not just rarely used combinations), but enabling them only after first hotkey or only when e.g. scroll lock is ON. <<
Great info! Will definitely use that ...however, for other needs and especially for use in windows tablet mode. Another issue with me is age (73) and the creeping inability to remember what key is for what
I will be back later for the "enabling" syntax.
Thanks again,
Beverly Howard
Great info! Will definitely use that ...however, for other needs and especially for use in windows tablet mode. Another issue with me is age (73) and the creeping inability to remember what key is for what
I will be back later for the "enabling" syntax.
Thanks again,
Beverly Howard
- waetherman
- Posts: 112
- Joined: 05 Feb 2016, 17:00
Re: SetKeyDelay in Menu?
You could also for example create a searchable interface. For example pressing a Windows key could popup a field to search for a command. Because pressing Windows key alone is done only to access Windows Menu, it wouldn't interfere, and could detect a mouse click and hide itself in such case. But if a user would type instead, then something similar to autocomplete suggestions would appear. It's some hassle to do, but how cool would it be!
Marek Smolinski
Marek Smolinski
Re: SetKeyDelay in Menu?
>> how cool would it be <<
That's what drives many of us
Beverly Howard
That's what drives many of us
Beverly Howard