Page 1 of 1

Another mouse movement blocking script.

Posted: 30 Mar 2023, 22:50
by handen
Before I introduce myself with this awful thread just let me say that I have already searched the forum, and I do see that there is a very similar thread already posted today of all days asking a very similar question. With that out of the way, I still haven't quite figured it out, so I'm posting this thread rather than replying to that other one to see what kind of response it gets as I continue actively reading for what I'm looking for.

I want to set a hotkey that disables only mouse movement (both axis simultaneously), but only while that hotkey is being held down. When that hotkey is let go, mouse movement resumes. I want this to work in War Thunder, so that I can map that hotkey to a button on my Logitech G600 mouse so that I don't have to lift the mouse off of the surface of the table to relocate it. It's a heavy, touchy mouse, and the act of modifying my grip to lift it from the table changes my finger position just enough to be a pain in the ass. Hence why I would prefer to map a hotkey to disable movement input while I slide the mouse across the table, basically emulating lift-off without having to lift the mouse.

This is what I've got. I'm using F13 because it's an easy hotkey variable with no other key mappings. This script works in Explorer, which is nice insofar as it means I'm not completely inept, but it DOESN'T work inside of War Thunder, which is my next big hurdle to grasp here, and I guess where I'm hoping your suggestions might come in handy.

Code: Select all

^Esc::ExitApp

#If GetKeyState("F13", "T")
	F13::BlockInput, MouseMove
		return
#If GetKeyState("F13", "T")
	F13 Up::BlockInput, MouseMoveOff
		return

Aside from the kill command I can't claim to fully understand it, though. "If F13 is toggled down, block mouse movement, return. If F13 is toggled up, unblock mouse movement, return"? Intuitively it would seem that "BlockInputOff, MouseMove" would make more sense syntactically, no? So what's the deal with the "off" suffix on "MouseMove"? It disables the hyperlink to the official doc, so I have to assume there's some sort of morphological aspect to AHK coding that I've yet to encounter that also breaks the forum's auto hotlink functionality? Or am I completely off-base here?

The last time I coded anything was ten years ago and in SuperCollider, so forgive my ineptitude. I'll be reacquainting myself with the basics of coding in short order, but for now all I can do is ask for your leniency.

Any advice would be swell as I continue trawling previous posts and the official docs. Thanks.


[Mod action: Moved topic to v1 section. The main section is for v2.]

Re: Another mouse movement blocking script.

Posted: 30 Mar 2023, 23:35
by boiler
You have more going on there than necessary. Extra returns, directives that aren't necessary. This won't affect why it's not working in a certain application. It might be because that is an elevated process, so this script needs to also run as an elevated process. See this FAQ answer. Try running it as administrator by right-clicking on the script file in File Explorer and selecting "Run as administrator".

Code: Select all

^Esc::ExitApp

F13::BlockInput, MouseMove

F13 Up::BlockInput, MouseMoveOff

By the way, you posted in the v2 section, and your code is v1, so I moved the thread to the v1 section.

Re: Another mouse movement blocking script.

Posted: 31 Mar 2023, 08:12
by RDC
Another option... by ChatGPT of all places. 1st time I've had anything actually work without having to modify it, using...
"AutoHotkey script to disable mouse movement in both axis simultaneously, but only while hotkey F1 is being held down?" as the search parameter.

Code: Select all

#NoEnv
#SingleInstance force

F1::
    BlockInput, MouseMove
    KeyWait, F1
    BlockInput, MouseMoveOff
return

Re: Another mouse movement blocking script.

Posted: 01 Apr 2023, 11:30
by handen
Thank you both, you've both helped me solve this. Running as admin allowed it to work in War Thunder, and even though I had previously used ChatGPT for generating goofy Seinfeld scripts, I never would have considered that it could write working code instantly.

Re: Another mouse movement blocking script.

Posted: 01 Apr 2023, 11:39
by boiler
handen wrote: … even though I had previously used ChatGPT for generating goofy Seinfeld scripts, I never would have considered that it could write working code instantly.
It may have worked in this case where it is essentially copying something relatively simple that has been posted before, but it usually writes very poor AHK code, often with made-up syntax and faulty logic. It is generally not allowed to be posted on this forum.

Re: Another mouse movement blocking script.

Posted: 01 Apr 2023, 12:15
by swagfag
disassemble ur mouse and take out the weights inside it lol