Guest User

Untitled

a guest
Jan 10th, 2023
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn  ; Enable warnings to assist with detecting common errors.
  3. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  5.  
  6. #SingleInstance Force
  7.  
  8. Gui, Add, ListBox, vMyListBox r10 gRemoveDup, Red|Green|Blue|Red|Green|Green|Yellow|Red|Purple
  9. Gui, Add, Button, x+5 yp, Remove Duplicates
  10. Gui, Show, h200 w350, Remove Duplicates
  11.  
  12. RemoveDup:
  13.    Gui, Submit, NoHide
  14.     ; Create a variable to store the unique strings
  15.     unique_strings := []
  16.     Loop, % MyListBox.MaxIndex()
  17.     {
  18.         string := MyListBox[A_Index]
  19.         string:=StringLower (string)
  20.         ; Check if the current string is not already in the array
  21.         if (!unique_strings.HasKey(string))
  22.         {
  23.             ; If not, add it to the array
  24.             unique_strings[string] := true
  25.         }
  26.     }
  27.     ; Clear the list box
  28.     GuiControl, , MyListBox,
  29.     ; Loop through the array and add all the unique strings back to the list box
  30.     Loop, % unique_strings.MaxIndex()
  31.     {
  32.         GuiControl, , MyListBox, % A_Index
  33.     }
  34. return
  35.  
  36. GuiClose:
  37. ExitApp
  38.  
  39.  
  40. Gui, Show, h200 w350, Remove Duplicates
Advertisement
Add Comment
Please, Sign In to add comment