2014-11-05 8 views
0

휠이있는 새 마우스를 구입했습니다. 변수 (Quote_Selector)가 증가하거나 감소하여 보조 마우스 휠이 돌아서도록했습니다. 이 변수의 정수는 내 단추가 배열에서 보내는 메시지를 정의하는 키이기도합니다. 문제는 Quote_Selector를 표시된 배열의 메시지를 가져오고 보내기위한 키로 연결하려고하는 것입니다. 내 목표는 이것을 가능한 한 깨끗하게하려고 시도하는 것입니다. 그리고 심지어 사용해 보았습니다 표현식에서 키 [, 값]에 대해,하지만 아무 것도 생각 나지 않는 것 같습니다. 나는 AutoHotKey 언어와 소프트웨어를 사용하고있다.변수를 변경하고 키로 사용

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

사용중인 언어/기술을 나타내는 태그를 편집하고 추가해야합니다. –

+0

이 문제를 해결하기 위해 무엇을해야하는지 말해 줄 수 있습니까? –

답변

0

이 시도 :

; 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 

이 당신이 스크립트가 수행 할 작업인가?


실수 :

  1. 항상 배치 {하지 if 문 앞에 새로운 라인 if 문 조건, 후.
  2. 실제 오류는 아니지만 항상 = 대신 :=을 사용하여 숫자 값을 할당 해보십시오.
  3. 항상 if 문 조건을 ()으로 묶으십시오.
  4. 내가 아는 한 Send 명령으로 배열 항목을 직접 사용할 수 없습니다. 배열 항목을 다른 변수에 넣고 그 변수를 Send 명령과 함께 사용합니다.
  5. 단축키는 {}으로 묶지 않아도됩니다.


또한, 항상 AutoHotkey를하고 http://ahkscript.org/로부터 documenatation (현재을 최신 상태 버전, 새로운 공식 웹 사이트)를 사용! autohotkey.com의 AutoHotkey 및 설명서는 구형이므로 사용하는 데 문제가있을 수 있습니다!

+0

당신은 최고입니다! 나는 조언을 둘러 보면서 Quote_Selector에 정확한 값을 정의 할 수 있도록 Quote_Selector를 두어야한다. 나는 당신이 얼마나 놀라운 도움을 주 었는지 보여주기 위해 실제 해결책을 제시 할 것입니다! 고맙습니다! –

+0

@GraemeChew 감사합니다. 당신을 도와 드리겠습니다. – vasili111

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 

표시된 코드는 이전 또는 다음 메시지를 변경할 두 개의 키를 사용하고 송신 버튼을 누르면, 텍스트를 배열 한 것으로 보낸다.