From ab6f0a2ca95e1b273f0ca0c709752dd0debc158c Mon Sep 17 00:00:00 2001 From: Alexander Naumann Date: Mon, 18 Jan 2021 18:23:44 +0100 Subject: [PATCH 1/2] ADD option to open folders by name (specified in folders.csv) --- GUI/GUI.ahk | 57 +++++++++++++++++++++++++++++++++++++++ GUI/UserCommands.ahk | 12 ++++++++- Miscellaneous/folders.csv | 3 +++ README.md | 3 ++- 4 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 Miscellaneous/folders.csv diff --git a/GUI/GUI.ahk b/GUI/GUI.ahk index fb04a22..fdbe802 100644 --- a/GUI/GUI.ahk +++ b/GUI/GUI.ahk @@ -63,6 +63,7 @@ gui_spawn: ; Automatically triggered on Escape key: GuiEscape: gui_destroy() + search_urls := 0 return ; The callback function when the text changes in the input field. @@ -122,6 +123,41 @@ gui_search_add_elements: Gui, Show, AutoSize return +gui_project_search_add_elements: + Gui, Add, Text, %gui_control_options% %cYellow%, %gui_search_title% + Gui, Add, Edit, %gui_control_options% %cYellow% vList -WantReturn + Gui, Add, Button, x-10 y-10 w1 h1 +default ggui_find_and_open_folder ; hidden button + GuiControl, Disable, Pedersen + Gui, Show, AutoSize + return + +gui_find_and_open_folder: + OnSelect: + Gui, Submit, nohide + gui_destroy() + ;Parse a comma separated value (CSV) file: + Loop, read, %A_ScriptDir%\Miscellaneous\folders.csv + { + LineNumber = %A_Index% + Loop, parse, A_LoopReadLine, CSV + { + ; save all column values to Field1, Field2, ... + Field%A_Index% := A_LoopField + } + If (Field1 == List) + { + folder = %Field2% + Loop, %search_urls% + { + StringReplace, search_final_url, search_url%A_Index%, REPLACEME, %folder% + run %search_final_url% + } + search_urls := 0 + return + } + } + return + gui_search(url) { global if gui_state != search @@ -151,6 +187,27 @@ gui_SearchEnter: search_urls := 0 return +gui_projectsearch(url) { + global + if gui_state != search + { + gui_state = search + ; if gui_state is "main", then we are coming from the main window and + ; GUI elements for the search field have not yet been added. + Gosub, gui_project_search_add_elements + + } + + ; Assign the url to a variable. + ; The variables will have names search_url1, search_url2, ... + + search_urls := search_urls + 1 + search_url%search_urls% := url +} + + + + ;------------------------------------------------------------------------------- ; TOOLTIP ; The tooltip shows all defined commands, along with a description of what diff --git a/GUI/UserCommands.ahk b/GUI/UserCommands.ahk index 5fecfd1..15ae73e 100644 --- a/GUI/UserCommands.ahk +++ b/GUI/UserCommands.ahk @@ -48,7 +48,7 @@ else if Pedersen = x%A_Space% ; Search Google as Incognito ;------------------------------------------------------------------------------- ;;; SEARCH OTHER THINGS ;;; ;------------------------------------------------------------------------------- -else if Pedersen = f%A_Space% ; Search Facebook +else if Pedersen = fb%A_Space% ; Search Facebook { gui_search_title = Search Facebook gui_search("https://www.facebook.com/search/results.php?q=REPLACEME") @@ -134,6 +134,11 @@ else if Pedersen = rel ; Reload this script gui_destroy() ; removes the GUI even when the reload fails Reload } +else if Pedersen = flist ; show CSV with folders +{ + gui_destroy() + run, notepad.exe "%A_ScriptDir%\Miscellaneous\folders.csv" +} else if Pedersen = dir ; Open the directory for this script { gui_destroy() @@ -204,6 +209,11 @@ else if Pedersen = rec ; Recycle Bin gui_destroy() Run ::{645FF040-5081-101B-9F08-00AA002F954E} } +else if Pedersen = f%A_Space% ; Open local folder +{ + gui_search_title = Find local folder + gui_projectsearch("REPLACEME") +} ;------------------------------------------------------------------------------- diff --git a/Miscellaneous/folders.csv b/Miscellaneous/folders.csv new file mode 100644 index 0000000..29ef3b4 --- /dev/null +++ b/Miscellaneous/folders.csv @@ -0,0 +1,3 @@ +c,C:\ +programs,C:\Program Files +programsx,C:\Program Files (x86) \ No newline at end of file diff --git a/README.md b/README.md index e64b59b..6035749 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,11 @@ When typing something in the GUI, whatever you type is matched up against the co * While in Notepad, type `@` into the GUI. It will write your e-mail address (but you need to go into `UserCommands.ahk` later to specify your own address). * Try typing `down` into the GUI to open your Downloads folder or `rec` to open the Recycle Bin. * You can search google by typing `g` followed by a space. A new input field should appear. Type your search query and press enter. Use `l ` if you are 'Feeling Lucky'. -* You can search Youtube with `y `, search Facebook with `f ` or the torrent networks with `t `. +* You can search Youtube with `y `, search Facebook with `fb ` or the torrent networks with `t `. * If you like Reddit, you can visit a specific subreddit by typing `/` into the GUI and then the name of the subreddit you have in mind. * Try `week` or `date`. (I can never remember the week number so this is useful when on the phone with somebody who insists on comparing calendars going by week number). * Type `ping` into the GUI to quickly ping www.google.com to see if your internet connection works. +* Type `f ` to enter the name of a folder that should be opened (definition in [`folders.csv`](./Miscellaneous/folders.csv)) There are some additional example commands included. Try typing simply `?`, and you should see a tooltip with all defined commands and a description of what they do. You may also explore all the sample commands in detail by looking in `UserCommands.ahk`. Now it is time for you to start filling in your own personalized commands. From 8f260c7e516df1ab5d51b5acb63ba31044d100ee Mon Sep 17 00:00:00 2001 From: Alexander Naumann Date: Fri, 22 Jan 2021 09:06:54 +0100 Subject: [PATCH 2/2] FIX issue with resetting the search URLs --- GUI/GUI.ahk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GUI/GUI.ahk b/GUI/GUI.ahk index fdbe802..1a38e63 100644 --- a/GUI/GUI.ahk +++ b/GUI/GUI.ahk @@ -46,6 +46,7 @@ gui_spawn: } gui_state = main + search_urls := 0 Gui, Margin, 16, 16 Gui, Color, 1d1f21, 282a2e @@ -63,7 +64,6 @@ gui_spawn: ; Automatically triggered on Escape key: GuiEscape: gui_destroy() - search_urls := 0 return ; The callback function when the text changes in the input field.