One button to +1 number

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
greg111
Posts: 9
Joined: 29 Apr 2017, 14:21

One button to +1 number

29 Apr 2017, 14:34

I have keyboard Microsoft sidewinder x4, the keyboard support "macro keys". I want (in to notepad) use ONE button to write +1 (for example one press: 1, next press: 2, ...)
eduardoblu
Posts: 19
Joined: 28 Apr 2017, 18:54

Re: One button to +1 number

29 Apr 2017, 17:04

Code: Select all

1::
IfWinActive, Untitled - Notepad
{
send, %number%
NUMBER += 1
}
greg111
Posts: 9
Joined: 29 Apr 2017, 14:21

Re: One button to +1 number

30 Apr 2017, 02:31

Sorry but I am beginner ;) If I press 1 nothing happen
neomulemi6
Posts: 216
Joined: 30 Jun 2016, 06:01

Re: One button to +1 number

30 Apr 2017, 07:36

There are 3 problems with eduardo's script. First, he didn't use the $ prefix to keep the hotkey from triggering itself, meaning it would start at 2, second he initiated the number variable after the first send, third he assumed the title of your notepad window was "Untitled - Notepad" when it usually won't be.

This should work.

Code: Select all

$1::
number++
send % number
Return
eduardoblu
Posts: 19
Joined: 28 Apr 2017, 18:54

Re: One button to +1 number

30 Apr 2017, 15:17

Thanks, I was too lazy indeed, just copied straight from WinActive article and made some changes, sorry.

intentions were good
neomulemi6 wrote:There are 3 problems with eduardo's script. First, he didn't use the $ prefix to keep the hotkey from triggering itself, meaning it would start at 2, second he initiated the number variable after the first send, third he assumed the title of your notepad window was "Untitled - Notepad" when it usually won't be.

This should work.

Code: Select all

$1::
number++
send % number
Return
greg111
Posts: 9
Joined: 29 Apr 2017, 14:21

Re: One button to +1 number

30 Apr 2017, 16:55

Thanks for advice.
One more question. I select some text , now I paste them (in correct place) by click cursor + "paste".Is possible to copy PASTE them immediately after click without function key "paste"?
Last edited by greg111 on 01 May 2017, 02:41, edited 1 time in total.
eduardoblu
Posts: 19
Joined: 28 Apr 2017, 18:54

Re: One button to +1 number

30 Apr 2017, 18:42

!=Alt
^=Control
+=Shift

https://autohotkey.com/docs/misc/Clipboard.htm

Code: Select all

send, ^c ;copy
send, ^v ;paste
greg111
Posts: 9
Joined: 29 Apr 2017, 14:21

Re: One button to +1 number

01 May 2017, 02:48

I made a mistake, I want paste previously selected text when I click LBmouse
I found code:

Code: Select all

~LButton:: ; Make the left mouse button a hotkey, but allow it to function as normal.
MouseGetPos, xA, yA
loop ; Begin a loop.
{
	Sleep, 10 ; Wait 10 milliseconds.
	GetKeyState, LButton_state, LButton, P ; Check on the status of the left mouse button.
	if LButton_state = U ; If the left mouse button has been released.
	{	
		MouseGetPos, xB, yB
		Transform, xA, abs, %xA% ; Return the absolute value of xA.
		Transform, xB, abs, %xB%
		Transform, yA, abs, %yA%
		Transform, yB, abs, %yB%
		xDiff = 0
		xDiff += %xA%	; Add xA to xDiff.
		xDiff -= %xB%	; Subtract xA from xDiff.
		Transform, xDiff, abs, %xDiff%
		yDiff = 0
		yDiff += %yA%
		yDiff -= %yB%
		Transform, yDiff, abs, %yDiff%
		diffSum = 0
		diffSum += %xDiff%
		diffSum += %yDiff%
		If diffSum > 10
		{
			Send, ^c ; Copy.
			clipboard = %clipboard%	; Convert the cliboard contents to plain text.
		}
		break
	}
}
return

MButton:: ; Make the middle mouse button a hotkey, and _don't_ allow it to function as normal.
send, ^v ; Paste
return
work fine but if I click MButton
I have script to copy but how paste by Left Button mouse
neomulemi6
Posts: 216
Joined: 30 Jun 2016, 06:01

Re: One button to +1 number

01 May 2017, 07:56

LButton::Send ^v

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: inseption86, mikeyww and 449 guests