Find in Combobox get or select item

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Find in Combobox get or select item

16 Aug 2018, 08:39

When I enter a letter from the keyboard while in the ComboBox,
for example,

When I write the word "CAR" in the ComboBox, it will find the word "CAR".
When I write the word "CAR 90" in the ComboBox, it will find the word "CAR 90".

that is, the keyboard entries made in the ComboBox, from within the ComboBox.

Code: Select all

#NoTrayIcon
brafs:="APLLE|BANANA|CRANBERRIES|WATERMELOON|PEACE|CHERY|CAR|CAR 1|CAR 2|CAR 20|CAR 31|CAR 90|CAR 97|ELEPHANT|DUNKEY|MONKEY"
Gui, Add, ComboBox, x32 y30 w140 h90 vCOMBO1 , % brafs
Gui, Add, DropDownList, x192 y30 w130 h90 vDROP1 , % brafs

Gui, Show, w392 h161, Untitled GUI
return

GuiClose:
ExitApp
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Re: Find in Combobox get or select item

17 Aug 2018, 03:13

I would like to ask specialist friends who can help. It's a bit urgent because ...
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Find in Combobox get or select item

17 Aug 2018, 19:44

Hi.
How about this solution?

Code: Select all

#NoTrayIcon
brafs:="APLLE|BANANA|CRANBERRIES|WATERMELOON|PEACE|CHERY|CAR|CAR 1|CAR 2|CAR 20|CAR 31|CAR 90|CAR 97|ELEPHANT|DUNKEY|MONKEY"
Gui, Add, ComboBox, hwndCOMBO1ID x32 y30 w140 h90 vCOMBO1 gCombo1, % brafs
Gui, Add, DropDownList, x192 y30 w130 h90 vDROP1 , % brafs

Gui, Show, w392 h161, Untitled GUI
return

GuiClose:
ExitApp


COMBO1: 
{
	ControlGetText, Eingabe,, ahk_id %Combo1ID%
	ControlGet, Liste, List, , , ahk_id %Combo1ID%
	If ( !GetKeyState("Delete") && !GetKeyState("BackSpace") && RegExMatch(Liste, "`nmi)^(\Q" . Eingabe . "\E.*)$", Match)) {
	ControlSetText, , %Match%, ahk_id %Combo1ID%
	Selection := StrLen(Eingabe) | 0xFFFF0000
	SendMessage, CB_SETEDITSEL := 0x142, , Selection, , ahk_id %Combo1ID%
	} Else {
	CheckDelKey = 0
	CheckBackspaceKey = 0
	}
return
}
EDIT: 2020.04.19 - I've included superior suggestion from A_AhkUser. See below for reasons.
Last edited by divanebaba on 19 Apr 2020, 08:38, edited 1 time in total.
Einfach nur ein toller Typ. :mrgreen:
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Re: Find in Combobox get or select item

20 Aug 2018, 12:35

[quote="divanebaba"]Hi.
How about this solution?

Code: Select all

#NoTrayIcon
[/quote]

The solution is pretty good. it does not allow backward deletion with backspace key alone. I can write and delete the data in the combo. I can intervene in the combo. While in the combo, filter out the data in the ComboBox if you press any key on the keyboard. I can do it in the delete process with the backspace key.

thanks in advance for your help ..
Divanebaba Kurban bayramın mübarek olsun abi.. Saygılar :)
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Find in Combobox get or select item

20 Aug 2018, 20:16

Thanks, chngrcn.
I'm sorry not responding to your PM last time.

I've created a new method for storing huge amounts of metal and plastic strips and have learned how to create patent papers.
Now my method is patent pending.
It will replace most of common strip accumulators for rollforming pipes and profiles, made from steel.
If I find a financial strong buyer, I will buy this forum and its members too. :HeHe: :HeHe:
DRAWING_011_klein.jpg
(98.68 KiB) Downloaded 111 times
Not to bad - newest technology. Patent priority for sale. Contact as fast as you can worlds most intelligent fool.
Einfach nur ein toller Typ. :mrgreen:
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Find in Combobox get or select item

21 Aug 2018, 14:46

chngrcn wrote:it does not allow backward deletion with backspace key alone.
Just for reference:

Code: Select all

If ( !CheckDelKey && !CheckBackspaceKey && RegExMatch(Liste, "`nmi)^(\Q" . Eingabe . "\E.*)$", Match) ){
should be:

Code: Select all

If ( !GetKeyState("Delete") && !GetKeyState("BackSpace") && RegExMatch(Liste, "`nmi)^(\Q" . Eingabe . "\E.*)$", Match)) {
The solution is pretty good
my scripts
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Find in Combobox get or select item

21 Aug 2018, 16:43

Hello A_AhkUser.

The sample was a code, I found years ago in this forum.
I've tested your optimization and now it works much better, maybe perfect.
It is so convincing, that I immediately have replaced this part of code in my used scripts. :mrgreen: :mrgreen:

:salute: Respect and thanks for sharing your excellent knowledge.
Einfach nur ein toller Typ. :mrgreen:
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Find in Combobox get or select item

21 Aug 2018, 20:33

divanebaba wrote: I've tested your optimization and now it works much better, maybe perfect.
It is so convincing, that I immediately have replaced this part of code in my used scripts. :mrgreen: :mrgreen:
Really?! I thought it was simply a typo from your part. I can only guess that years ago you simply copy-pasted it without trying to decrypt it. But you have no excuses: the one who wrote it even made an effort to give an explicit name to its variables: CheckDelKey, CheckBackspaceKey... :terms: :mrgreen: Well, I'm glad I could help :D

Thanks again for sharing this code ;)

Cheers
my scripts

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: AlFlo and 220 guests