Alphabetische Sortierung eines DropDown Mnu

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Alphabetische Sortierung eines DropDown Mnu

Re: Alphabetische Sortierung eines DropDown Mnu

Post by just me » 22 May 2019, 04:12

Moin,

die Veränderung der Auswahl mit den Pfeiltasten sendet kein Enter/Return. Dein G-Label wird aber aufgerufen, und wenn Du darin bedingungslos Aktionen ausführst, wird die neue Auswahl sofort verarbeitet.

Wenn Du die Verarbeitung an Enter koppeln willst, kannst Du die Auswahl nicht mehr direkt im G-Label verarbeiten. Du musst die Verarbeitung der Änderung verzögern, bis die Enter-Taste gedrückt wird. Um das Ganze möglichst einfach zu halten, schlage ich Folgendes vor:

Code: Select all

#NoEnv
Liste =
(Join|
BRA - SternBra IT relevant
BST - Push Auftrag im MP
Datum - To_Date
RES - Pickliste zurück in System
DRUCKER - Zugewiesene
DRUCKER - (alt)Zuweisen
DRUCKER - Zuweisung löschen
...
)
Choice := ""
Gui, Add, ListBox, gAction vChoice hwndHLB w300 h100 Sort, %Liste%
Gui, Add, Edit, wp hp vEdit, For testing ...
Gui, Show, , Test
Return

GuiClose:
ExitApp

Action:
GuiControlGet, Choice ; hier nur die neue Auswahl auslesen
Return

#If GuiControlHasFocus(1, "Choice") ; der Hotkey ist nur aktiv, wenn die ListBox den Eingabefokus hat
Enter::
   ToolTip, You pressed Enter for %Choice% ; hier wird die neue Auswahl verarbeitet
Return
#If

GuiControlHasFocus(Gui, GuiControl) {
   GuiControlGet, Focused, %Gui%:FocusV
   Return (Focused = GuiControl) ? True : False
}

Re: Alphabetische Sortierung eines DropDown Mnu

Post by Dosenbrot » 22 May 2019, 02:58

Ha, jetzt hab ich doch noch ne Frage ...

Ich würde gern innerhalb der ListBox mit Pfeiltasten navigieren und mit Enter ausführen

Aktuell ist es aber so, dass wenn ich Pfeil runter(down) drücke, der cursor eine n Eintrag hinuntergeht und direkt den Eintrag ausführt.
Wie kann ich das unterbinden, das ein Return(Enter) gesendet wird?


Danke euch :)

Re: Alphabetische Sortierung eines DropDown Mnu

Post by Dosenbrot » 21 May 2019, 09:41

just me wrote:
21 May 2019, 06:48
Moin,

was genau ist denn Dein Problem?

Wenn ich das überzählige Komma vor der Sort Option entferne, sieht das für mich alphabetisch sortiert aus.

Code: Select all

Gui, Add, ListBox, gAction vChoise w300 h100 Sort, BRA - SternBra IT relevant|BST - Push Auftrag im MP|Datum - To_Date|RES - Pickliste zurück in System|DRUCKER - Zugewiesene|DRUCKER - (alt)Zuweisen|DRUCKER - Zuweisung löschen|...

Wie geil ^^
ich habe es einfach nicht gesehen xD

Danke euch für die schnelle Hilfe :)

Re: Alphabetische Sortierung eines DropDown Mnu

Post by just me » 21 May 2019, 06:48

Moin,

was genau ist denn Dein Problem?

Wenn ich das überzählige Komma vor der Sort Option entferne, sieht das für mich alphabetisch sortiert aus.

Code: Select all

Gui, Add, ListBox, gAction vChoise w300 h100 Sort, BRA - SternBra IT relevant|BST - Push Auftrag im MP|Datum - To_Date|RES - Pickliste zurück in System|DRUCKER - Zugewiesene|DRUCKER - (alt)Zuweisen|DRUCKER - Zuweisung löschen|...

Re: Alphabetische Sortierung eines DropDown Mnu

Post by jNizM » 21 May 2019, 04:38

z.B.:

Code: Select all

SortArray(ListBoxArray := ["Birne", "Pflaume", "Apfel", "Traube", "Orange"])

for k, v in ListBoxArray
	MeineListBox .= v "|"


Gui, Add, ListBox, w200 h100, % MeineListBox
Gui, Show, w300 h300
return


GuiClose:
ExitApp


SortArray(Array, Order := "A") ; https://sites.google.com/site/ahkref/custom-functions/sortarray
{
    ;Order A: Ascending, D: Descending, R: Reverse
    MaxIndex := ObjMaxIndex(Array)
    if (Order = "R") {
        count := 0
        loop % MaxIndex 
            ObjInsert(Array, ObjRemove(Array, MaxIndex - count++))
        return
    }
    Partitions := "|" ObjMinIndex(Array) "," MaxIndex
    loop {
        comma := InStr(this_partition := SubStr(Partitions, InStr(Partitions, "|", False, 0)+1), ",")
        spos := pivot := SubStr(this_partition, 1, comma-1) , epos := SubStr(this_partition, comma+1)    
        if (Order = "A") {    
            loop % epos - spos {
                if (Array[pivot] > Array[A_Index+spos])
                    ObjInsert(Array, pivot++, ObjRemove(Array, A_Index+spos))    
            }
        } else {
            loop % epos - spos {
                if (Array[pivot] < Array[A_Index+spos])
                    ObjInsert(Array, pivot++, ObjRemove(Array, A_Index+spos))    
            }
        }
        Partitions := SubStr(Partitions, 1, InStr(Partitions, "|", False, 0)-1)
        if (pivot - spos) > 1    ;if more than one elements
            Partitions .= "|" spos "," pivot-1        ;the left partition
        if (epos - pivot) > 1    ;if more than one elements
            Partitions .= "|" pivot+1 "," epos        ;the right partition
    } until !Partitions
}

Alphabetische Sortierung eines DropDown Mnu

Post by Dosenbrot » 21 May 2019, 04:16

Hallo zusammen,

ich setzte mich gerade ganz frisch mit AHK auseinander.

Kurz zur Info vorab.

Was mache ich:

Ich schreibe gerade ein Script als eine Art SQL Snippet Datenbank

Über den shortcut ^F1 rufe ich eine DropBoxList auf und wähle dann das auszuführende SQL aus.
Da die Datei stetig wächst, und dadurch nicht mehr sortiert ist, möchte ich das ganze der Übersichthalber Alphabetisch sortieren.

Mit "Sort" komme ich aber leider nicht weiter

Gui, Add, ListBox, gAction vChoise w300 h100, Sort, BRA - SternBra IT relevant|BST - Push Auftrag im MP|Datum - To_Date|RES - Pickliste zurück in System|DRUCKER - Zugewiesene|DRUCKER - (alt)Zuweisen|DRUCKER - Zuweisung löschen|...


I need somebody Heelp :)

Danke euch vorab

Top