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 

[??] Why aren't hotkeys mapping not allowed within functions

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



Joined: 23 Feb 2008
Posts: 59

PostPosted: Sun Apr 20, 2008 10:03 am    Post subject: [??] Why aren't hotkeys mapping not allowed within functions Reply with quote

Ok, I got a big problem, its preventing me from what I want to do.

I wanna remap certain keys, but before that, I want some user interaction.. How do I go abouts this?

Basically it's like this

if code=123
hotkeys1()

if code=234
hotkeys2()

since this probably is a program limitation, anyone got any ideas how to go about this?
Back to top
View user's profile Send private message
Zippo()
Guest





PostPosted: Sun Apr 20, 2008 11:29 am    Post subject: Reply with quote

Use the Hotkey command.
Back to top
biatche



Joined: 23 Feb 2008
Posts: 59

PostPosted: Sun Apr 20, 2008 12:45 pm    Post subject: Reply with quote

function1()
{
Hotkey, !q::send, {Numpad7}
}

syntax dont seem right.. for sure without the hotkey command it doesn't work. thats when it complains about not being able to be inside a function
Back to top
View user's profile Send private message
n-l-i-d
Guest





PostPosted: Sun Apr 20, 2008 1:17 pm    Post subject: Reply with quote

Quote:
syntax dont seem right


... true, it isn't. You are mixing the Hotstring and Hotkey command. Reread the documentation.
Back to top
biatche



Joined: 23 Feb 2008
Posts: 59

PostPosted: Sun Apr 20, 2008 1:23 pm    Post subject: Reply with quote

i can't get "!q::send, {Numpad7} " into a function... it doesnt allow me to.

so zippo seem to have suggested me using hotkey, but reading the docs, i dont know what syntax to make
Back to top
View user's profile Send private message
Tuncay



Joined: 07 Nov 2006
Posts: 384
Location: Berlin

PostPosted: Sun Apr 20, 2008 1:34 pm    Post subject: Reply with quote

Look at this:
Code:
function1()

function1()
{
Hotkey, !q, sendlabel
}

Return ; End of AutoExecution Section.

sendlabel:
    send, {Numpad7}
return

Tested.

With the Hotkey command you specify a Hotkey, which calls a subroutine (here named to sendlabel). To take the dynamically created Hotkey in effect, the command have to be executed. A function encapsulates all commands in it and does not execute automatically. You have to call the function explicitly (first line).
Back to top
View user's profile Send private message Send e-mail
biatche



Joined: 23 Feb 2008
Posts: 59

PostPosted: Sun Apr 20, 2008 2:20 pm    Post subject: Reply with quote

Thanks Tuncay.
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