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 

suspend within a function

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



Joined: 13 May 2008
Posts: 5

PostPosted: Wed May 14, 2008 3:42 am    Post subject: suspend within a function Reply with quote

hi guys, i am trying to improve on my 'leetspeaker' program. This is a small chunk of the 500 line code.

Code:
;random function
random(){
random, rand, 1, 4
return rand
}

;lowercase function to prevent hotkey from calling itself
lowercase(x){
suspend, on
send %x%
suspend,off
}

;a hotkey
a::
rand := random()
if(rand=1){
suspend, on
send, a
suspend,off
}
else if(rand=2){
send, A
}
else if(rand=3){
send, 4
}
else{
send, @
}
return

;b hotkey
b::
rand := random()
if(rand=1){
suspend, on
send, b
suspend,off
}
else if(rand=2){
send, B
}
else if(rand=3){
send, B
}
else{
send, 8
}
return


As you probably can see, the lowercase functions prevents the hotkey from calling itself. for example, if 'a' is typed and the result of rand is 1, the lowercase function will kick in, suspending the script and outputting 'a' so that 'a' will not call itself. after 'a' is outputted, the script is then resumed. the logic is there, but i cant seem to figure why it isnt working.

below is some sample output:
a: 4@AAA@@@@44@@A4AA4AA44A@A@A@@444A4@AA@@A4A@@@A4
b: 8BB8BBBB8BB88BBBBBBBB8B88B8B88BB8B88BB8BBBBB88BBB88B

'a' and 'b' are never outputted. someone please help!!!
Back to top
View user's profile Send private message
Z Gecko
Guest





PostPosted: Wed May 14, 2008 3:49 am    Post subject: Reply with quote

why you dont use the $-modifier
Code:
$a::

from the help:
Quote:
$
This is usually only necessary if the script uses the Send command to send the keys that comprise the hotkey itself, which might otherwise cause it to trigger itself. The exact behavior of the $ prefix varies depending on operating system:
Back to top
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