0

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
2
  • 1
    You need to edit and add a tag indicating the language/technology you are using. Commented Nov 5, 2014 at 13:03
  • I fixed it, can you tell me what to do to fix this? Commented Nov 6, 2014 at 6:59

2 Answers 2

1
; 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.

Sign up to request clarification or add additional context in comments.

Comments

0

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:

  1. Always place { after if statement condition in a new line, not before if statement.
  2. It is not an actual error but always try to use := instead of = for assigning numeric values.
  3. Always enclose if statement condition in ().
  4. As far as I know you can't directly use array item with Send command. Put array item to another variable and after use that variable with Send command.
  5. Hotkey does not need to be enclosed in {}.


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!

1 Comment

YOU ARE THE BEST! I fiddled around with the advice and turns out I need to put the Quote_Selector have % around it to define the exact value of it. I'll put up the actual solution to this to show how amazing you are at helping! THANKYOU!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.