使用另一个禁用脚本/或热键的一部分

时间:2017-07-21 01:56:00

标签: autohotkey

所以,我有这个代码,我想要它,所以当我按下" numpad1"我可以切换" LButton"开和关。如果我运行它,脚本实际上是有效的但是当我使用LButton(鼠标左键)更改一些选项并在游戏中执行其他任务时,如果我只是保留它我就不能使用LButton来做任何事情而不仅仅是脚本,所以我希望能够打开和关闭它。我不知道自己是否清楚但我希望自己做到了。谢谢你的回答!

 #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
Gui,+AlwaysOnTop
Gui,Show,w500 h500 Center,AlwaysOnTop Window
Gui, Add, Text, x10 y15 w105 h90 , Choose your weapon.
Gui, Show, x127 y87 h269 w246, Recoilbot
Gui, Add, DropDownList, x120 y10 w50 vList1 gOnSelect, Off|AK-47|M4A4


#Persistent
Gui, Add, Checkbox, vSjekkboksen, Status

;;;no reason to set the same info every time you click so define outside/before the label
active_pattern := ak_pattern ;semi-redundant and will make sense later
sens:=2.52
key_shoot:="LButton"
modifier:=2.52/sens

;instead of having 29 separate dllcalls with a bunch of if->elses, use an array so you can loop over them
no_pattern := {}
ak_pattern := {1: "-4,7",       2: "4,19",      3: "-3,29"
              ,4: "-1,31",      5: "13,31",     6: "8,28"
              ,7: "13,21",      8: "-17,12",    9: "-42,-3"
              ,10: "-21,2",     11: "12,11",    12: "-15,7"
              ,13: "-26,-8",    14: "-3,4",     15: "40,1"
              ,16: "19,7",      17: "14,10",    18: "27,0"
              ,19: "33,-10",    20: "-21,-2",   21: "7,3"
              ,22: "-7,9",      23: "-8,4",     24: "19,-3"
              ,25: "5,6",       26: "-20,-1",   27: "-33,-4"
              ,28: "-45,-21",   29: "-14,1"}
;"another" pattern, just an example of adding more
m416_pattern := {1: "-4,7",     2: "4,19",      3: "-3,29"
              ,4: "-1,31",      5: "13,31",     6: "8,28"
              ,7: "13,21",      8: "-17,12",    9: "-42,-3"
              ,10: "-21,2",     11: "12,11",    12: "-15,7"
              ,13: "-26,-8",    14: "-3,4",     15: "40,1"
              ,16: "19,7",      17: "14,10",    18: "27,0"}



active_pattern := no_pattern ;setting the ak_pattern as the default one at launch, demo purposes      

1::active_pattern := ak_pattern
2::active_pattern := m416_patternpattern
3::active_pattern := no_pattern

#IfWInActive, Recoilbot
Numpad1::
    ControlGet, outPutVar, Checked , , Button1, Recoilbot

    If outPutVar
        GuiControl, , Sjekkboksen, 0

    Else
        GuiControl, , Sjekkboksen, 1
Return

Numpad0::
    ControlGet, outPutVar, Checked , , Button1, Recoilbot

    If outPutVar
        GuiControl, , Sjekkboksen, 1

    Else
        GuiControl, , Sjekkboksen, 0
return
return
Gui, show

OnSelect:
Gui, Submit, nohide
if (List1 = "AK-47") {
    active_pattern:=ak_pattern
}
Else if (List1 = "M4A4") {
    active_pattern:=m416_pattern
}
Else if (List1 = "Off") {
    active_pattern:= no_pattern
}
return
;using right button so I can close script easier (will change it once script is finished).
LButton::
        DllCall("mouse_event", uint, 2, int, 0, int, 0, uint, 0, int, 0) ;send the mouse down like in your script
        loop { ;loop "until" key_shoot is released or you've reached the end (empty mag) "a_index > active_pattern.maxindex()"
            x := strsplit(active_pattern[a_index],",")[1] ;get the "x" from the item at a_index in active_pattern
            y := strsplit(active_pattern[a_index],",")[2] ;get the "y" from the item at a_index in active_pattern
            dllcall("mouse_event","UInt",0x01,"UInt",x*modifier,"UInt",y*modifier) ;same relative dllcall like in your script
            sleep, 99 ;same...
        } until % !GetKeyState(key_shoot,"P") || a_index > active_pattern.maxindex() ;see loop comment
        DllCall("mouse_event", uint, 4, int, 0, int, 0, uint, 0, int, 0) ;send the mouse up like in your script

1 个答案:

答案 0 :(得分:0)

正确的文档:https://autohotkey.com/docs/commands/Suspend.htm#Example

; Send a Suspend command to another script.
DetectHiddenWindows, On
WM_COMMAND := 0x111
ID_FILE_SUSPEND := 65404
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, C:\YourScript.ahk ahk_class AutoHotkey