Jump to content


Photo

Crude Script.


  • Please log in to reply
3 replies to this topic

#1 Ahoy

Ahoy
  • Members
  • 22 posts

Posted 16 April 2012 - 05:16 PM

Hello all, me again!

I have this god awful script that i have made, it works in princable, my problem:

When i take my finger off of the left mouse button the script keeps on going!

Ideally, i would like the script to stop if i take my finger off fire.

script:

#NoEnv
#InstallKeybdHook
#InstallMouseHook

#SingleInstance
ActivateScript = 0

; BF3 G3A3 Full auto recoild timings and distance.
; Press P to suspend this script!

~LButton::autofire() 
~^LButton::autofire() 

Code: 

~*p::suspend

autofire()
{ 
	Loop
	{ 	
	if GetKeyState("LButton", "P") 
	{
send, {Lbutton down}
Sleep, 78
DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
send, {Lbutton up}
Sleep, 100
send, {Lbutton down}
Sleep, 78
DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
send, {Lbutton up}
Sleep, 100
send, {Lbutton down}
Sleep, 78
DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
send, {Lbutton up}
Sleep, 100
send, {Lbutton down}
Sleep, 78
DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
send, {Lbutton up}
Sleep, 100
send, {Lbutton down}
Sleep, 78
DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
send, {Lbutton up}
Sleep, 100
send, {Lbutton down}
Sleep, 78
DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
send, {Lbutton up}
Sleep, 100
send, {Lbutton down}
Sleep, 78
DllCall("mouse_event", uint, 1, int, -1, int, 0, uint, 0, int, 0)
DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
send, {Lbutton up}
Sleep, 100
send, {Lbutton down}
Sleep, 78
DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
send, {Lbutton up}
Sleep, 100
send, {Lbutton down}
Sleep, 78
DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
send, {Lbutton up}
Sleep, 100
send, {Lbutton down}
Sleep, 78
DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
send, {Lbutton up}
Sleep, 100
send, {Lbutton down}
Sleep, 78
DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
send, {Lbutton up}
Sleep, 100
send, {Lbutton down}
Sleep, 78
DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
send, {Lbutton up}
Sleep, 100
send, {Lbutton down}
Sleep, 78
DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
send, {Lbutton up}
} 
		else
		break
		}
}

Thanks everyone.
Apologies about this.

#2 Ohnitiel

Ohnitiel
  • Members
  • 664 posts

Posted 16 April 2012 - 05:24 PM

Reduce the autofire() part to this:

autofire()
{
   Loop
   {    
   if GetKeyState("LButton", "P")
   {
send, {Lbutton down}
Sleep, 78
DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
send, {Lbutton up}
Sleep, 100
}
      else
      break
      }
}

And if you're using Ahk_L:

autofire()
{
	While GetKeyState("LButton", "P")
	{
	send, {Lbutton down}
	Sleep, 78
	DllCall("mouse_event", uint, 1, int, 0, int, 13, uint, 0, int, 0)
	send, {Lbutton up}
	Sleep, 100
	}
}


#3 Ahoy

Ahoy
  • Members
  • 22 posts

Posted 16 April 2012 - 06:48 PM

Oh cripes!

Wow, that looks simply, simple!

I guess us n00bs have a habit of making things overly complicated!

Thank you Ohnitiel!

Now to tweak the recoil and speed!

#4 Ahoy

Ahoy
  • Members
  • 22 posts

Posted 17 April 2012 - 11:35 AM

I have been trying to make this (and ohers) into ahk scripts:

LeftDown 1
Delay 56 ms
MoveR 0 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR -1 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR -1 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR -1 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR -1 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR -1 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR 0 4
LeftUp 1
Delay 14 ms
LeftDown 1
Delay 56 ms
MoveR -1 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR 0 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR -1 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR 0 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR -1 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR -1 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR 0 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR -1 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR 0 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR -1 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR -1 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR 0 4
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR 0 5
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR 0 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR 0 5
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR 0 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR 0 5
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
MoveR 0 4
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
LeftUp 1
Delay 28 ms
LeftDown 1
Delay 56 ms
LeftUp 1
Delay 28 ms

Its a mouse macro that is directly saved to the mouse.

These are my translations:

LeftDown 1
send, {Lbutton down}

Delay 56 ms
Sleep, 56

MoveR -1 4
DllCall("mouse_event", uint, 1, int, -1, int, 4, uint, 0, int, 0)

LeftUp 1
send, {Lbutton up}

The above help from Ohnitiel was great, and that weapon fires with some accuracy, but this scripts has quiet a few corrections on recoil but the sleep times are consistent.

I wondered if someone would have the time to point me in the right direction, the aim:

To only run when the LMB is pressed
To stop when the LMB is not pressed
To use the corrected mouse recoil movements.

Many thanks chaps.

Ahoy.