Hello I have a hearing on how to make:

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Magija
Posts: 21
Joined: 21 Aug 2021, 06:29

Hello I have a hearing on how to make:

Post by Magija » 18 Sep 2021, 14:26

Hello I have a hearing on how to make:

1."Sleep" from "1000" to "2000" random number from 1000-2000

2. how to make a script ignore keys other than selected. eg F1 ::
Send "Hello" but when I hold some other key together the script doesn't work.
Ianizer
Posts: 79
Joined: 07 Mar 2021, 00:06

Re: Hello I have a hearing on how to make:

Post by Ianizer » 18 Sep 2021, 19:03

The random duration Sleep part is quite simple:

Code: Select all

Random, RandomNumber, 1000, 2000
Sleep, RandomNumber
As for a hotkey not running if other keys are held, I'm not sure that it is (efficiently) possible. The only way I can think of doing this is very inefficient:

Code: Select all

$F1::
	if (!AnyKeyIsHeldDown("F1"))
		Send, {F1 Down}
~F1 Up::return ;This hotkey definiton acts as the $F1 hotkey's return. One line saved! (The ~F1 Up hotkey is necessary to release the key. Using KeyWait then releasing F1 with Send would disable auto-repeated keystrokes for the key, so I decided against it.)

AnyKeyIsHeldDown(KeyToExclude := "")
{
	SetBatchLines, -1 ;so it doesn't take long to run
	KeyList := ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "``", "-", "=", "[", "]", "`;", "'", "\", "`,", ".", "/", "CapsLock", "Space", "Tab", "Enter", "Escape", "Backspace", "Up", "Down", "Right", "Left", "ScrollLock", "Delete", "Insert", "Home", "End", "PgUp", "PgDn", "Numpad0", "Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9", "NumpadDot", "NumLock", "NumpadDiv", "NumpadMult", "NumpadAdd", "NumpadSub", "NumpadEnter", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24", "LWin", "RWin", "LControl", "RControl", "LShift", "RShift", "LAlt", "RAlt", "Browser_Back", "Browser_Forward", "Browser_Refresh", "Browser_Stop", "Browser_Search", "Browser_Favorites", "Browser_Home", "Volume_Mute", "Volume_Down", "Volume_Up", "Media_Next", "Media_Prev", "Media_Stop", "Media_Play_Pause", "Launch_Mail", "Launch_Media", "Launch_App1", "Launch_App2", "AppsKey", "PrintScreen", "CtrlBreak", "Pause", "Help", "Sleep"]
	Loop, % KeyList.MaxIndex() + 1
	{
		if (KeyList[A_Index] != KeyToExclude)
		{
			if (GetKeyState(KeyList[A_Index]))
				break
			LoopIterationBrokenAt := A_Index
		}
	}
	if (LoopIterationBrokenAt = KeyList.MaxIndex() + 1)
		return 0
	else
		return 1
}
I may have misunderstood you, so be sure to post if I did.
Rohwedder
Posts: 7510
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Hello I have a hearing on how to make:

Post by Rohwedder » 19 Sep 2021, 00:44

Hallo,
2. how to make a script ignore keys other than selected. eg F1 ::
Send "Hello" but when I hold some other key together the script doesn't work.

Code: Select all

F1::Send,% "Hello "
F2::Send,% "World "
What should be written to a notepad window when the 3 keys F1+F2+Q are held down?
Magija
Posts: 21
Joined: 21 Aug 2021, 06:29

Re: Hello I have a hearing on how to make:

Post by Magija » 19 Sep 2021, 02:20

when i hold other keys and press F1 :: the system doesn't work, but as soon as i release the other keys and press f1 :: the system works, how should i make the system work while holding the other keys.
Rohwedder
Posts: 7510
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Hello I have a hearing on how to make:

Post by Rohwedder » 19 Sep 2021, 02:51

"the system doesnt work" means it doesnt happen exactly what you want. In order to help you, you should define what you want to happen!!
Post Reply

Return to “Ask for Help (v1)”