Help me improve the script.

Ask gaming related questions (AHK v1.1 and older)
Novelty1
Posts: 10
Joined: 25 Feb 2018, 03:10

Help me improve the script.

25 Feb 2018, 04:47

So i got a script, basically makes my cursor stays in 1 place. But after scripting the mouse did what i want but not perfect. The cursor moves from the center to the lower left side around the center. Anyone to help me fix the cursor to stays in the center but still does it's job. Below is the script i used.


#NoEnv
SendMode Input
~CapsLock::Suspend
Insert::ExitApp


~*$LButton::
Loop
{

GetKeyState, state, Lbutton, P
if state=u
break

mouseXY(-2,5)
sleep 1
mouseXY(2,-5)
sleep 1
}
return

mouseXY(x,y)
{
DllCall("mouse_event",int,1,int,x,int,y,uint,0,uint,0)
}
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Help me improve the script.

25 Feb 2018, 05:35

Try this. Should work exactly as you wanted it to. Click once to start centering and click again to stop. Capslock for suspend and insert for exit.

Code: Select all

#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.
#MaxThreadsPerHotkey 2

CoordMode, Mouse, Screen
Toggle := 0

~*$LButton::
Toggle := !Toggle
While Toggle
{
		Mousemove, (A_ScreenWidth//2), (A_ScreenHeight//2)
		Sleep 50
}
return

~CapsLock:: Suspend
Insert:: ExitApp
I am your average ahk newbie. Just.. a tat more cute. ;)
Novelty1
Posts: 10
Joined: 25 Feb 2018, 03:10

Re: Help me improve the script.

25 Feb 2018, 07:08

Nwb wrote:Try this. Should work exactly as you wanted it to. Click once to start centering and click again to stop. Capslock for suspend and insert for exit.

Code: Select all

#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.
#MaxThreadsPerHotkey 2

CoordMode, Mouse, Screen
Toggle := 0

~*$LButton::
Toggle := !Toggle
While Toggle
{
		Mousemove, (A_ScreenWidth//2), (A_ScreenHeight//2)
		Sleep 50
}
return

~CapsLock:: Suspend
Insert:: ExitApp
Thank you for the reply, it does what i want, but i wanted is when i hold left click, the cursor stays in that position/center. I'm able to move freely while while keeping my cursor centered. As an example, if im in a game i want to move my camera freely while holding that cursor in place.
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Help me improve the script.

25 Feb 2018, 07:28

Novelty1 wrote:
Nwb wrote:Try this. Should work exactly as you wanted it to. Click once to start centering and click again to stop. Capslock for suspend and insert for exit.

Code: Select all

#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.
#MaxThreadsPerHotkey 2

CoordMode, Mouse, Screen
Toggle := 0

~*$LButton::
Toggle := !Toggle
While Toggle
{
		Mousemove, (A_ScreenWidth//2), (A_ScreenHeight//2)
		Sleep 50
}
return

~CapsLock:: Suspend
Insert:: ExitApp
Thank you for the reply, it does what i want, but i wanted is when i hold left click, the cursor stays in that position/center. I'm able to move freely while while keeping my cursor centered. As an example, if im in a game i want to move my camera freely while holding that cursor in place.
Oh okay so you want the cursor to move to the center, once, when you click lbutton?

Does this work?

Code: Select all

#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.
#MaxThreadsPerHotkey 2

CoordMode, Mouse, Screen

~*$LButton::

		Mousemove, (A_ScreenWidth//2), (A_ScreenHeight//2)
		Sleep 50

return

~CapsLock:: Suspend
Insert:: ExitApp
I am your average ahk newbie. Just.. a tat more cute. ;)
Novelty1
Posts: 10
Joined: 25 Feb 2018, 03:10

Re: Help me improve the script.

26 Feb 2018, 06:20

Nwb wrote:
Novelty1 wrote:
Nwb wrote:Try this. Should work exactly as you wanted it to. Click once to start centering and click again to stop. Capslock for suspend and insert for exit.

Code: Select all

#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.
#MaxThreadsPerHotkey 2

CoordMode, Mouse, Screen
Toggle := 0

~*$LButton::
Toggle := !Toggle
While Toggle
{
		Mousemove, (A_ScreenWidth//2), (A_ScreenHeight//2)
		Sleep 50
}
return

~CapsLock:: Suspend
Insert:: ExitApp
Thank you for the reply, it does what i want, but i wanted is when i hold left click, the cursor stays in that position/center. I'm able to move freely while while keeping my cursor centered. As an example, if im in a game i want to move my camera freely while holding that cursor in place.
Oh okay so you want the cursor to move to the center, once, when you click lbutton?

Does this work?

Code: Select all

#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.
#MaxThreadsPerHotkey 2

CoordMode, Mouse, Screen

~*$LButton::

		Mousemove, (A_ScreenWidth//2), (A_ScreenHeight//2)
		Sleep 50

return

~CapsLock:: Suspend
Insert:: ExitApp
We're getting close, you helped me alot, but there is only one more thing i need. If you run the script i used originally, they cursor kinda shakes around from center to the other point, going back and again and again. All i need is to make that cursor shaking yet shakes to the center while holding Left Click Mouse. my point is to make the crusor shakes like the original script i used but just shakes in 1 point.
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Help me improve the script.

26 Feb 2018, 06:30

Like this??

Code: Select all

#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.
#MaxThreadsPerHotkey 2

CoordMode, Mouse, Screen

~*$LButton::
                Mousemove, (A_ScreenWidth//2), (A_ScreenHeight//2)
                Sleep 50
		Mousemove, (A_ScreenWidth//2+1), (A_ScreenHeight//2+1)
		Sleep 50
		Mousemove, (A_ScreenWidth//2), (A_ScreenHeight//2)
		Sleep 50

return

~CapsLock:: Suspend
Insert:: ExitApp
I am your average ahk newbie. Just.. a tat more cute. ;)

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: nebber and 41 guests