-1

How to make this script work with this macro: https://i.stack.imgur.com/TELZi.png?

EnablePrimaryMouseButtonEvents(true);
function OnEvent(event, arg)
if IsKeyLockOn("capslock")then
if IsMouseButtonPressed(1) then
repeat
MoveMouseRelative(0,-1)
Sleep(10)
until not IsMouseButtonPressed(1)
end 
end
end

Is it also possible to make a script where:

When pressing the Left Mouse button - It will drag/snap the crosshair/camera upward (few pixels above the target) but at the same time, the weapon will shot/fire only after reaching that pixel?

techseeder
  • 1
  • 1
  • 4
  • What button your macro is bound to? Do you want to control both anti-recoil and the macro with the same button (left mouse button)? – Egor Skriptunoff Nov 13 '20 at 15:03
  • `only after reaching that pixel` - do you know how many milliseconds it will take? – Egor Skriptunoff Nov 13 '20 at 15:07
  • The macro is bound to the Right Mouse Button. I wanted the anti-recoil to kick while holding down the Right Mouse Button but right now the script doesn't work with the macro that is already binded in the RMB. – techseeder Nov 13 '20 at 15:24
  • To be honest the milliseconds will vary depending on the distance of the target, would it be possible that the milliseconds is going to be editable? – techseeder Nov 13 '20 at 15:29
  • AFAIU you want to achieve the following behavior: when you press RMB, the Shift press is simulated, and mouse starts to move. When you release RMB, Shift release is simulated, and mouse movement stops. Is it correct? – Egor Skriptunoff Nov 13 '20 at 16:12
  • It needs to simulate pressing both RMB + SHIFT while holding the RMB and while doing so the mouse starts to move upwards. Letting go of the RMB stops the movement. – techseeder Nov 13 '20 at 16:50

1 Answers1

0
  1. Unbind your macro from RMB. Bind standard "Secondary click" to RMB.
  2. Set the script:
function OnEvent(event, arg)
   if event == "PROFILE_ACTIVATED" then
      EnablePrimaryMouseButtonEvents(true)
   elseif event == "MOUSE_BUTTON_PRESSED" and arg == 2 and IsKeyLockOn"capslock" then  -- RMB pressed
      Sleep(50)
      PressKey"lshift"
      repeat
         MoveMouseRelative(0,-1)
         Sleep(10)
      until not IsMouseButtonPressed(3)  -- RMB released
      ReleaseKey"lshift"
   end
end

Script #2

  1. Create a "spare LMB" button.
    For example, if you don't use button#8, bind "Primary click" to Button#8.
    If something goes wrong and your LMB stops working, you can use button#8 instead of LMB.

  2. Set script

function OnEvent(event, arg)
   if event == "PROFILE_ACTIVATED" then
      EnablePrimaryMouseButtonEvents(true)
   elseif event == "MOUSE_BUTTON_PRESSED" and arg == 1 then  -- LMB pressed
      if IsKeyLockOn"capslock" then
         if IsModifierPressed"shift" then
            -- Mouse movement when SHIFT is pressed
            for i = 1, 4 do  -- 4 steps.  Each step is 30ms delay and 5 pixels movement.  Total is 20 pixels
               MoveMouseRelative(0,-5)
               Sleep(30)
            end
         else
            -- Mouse movement when SHIFT is NOT pressed
            for i = 1, 4 do  -- 4 steps.  Each step is 30ms delay and 5 pixels movement.  Total is 20 pixels
               MoveMouseRelative(0,-5)
               Sleep(30)
            end
         end
      end
      PressMouseButton(1)
   elseif event == "MOUSE_BUTTON_RELEASED" and arg == 1 then  -- LMB released
      ReleaseMouseButton(1)
   end
end
  1. Unbind "Primary click" from LMB (it will look like white circle with black inside).
Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64
  • My apologies I need to edit my comment. I think you forgot to add the press simulation of RMB. – techseeder Nov 13 '20 at 17:20
  • You don't need to simulate RMB press if you have "Secondary click" bounded to RMB. – Egor Skriptunoff Nov 13 '20 at 17:22
  • I tested again and it would will sometimes Aim Down Sights but most of the time it just goes to a standard Hipfire mode. – techseeder Nov 13 '20 at 17:37
  • Insert `Sleep(50)` before `PressKey"lshift"` – Egor Skriptunoff Nov 13 '20 at 18:06
  • That fixed it. :D – techseeder Nov 13 '20 at 18:14
  • so is it possible to make that second script? – techseeder Nov 13 '20 at 19:46
  • The second script AFAIU: when you press-and-hold LMB, mouse slowly moves upward and after some delay LMB press is simulated. Is it correct? – Egor Skriptunoff Nov 13 '20 at 21:33
  • Is it possible that when you press (no holding) LMB will snap a few pixels (10 ms) above its original position and after some delay LMB press is simulated. – techseeder Nov 14 '20 at 03:31
  • This is perfect! I just need to tweak it a little bit more and it does exactly what I wanted. Thanks a lot bro, really wish I can return the favor. – techseeder Nov 14 '20 at 06:25
  • Is it possible to edit the second script further where: script will do the same function except there will be two modes: The first one while holding down the RMB button (Hipfire) and pressing the LMB will trigger the script function, the second one is while holding down RMB + SHIFT (ADS) and pressing the LMB will trigger the script function. Each modes will have different pixel movement. – techseeder Nov 18 '20 at 04:09