Page 1 of 2

Re: I want a script

Posted: 03 Sep 2021, 09:12
by mikeyww

Code: Select all

F1::
SetTimer, Go, % (on := !on) ? 2 : "Off"
SoundBeep, 1000 + 500 * on ; OK to delete
Return
Go:
MouseMove, 9000, 0,, R
Return

Re: I want a script

Posted: 03 Sep 2021, 09:52
by mikeyww
Test it in Notepad. You can adjust the numbers if needed. A mouse does not turn. It can just move from one coordinate to another. This script moves the mouse to the right of its current location.

Re: I want a script

Posted: 03 Sep 2021, 10:07
by mikeyww
I do not have a way to troubleshoot your game. What this script does: when you press F1, it moves the mouse to the right as fast as possible until you press F1 again.

Re: I want a script

Posted: 03 Sep 2021, 10:38
by mikeyww

Code: Select all

F3::
SetTimer, Go, % (on := !on) ? 250 : "Off"
SoundBeep, 1000 + 500 * on ; OK to delete
Return
Go:
MouseMove, 100, 0,, R
Return

Re: I want a script

Posted: 03 Sep 2021, 11:44
by mikeyww
Teleporting is a game construct that AHK does not know. This script moves the mouse. Confirm that by testing it in Notepad.

Re: I want a script

Posted: 03 Sep 2021, 14:04
by mikeyww
Describe what the script should do. Please include an example.

Re: I want a script

Posted: 04 Sep 2021, 06:55
by mikeyww
The posted scripts will move the mouse if you press the hotkey first to start the action. When you try that in Notepad, does it work?

Re: I want a script

Posted: 04 Sep 2021, 09:41
by mikeyww
When you tested my script in Notepad, did it work?

Re: I want a script

Posted: 04 Sep 2021, 11:11
by mikeyww
I see no testing yet, just requests for more scripts and reading. If all of those statements are the same, you can simply put a single iteration of the command set into a short loop. That will save about 188,000 of the lines. The script is not especially helpful for a couple of reasons. The first is that the GetKeyState is assessed instantaneously when the script is run. The second is that key_shoot is undefined.

Re: I want a script

Posted: 04 Sep 2021, 12:18
by mikeyww
Here is an example that you can adapt.

Code: Select all

#InstallKeybdHook
F3::
While GetKeyState(A_ThisHotkey, "P") {
 DllCall("mouse_event", "UInt", 2, "Int", 0, "Int", 0, "UInt", 0, "Int", 0)
 Sleep, 0
 DllCall("mouse_event", "UInt", 4, "Int", 0, "Int", 0, "UInt", 0, "Int", 0)
 SoundBeep, 1500
}
Return
These calls are not necessarily correct. I just copied them.

Re: I want a script

Posted: 05 Sep 2021, 07:05
by mikeyww
MouseMove seems like a good option, no?

Re: I want a script

Posted: 05 Sep 2021, 08:58
by mikeyww
As you know, a mouse move is not a mouse drag. AHK does have a drag command. See MouseClickDrag.

Re: I want a script

Posted: 05 Sep 2021, 10:26
by mikeyww
Sure. Here it is.

viewtopic.php?p=418861#p418861

Change F3 to F4.

Test in Notepad. Report the results from Notepad testing here.

Re: I want a script

Posted: 05 Sep 2021, 13:28
by mikeyww
I thought that this question had been answered: "I want a script, when I press a key, it should turn the mouse straight to the right as fast as possible until I press that key again. Can you provide such a script?" Nonetheless, at the bottom of page 2, I have still failed to solve your problem. It's time for others to take over, to provide you with the answer. Best wishes.

Re: I want a script

Posted: 05 Sep 2021, 14:26
by mikeyww
OK. I'm not sure if you are trying to block the mouse, but BlockInput might do it. You can try it.

Re: I want a script

Posted: 06 Sep 2021, 08:10
by mikeyww
Here is a variant that may help. Test it in Notepad. What the script does: moves the mouse straight to the right at a certain speed until I press that key again when I press the F4 key as if I were just moving the mouse.

Code: Select all

#MaxThreadsPerHotkey 2
F4::
on := !on
BlockInput, MouseMove
While on
 MouseMove, 30, 0,, R
BlockInput, MouseMoveOff
Return

Re: I want a script

Posted: 06 Sep 2021, 09:12
by mikeyww
I tried. I hope that others will know a better way!

Re: I want a script

Posted: 06 Sep 2021, 10:09
by mikeyww
I'm glad that you have a solution. To add a hotkey, you can use the approach from my last post. Instead of the mouse move, you can insert your actions in a set of braces.

Re: I want a script

Posted: 06 Sep 2021, 10:28
by mikeyww
You can use GetKeyState() to get a key's state. Example

Re: I want a script

Posted: 06 Sep 2021, 10:40
by mikeyww
I don't think that I can be helpful beyond the various examples and other notes that I have already posted. I see that your last script already contains the GetKeyState function. If your script does not work, then my advice is to shorten the script so that you can test just a few essential lines. After you have them working, you can expand from there. GetKeyState is an instantaneous check. Best of luck. In response to your post, entitled, "I want a script", below is a summary of the examples that I provided in this thread.

1. An example of how a hotkey can be used with "While" in a toggle manner.
2. An example of how a hotkey can be used with GetKeyState, so that you can hold a hotkey to repeat actions.
3. An example of how a hotkey can be used to toggle a timed routine to move the mouse.
4. An example of how to block manual mouse movements.