Holding shift down while also rapid left click

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
timeloop4444
Posts: 7
Joined: 06 Aug 2022, 19:33

Holding shift down while also rapid left click

Post by timeloop4444 » 06 Aug 2022, 19:40

I can't figure out whats going wrong but I am trying to make a macro that will
1. Hold shift when lctrl is pressed and release it when rctrl is pressed
2. mouse click left rapid when held down

They kind of work separately but I cant get them to work at the same time.

Thank you for helping me.

-----------------------------------------------------------------------------

Code: Select all

LCtrl::
{
Send {LShift Down}
}

RCtrl::
{
Send {LShift Up}
}


LShift & LButton::
While (GetKeyState("LShift & LButton","P"))
{
  Click
  sleep, 10
}

LButton::
While (GetKeyState("LButton","P"))
{
  Click
  sleep, 10
}

Return
[Mod edit: [code][/code] tags added.]

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Holding shift down while also rapid left click

Post by Rohwedder » 07 Aug 2022, 03:38

Hallo.
Test, test, test, preferably in Notepad!
Already the beginning of your script does not work!:

Code: Select all

LCtrl::
{
Send {LShift Down}
}

RCtrl::
{
Send {LShift Up}
}
A LCtrl pressure should switch on the capitalization. A RCtrl pressure should switch off.
What is missing?

timeloop4444
Posts: 7
Joined: 06 Aug 2022, 19:33

Re: Holding shift down while also rapid left click

Post by timeloop4444 » 07 Aug 2022, 12:54

the code you linked works on its own if I put a return tag but it doesnt work together with the rest of it. There is a return tag at the end. I don't know what I'm missing other than that!

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Holding shift down while also rapid left click

Post by boiler » 07 Aug 2022, 13:26

Braces { } don't mean anything as far as defining the start and end of hotkey subroutines in AHK v1. That's also not the way you get the state of multiple keys. And don't use the custom key combination for hotkeys when a modifier key will suffice. Your code should look like this:

Code: Select all

LCtrl::Send {LShift Down}

RCtrl::Send {LShift Up}


<+LButton::
  While (GetKeyState("LShift") && GetKeyState("LButton","P"))
  {
    Click
    sleep, 10
  }
return

LButton::
  While (GetKeyState("LButton","P"))
  {
    Click
    sleep, 10
  }
return
Why exactly RCtrl doesn't seem to release LShift, I don't know.

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Holding shift down while also rapid left click

Post by Rohwedder » 08 Aug 2022, 01:25

Why exactly RCtrl doesn't seem to release LShift?
Try:

Code: Select all

+RCtrl::Send {LShift Up}

timeloop4444
Posts: 7
Joined: 06 Aug 2022, 19:33

Re: Holding shift down while also rapid left click

Post by timeloop4444 » 09 Aug 2022, 19:03

Thank you for your help. I was not aware of some of the codes you guys used like + or <+ and I wasnt able to find any info on them other than something about a hotkey prefix. I also didnt know you had to put & twice so im not sure what that did either.

Is it possible to have Lshift be the toggle to turn it on AND off? Like first time to hold shift down, then second time turn let shift up and so on. Like a toggle. I have been trying to find code but I cant understand how to apply it to my macro.

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Holding shift down while also rapid left click

Post by boiler » 09 Aug 2022, 21:05

&& is just a shortcut for the and operator. It’s not in place of where you would use & (either in custom hotkey combinations or as the bitwise and operator).

You could make it so you could use LShift as a toggle, but you want to kill your LShift key from working like a regular Shift key?

timeloop4444
Posts: 7
Joined: 06 Aug 2022, 19:33

Re: Holding shift down while also rapid left click

Post by timeloop4444 » 12 Aug 2022, 13:28

thank you for responding.
oh okay so ill use && or and in the future. do you know what the + or <+ does before the key like +rctrl? i cant find info on that.

but yeah I would like the shift key to still work as normal. so to answer your question, no i dont want to kill the lshift key.

thank you!

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Holding shift down while also rapid left click

Post by boiler » 12 Aug 2022, 17:05

timeloop4444 wrote: oh okay so ill use && or and in the future. do you know what the + or <+ does before the key like +rctrl? i cant find info on that.
+ is the Shift key modifier symbol. < is the symbol that indicates to use the left of a pair of keys like Shift or Ctrl.

It's explained in the documentation for Hotkeys in the Hotkey Modifier Symbols section.

timeloop4444
Posts: 7
Joined: 06 Aug 2022, 19:33

Re: Holding shift down while also rapid left click

Post by timeloop4444 » 15 Aug 2022, 00:57

Oh I understand now. Thank you for explaining.

To answer your previous question
You could make it so you could use LShift as a toggle, but you want to kill your LShift key from working like a regular Shift key?
I would like the shift key to still work as normal. so to answer your question, no i dont want to kill the lshift key. Can that be achieved here?

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Holding shift down while also rapid left click

Post by boiler » 15 Aug 2022, 01:14

Use the ~ modifier to keep its normal function and have it toggle a variable:

Code: Select all

~LShift::Toggle := !Toggle
Then have whatever you want to be toggled act on whether the value of that variable is True or False (1 or 0).

timeloop4444
Posts: 7
Joined: 06 Aug 2022, 19:33

Re: Holding shift down while also rapid left click

Post by timeloop4444 » 21 Aug 2022, 16:52

Code: Select all

~LShift::Toggle := !Toggle


<+LButton::
  While (GetKeyState("LShift") && GetKeyState("LButton","P"))
  {
    Click
    sleep, 10
  }
return

LButton::
  While (GetKeyState("LButton","P"))
  {
    Click
    sleep, 10
  }
return
would I add something like this somewhere to make it do what i want?

Code: Select all

Toggler: 
    if (toggle = true)
        Send, {LShift down}
    else
        Send, {LShift up}

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Holding shift down while also rapid left click

Post by boiler » 22 Aug 2022, 18:30

I can't tell what you're trying to do. At one point you said you want to use LShift as a toggle for some things but you want it to otherwise act as it normally would. Are you now saying you want it to actually lock shift down as if it was a Caps Lock key?

In any case, you can't just put some label like Toggler before some code and expect it to know when to execute. Just because your hotkey toggles the value of the Toggle variable and your Toggler makes use of the variable Toggle, it doesn't magically know to execute that code when the value of the variable changes. You have to direct the code there by using something such as gosub. Or just include that code in the hotkey routine itself.

timeloop4444
Posts: 7
Joined: 06 Aug 2022, 19:33

Re: Holding shift down while also rapid left click

Post by timeloop4444 » 26 Aug 2022, 13:39

what im trying to say is i want shift to act as it normal would except that in addition to its normal function, i want it to hold down shift when i first press it then stop holding it down on the second press and so forth. so i press shift, now shift is being held down, i press shift again, now shift is released. basically just on and off for shift being held down and using shift as the activator. i hope that makes sense.

if its not obvious by now, i dont know how to implement the toggles with the knowledge i have which is why im here in the first place. i have tried looking up toggles but i dont understand how to implement it into my macro.

thank you

Post Reply

Return to “Ask for Help (v1)”