NoActivate for AHK context menu?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
The_One_True_Rick
Posts: 65
Joined: 25 May 2023, 17:14

NoActivate for AHK context menu?

Post by The_One_True_Rick » 30 May 2023, 14:13

Is there a NoActivate that works for context menus in AHK? Whenever I show the context menu it breaks focus from the current edit box i'm in and changes the active window and its messing up part of my script. I came up with a work around but just curious because a simple NoActivate like with GUIs would work better.

The_One_True_Rick
Posts: 65
Joined: 25 May 2023, 17:14

Re: NoActivate for AHK context menu?

Post by The_One_True_Rick » 31 May 2023, 10:08

Here is a little more info of what I'm trying to do:
I am using hotstrings to recognize text for prescription drug names. As a lot of them start with the same few letters it will have a context menu pop up to provide the potential choices for you to pick from. Issue is if you want to keep typing after the context menu pops up to widdle down the options more you cant because the context menu breaks focus from the control so you can no longer type. Works for the most part otherwise, Haven't added in the functionality to widdle down options if you type more than the first 4 letters yet because I have to solve the issue of not being able to type anymore once the menu comes up. Might be better off just making my own gui but the context menu would work so well. I want it to be like the menu that pops up in Scite that lets you keep typing but still shows you potential options to choose from. Here is my code so far.

Code: Select all

Drug_List =
(
Suboxone
Carisoprodol
Celecoxib
Celebrex
Codeine
Cyclobenzaprine
Diclofenac
Fentanyl
Hydrocodone
Hydrocodone/APAP
Ibuprofen
Indomethacin
Lidocaine
Meloxicam
Methadone
Methocarbamol
Morphine
Naproxen
Oxycodone
OxyContin
Pentosan
Elmiron
Sumatriptan
Tramadol
)


Loop, Parse, Drug_List, `n
	{
	NewStr := SubStr(A_LoopField, 1 , 3)
	Hotstring(":B0X*:" NewStr, "Spell_Menu")
	}

return

Spell_Menu:

Loop, Parse, Drug_List, `n
	{
	Menu, Spell, Add, %A_LoopField%, Type_Option
	}


Loop, Parse, Drug_List, `n
	{
	NewStr2 := RegExReplace(A_ThisHotkey, "(:X:)", "")
	if (NewStr2 ~= SubStr(A_LoopField, 1 , 3))
		Menu, Spell, Add, %A_LoopField%, Type_Option
	else
		Menu, Spell, Delete , %A_LoopField%
	}

Menu, Spell, Color, White
Menu, Spell, Show

return

Type_Option:
SendInput, %A_ThisMenuItem%

return
[Mod edit: [code][/code] tags added. Please use them yourself going forward.]

Post Reply

Return to “Ask for Help (v1)”