如果变量为true,AutoHotKey更改键

问题描述:

我是新来的AutoHotKey,并且正在尝试创建一个脚本,让我可以在我的PC上使用Roku的蓝牙遥控器。遥控器的问题是所有的键都很奇怪。我想要的是,当我同时按x和y键时,所有必要的键都会重新映射到远程键的键,反之亦然。这是我现在(不工作):如果变量为true,AutoHotKey更改键

state = keyboard 

loop{ 
    if (GetKeyState("x", "P") && GetKeyState("y", "P")){ 
     if (state == "keyboard") { 
      state = roku 
      Sleep 30 

     } 
     else if (state == "roku") { 
      state = keyboard 
      Sleep 30 
     } 
    } 
    if (state == "roku"){ 
     4::send h 
     u::send {up} 
     l::send {left} 
     r::send {right} 
     d::send {down} 
     e::send {esc} 
     6::send {backspace} 
     c::send r 
     8::send f 
     s::send {enter} 
     3::send c 
     a::send {space} 
    } 
} 

有没有人知道为什么这不起作用?

~x & y::(HotkeysState:=!HotkeysState) 

#If HotkeysState 
    4::SendInput h 
    u::SendInput {up} 
    l::SendInput {left} 
    r::SendInput {right} 
    d::SendInput {down} 
    e::SendInput {esc} 
    6::SendInput {backspace} 
    c::SendInput r 
    8::SendInput f 
    s::SendInput {enter} 
    3::SendInput c 
    a::SendInput {space} 
#If 
+0

哇,真的很简单,谢谢! – quadrplax 2014-10-03 21:10:01