Making a script function without needing to press a key several times? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Jason Brown

Making a script function without needing to press a key several times?

21 May 2018, 19:26

Hello everyone,

I'm sorry for asking a question that's been asked a million times before, or asking a question that's easy to answer. It feels absurd that I need to apologize for asking a question, but oh well, this is the internet.
I'm attempting to create something that (with the press of only one button such as F9) will move to a part of my screen, left click, move to another part, shift + left click, and repeat.
I somewhat understand the basic components and have them ready to go, but there lies a problem with my code, and it is that I must press the chosen key to start up production (Page Up for me) for every step!
Here is a little example of what I mean.

Code: Select all

PgUp::
    MouseMove, 1284, 505
         ^LButton::Click 1 left
           {Sleep 100}
	     MouseMove, 2376,770
return

Escape::
ExitApp
Return
All I'm trying to do in this sample is have it preform those three actions (movemouse, left click, movemouse) at the press of one button, Page Up. Instead, I'm being forced to press Page Up for every step.
Does anyone have a possible solution for this?

Additionally, if any part of this script is wrong or could be improved/cleaned, please, please, please let me know. I honestly have no idea what I'm doing and feel like I've been cast into deep water and told to swim.
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Making a script function without needing to press a key several times?

21 May 2018, 22:20

This assumes that your code as-is is correct and works.

It also assumes that this is all your script is doing. If you have other hotkeys etc you will need another approach.

Code: Select all

#SingleInstance,Force
Pause,On
Loop 
	{
		;replace the tooltip with your code
		tooltip,% A_Index
	}

return

pgup::Pause

ESC::ExitApp
chthonicastro
Posts: 8
Joined: 21 May 2018, 04:47

Re: Making a script function without needing to press a key several times?  Topic is solved

22 May 2018, 06:30

What you are asking for is slightly different than what you appear to have written. Is this a click and drag, or a click+unclick, move, and click again?

You should actually Send discrete mouselicks, rather than having one hotkey call another hotkey that is activated by the mouseclick, as your script currently does. Try:

Code: Select all

PgUp::

	Click, 1284, 505		;you can also format this as Send {click, 1284, 505} like in the last step
	Sleep 100
	Send +{Click, 2376, 660}

return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: hedehede81 and 280 guests