Reputation: 21
I bought a new mouse which has a wheel on it and I've made it so a variable (Quote_Selector) increases or decreases from which way the secondary mouse wheel turns. The integer from this variable is also the key in which defines which message my button sendsfrom the array. The problem is trying to link the Quote_Selector as a key to pull which message is in the array shown and send it. My goal is to try and make this as clean as possible as well. And I've even tried using For key [,value] in expression but I can't seem to come up with anything. i am using the AutoHotKey language and software.
; Declare Variables
Quote_Selector = 0
Min_Selector_Range = 0
Max_Selector_Range = 3
; Declare Message Choices
MessageArray := []
MessageArray[0] := "Darude - Sandstorm"
MessageArray[1] := "Rekt"
MessageArray[2] := "I cry all the time"
MessageArray[3] := "My anaconda don't"
return
; Forward Key Command
$=::
{
If Quote_Selector < %Max_Selector_Range%
Quote_Selector ++
Send, %Quote_Selector%
}
return
; Backward Key Command
$-::
{
If Quote_Selector > %Min_Selector_Range%
Quote_Selector --
Send, %Quote_Selector%
}
return
; Enter Chat Command
$0::
{
Send, {Enter}
Send, /all{space} %value%
Send, {enter}
}
return
Upvotes: 0
Views: 97
Reputation: 6930
Try this:
; Declare Variables
Quote_Selector := 0
Min_Selector_Range := 0
Max_Selector_Range := 3
; Declare Message Choices
MessageArray := []
MessageArray[0] := "Darude - Sandstorm"
MessageArray[1] := "Rekt"
MessageArray[2] := "I cry all the time"
MessageArray[3] := "My anaconda don't"
return
; Forward Key Command
$=::
If (Quote_Selector < Max_Selector_Range)
{
Quote_Selector := Quote_Selector + 1
CurrentMessage := MessageArray[Quote_Selector]
Send, %CurrentMessage%
CurrentMessage := ""
}
return
; Backward Key Command
$-::
If (Quote_Selector > Min_Selector_Range)
{
Quote_Selector := Quote_Selector - 1
CurrentMessage := MessageArray[Quote_Selector]
Send, %CurrentMessage%
CurrentMessage := ""
}
return
; Enter Chat Command
$0::
Send, {Enter}
Send, /all{space} %value%
Send, {enter}
return
Is this what you want script to do?
Your mistakes:
{
after if
statement condition in a new line, not before if
statement.:=
instead of =
for assigning numeric values.if
statement condition in ()
.Send
command. Put array item to another variable and after use that variable with Send
command.{}
.
Also, always use AutoHotkey and its documenatation from http://ahkscript.org/ (current uptodate version, new official website)! AutoHotkey and its documentation from autohotkey.com is outdated and you may have some problems using them!
Upvotes: 0
Reputation: 21
; Declare Variables
Quote_Selector := 0
Min_Selector_Range := 0
Max_Selector_Range := 3
; Declare Message Choices
MessageArray := []
MessageArray[0] = "Darude - Sandstorm"
MessageArray[1] = "Rekt"
MessageArray[2] = "Ready to meme"
MessageArray[3] = "My anaconda don't"
return
; Forward Key Command
$=::
If (Quote_Selector < Max_Selector_Range)
{
Quote_Selector := Quote_Selector + 1
}
return
; Backward Key Command
$-::
If (Quote_Selector > Min_Selector_Range)
{
Quote_Selector := Quote_Selector - 1
}
return
; Enter Chat Command
$0::
Send, {Enter}
CurrentMessage := MessageArray[%Quote_Selector%]
Send, /all{Space} %CurrentMessage%
Send, {Enter}
CurrentMessage := ""
return
The code shown uses two keys to change the message to previous or next, and pressing the send button sends that the text provided in the array.
Upvotes: 1