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)
}
Help me improve the script.
Re: Help me improve the script.
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.
Re: Help me improve the script.
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.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
Re: Help me improve the script.
Oh okay so you want the cursor to move to the center, once, when you click lbutton?Novelty1 wrote: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.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
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.
Re: Help me improve the script.
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.Nwb wrote:Oh okay so you want the cursor to move to the center, once, when you click lbutton?Novelty1 wrote: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.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
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
Re: Help me improve the script.
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.
Who is online
Users browsing this forum: nebber and 41 guests