Script help: combine left click macro with another script which presses the "1" hotkey

Ask gaming related questions
need_skill
Posts: 2
Joined: 13 Apr 2024, 06:27

Script help: combine left click macro with another script which presses the "1" hotkey

13 Apr 2024, 06:31

So what i am trying to do is very complicated and i don't know if its possible but here it is.First of all i have a left click macro which activates when i hold down the left click button and stops when i release and i need to combine this with another script which presses the "1" hotkey when i am holding left click and switches to "2" hotkey when i release it only needs 1 tap not a spam but it also has to not conflict with my left click macro is this possible I am open to every kind of workaround which achieves this
User avatar
mikeyww
Posts: 27133
Joined: 09 Sep 2014, 18:38

Re: Script help: combine left click macro with another script which presses the "1" hotkey

14 Apr 2024, 07:33

Welcome to this AutoHotkey forum!

When you have a script that does not work, I recommend posting it here on the forum. This enables other forum readers to examine it, run it, and provide specific feedback about it. It may also help if you provide more detail about what the script should do. Include a few examples of the different situations if possible.
need_skill
Posts: 2
Joined: 13 Apr 2024, 06:27

Re: Script help: combine left click macro with another script which presses the "1" hotkey

17 Apr 2024, 08:58

i think i already said enough i am very new to autohotkey and so far i came up with F1::MyToggleFunc("On/Off")

Code: Select all

F1::MyToggleFunc("On/Off")

#HotIf MyToggleFunc()
*LButton:: {
    SetTimer(MyOtherFunc, 0)
    SetTimer(MyFunc, 50)
}

*LButton Up:: {
    SetTimer(MyFunc, 0)
    SetTimer(MyOtherFunc, 50)
}
#HotIf

MyFunc() => Send(1)
MyOtherFunc() => Send(2)

MyToggleFunc(Param := "") {
    Static Toggle := false
    If Param {
        if not Toggle := !Toggle {
            SetTimer(MyFunc, 0)
            SetTimer(MyOtherFunc, 0)
        }
    }
    Return Toggle
}
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]

but this firstly spams the "1" hotkey when i am holding it and "2" hotkey when i release i want it to realize that i pressed left click and i am holding it when it does that it should press "1" hotkey once and when i release it should press "2" hotkey once and it needs to do all of these while not blocking left click macros or disabling mouse input while turning around in a game etc
User avatar
mikeyww
Posts: 27133
Joined: 09 Sep 2014, 18:38

Re: Script help: combine left click macro with another script which presses the "1" hotkey

17 Apr 2024, 10:11

I'm not sure why you are calling the 1 and 2 hotkeys. They are just regular keys that you are sending (not triggering), right?

If you do not want to use a timer for repeated action, then why are the timers present throughout your script?

Code: Select all

#Requires AutoHotkey v2.0
SetKeyDelay 25, 25

~LButton:: {
 SetTimer go, 200
 SendEvent '{LButton up}1'
 KeyWait 'LButton'
 SetTimer go, 0
 SendEvent 2
}

go() {
 If !GetKeyState('LButton', 'P')
  Return
 SendEvent '-'
}
Test in Notepad.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 14 guests