AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Hotkeys within a script stop execution?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Mon May 12, 2008 12:44 am    Post subject: Hotkeys within a script stop execution? Reply with quote

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






PostPosted: Mon May 12, 2008 12:51 am    Post subject: Reply with quote

Maybe "Hotkey" cmd will fix this Very Happy
Back to top
Superfraggle



Joined: 02 Nov 2004
Posts: 753
Location: London, UK

PostPosted: Mon May 12, 2008 1:07 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Guest






PostPosted: Mon May 12, 2008 1:08 am    Post subject: Reply with quote

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






PostPosted: Mon May 12, 2008 1:09 am    Post subject: Reply with quote

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






PostPosted: Mon May 12, 2008 1:12 am    Post subject: Reply with quote

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

PostPosted: Mon May 12, 2008 1:25 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
excelsium



Joined: 12 May 2008
Posts: 3

PostPosted: Mon May 12, 2008 2:21 am    Post subject: Reply with quote

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^^ Confused


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
View user's profile Send private message
autonoob
Guest





PostPosted: Mon May 12, 2008 2:24 am    Post subject: Reply with quote

[quote]+e::
ms =: 5000
sleep 5*#ms#
SendInput {w}
send up
send "}"

/quote]


yw
Back to top
excelsium



Joined: 12 May 2008
Posts: 3

PostPosted: Mon May 12, 2008 2:56 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group