| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Mon May 12, 2008 12:44 am Post subject: Hotkeys within a script stop execution? |
|
|
This script to hold down a key works fine...
Loop
{
SendInput {w down} ; Auto-repeat consists of consecutive down-events (with no up-events).
Sleep 30 ; The number of milliseconds between keystrokes (or use SetKeyDelay).
}
But when I add a hotkey into the script like below the hotkey works but the script (loop) dosn't execute?
#x::ExitApp
Loop
{
SendInput {w down} ; Auto-repeat consists of consecutive down-events (with no up-events).
Sleep 30 ; The number of milliseconds between keystrokes (or use SetKeyDelay).
} |
|
| Back to top |
|
 |
Guest
|
Posted: Mon May 12, 2008 12:51 am Post subject: |
|
|
Maybe "Hotkey" cmd will fix this  |
|
| Back to top |
|
 |
Superfraggle
Joined: 02 Nov 2004 Posts: 753 Location: London, UK
|
Posted: Mon May 12, 2008 1:07 am Post subject: |
|
|
Add the hotkey after the loop. The first lines of the script will automatically Run. Until a hotkey, function??, or return is encountered. _________________ Steve F AKA Superfraggle
http://r.yuwie.com/superfraggle |
|
| Back to top |
|
 |
Guest
|
Posted: Mon May 12, 2008 1:08 am Post subject: |
|
|
I made a script to do it with seperate hotkeys for now but I want it like this, how to do this?
1. Win+W starts the script
2. Script redefines Win+W to ExitApp
3. Script exits and Win+W reverts to starting the script (as assigned in AutoHotkey.ini.
| Code: | #x::ExitApp
#w::
Loop
{
SendInput {w down} ; Auto-repeat consists of consecutive down-events (with no up-events).
Sleep 30 ; The number of milliseconds between keystrokes (or use SetKeyDelay).
}
return
|
|
|
| Back to top |
|
 |
Guest
|
Posted: Mon May 12, 2008 1:09 am Post subject: |
|
|
| Superfraggle wrote: | | Add the hotkey after the loop. The first lines of the script will automatically Run. Until a hotkey, function??, or return is encountered. |
I think I tried that but will try again.. |
|
| Back to top |
|
 |
Guest
|
Posted: Mon May 12, 2008 1:12 am Post subject: |
|
|
| Doing it like that - the script executes but the hotkey dosn't work? |
|
| Back to top |
|
 |
Superfraggle
Joined: 02 Nov 2004 Posts: 753 Location: London, UK
|
Posted: Mon May 12, 2008 1:25 am Post subject: |
|
|
Please register so you dont have to triple post.
The reason it doesnt work is because you are holding down the w key. So as far as ahk is concerned you are pressing Win + W + X.
You need to use the keyboard hook so that it can determine between the artificial key and the real key.
| Code: |
#w::
Loop
{
SendInput {w down} ; Auto-repeat consists of consecutive down-events (with no up-events).
Sleep 30 ; The number of milliseconds between keystrokes (or use SetKeyDelay).
}
REturn
$#x::Reload
|
Win x will reload the script, thus turning off the loop. _________________ Steve F AKA Superfraggle
http://r.yuwie.com/superfraggle |
|
| Back to top |
|
 |
excelsium
Joined: 12 May 2008 Posts: 3
|
Posted: Mon May 12, 2008 2:21 am Post subject: |
|
|
How do I use the keyboard hook to do this..
1. Hotkey in AutoHotkey.ini starts the script.
2. The Script re assigns Same hotkey to Reload itself.
3. Script reloads.
Editing above^^
| Code: | #SingleInstance force
#InstallKeybdHook
SendInput {w up}
+e::
Reload
return
+w::
Loop
{
SendInput {w down}
Sleep 30
}
return |
thats the closest I've got..
Last edited by excelsium on Mon May 12, 2008 2:48 am; edited 3 times in total |
|
| Back to top |
|
 |
autonoob Guest
|
Posted: Mon May 12, 2008 2:24 am Post subject: |
|
|
[quote]+e::
ms =: 5000
sleep 5*#ms#
SendInput {w}
send up
send "}"
/quote]
yw |
|
| Back to top |
|
 |
excelsium
Joined: 12 May 2008 Posts: 3
|
Posted: Mon May 12, 2008 2:56 am Post subject: |
|
|
That dosn't help autonoob..
Finally I'm sure of what I need to know...
- Script starts.. via hotkey or not.. if hotkey then a different hotkey to the ones used within.
- Subscript starts via a hotkey e.g. +w .. once the subscripts started it needs to redefine +w to reload this script , how to do this? :>. |
|
| Back to top |
|
 |
|