 ; Note: Save with encoding UTF-8 with BOM if possible.
 ; I had issues with special characters like in ¯\_(ツ)_/¯ that wouldn't work otherwise.
 ; Notepad will save UTF-8 files with BOM automatically (even though it does not say so).
 ; Some editors however save without BOM, and then special characters look messed up in the AHK GUI.

 ; Write your own AHK commands in this file to be recognized by the GUI. Take inspiration from the samples provided here.

 ;   A note on how this works:
 ;   The function name GuiSearch()" is poorly chosen.
 ;   What you actually specify as the parameter value is a command to run. It does not have to be a URL.
 ;   Before the command is run, the word REPLACEME is replaced by your input.
 ;   It does not have to be a search url, that was just the application I had in mind when I originally wrote it.
 ;   So what this does is that it runs chrome with the arguments "-incognito" and the google search URL where REPLACEME in the URL has been replaced by your input.

 ;-------------------------------------------------------------------------------
 ;;; Search Engines ;;;
 ;-------------------------------------------------------------------------------
 ;REPLACEME
 ;https://www.startpage.com/do/dsearch?query=site%3Awww.reddit.com+EXCELCOM&cat=web&pl=opensearch&language=english


 ; Search Engines
 ;-----------------------------------------------

 ; global cYellow
 ; global 

 ; Gui, Add, Text, %gui_control_options% %cYellow% +Center, %gui_search_title%
 ; Gui, Add, Picture, x2 h45 w45, %gui_search_icon%
 ; Gui, Add, Edit, x+1 %gui_control_options% %cYellow% 






;---AHK Scripts---
;------------------------------------------------
else if RMSearchTerm = bt%A_Space% ; Toggle Bluetooth
{
	gui_destroy()
	run, "C:\Users\%A_username%\Syncthing\Scripts\AutoHotKey\Tools\Windows10\Bluetooth\ToggleBluetooth.ahk"
}


else if RMSearchTerm = cico%A_Space% ; Open Icons Folder
{
	gui_destroy()
	run, C:\Users\%A_Username%\Syncthing\Scripts\AutoHotKey\Utilities\CreateICOIconUsingImageMagick.ahk
}

else if RMSearchTerm = rla%A_Space% ; Reload ALL scripts
{
	gui_destroy()
	run, "C:\Users\%A_username%\Syncthing\Scripts\AutoHotKey\Utilities\RMScriptManager.ahk" "ReloadAll"
}

else if RMSearchTerm = kill%A_Space% ; Kill all ahk scripts
{
	gui_destroy()
	run, C:\Users\%A_username%\Syncthing\Scripts\AutoHotKey\Tools\Kill & Close all running AHK scripts.ahk
}
else if RMSearchTerm = running%A_Space% ; Kill all ahk scripts
{
	gui_destroy()
	run, "C:\Users\%A_Username%\Syncthing\Scripts\AutoHotKey\Utilities\Running Script Manager.exe"
}

else if RMSearchTerm = tel%A_Space%	; run voidtools and search for executables
{
	gui_destroy()
	run, "C:\Users\%A_username%\Syncthing\Scripts\AutoHotKey\Utilities\SendTelegramMessageToCheckNowChannel.ahk"
}

;---/AHK Scripts---
;------------------------------------------------



;---Other Tools---
;------------------------------------------------

else if RMSearchTerm = uk%A_Space% ; uptime Kuma
{
	gui_destroy()
	run, http://206.210.43.203:3001/dashboard
}

else if RMSearchTerm = pf%A_Space% ; uptime Kuma
{
	gui_destroy()
	run, http://206.210.36.1/
}


else if RMSearchTerm = sst%A_Space% ; IT Toolbox
{
	gui_destroy()
	run, \\smb\Toolbox
}
else if RMSearchTerm = smb%A_Space% ; IT Toolbox
{
    gui_destroy()
    run, \\smb\General\
}
else if RMSearchTerm = ww%A_Space% ; 
{
	gui_destroy()
	run, W:\
}
else if RMSearchTerm = ssg%A_Space% ; 
{
	gui_destroy()
	run, \\smb\general
}

else if RMSearchTerm = nm%A_Space% ; nomachine
{
	CustomTool = NoMachine
	gui_search_title = NoMachine

	gui_search_icon = %A_ICODir%\NoMachine-icon.png
	GuiSearch("REPLACEME")	; REPLACEME  text will be replaced with the text input
}

else if RMSearchTerm = nmt%A_Space% ; nomachine
{
    CustomTool = NoMachine-Terminal
    gui_search_title = NoMachine (Terminal)

    gui_search_icon = %A_ICODir%\NoMachine-icon.png
    GuiSearch("REPLACEME")  ; REPLACEME  text will be replaced with the text input
}

else if RMSearchTerm = p%A_Space%	; Ping in CMD and keep open
{
	CustomTool = CMD_KeepOpen
	gui_search_title = Ping
	gui_search_icon = %A_ICODir%\Terminal.png
	GuiSearch("ping -n 9999 REPLACEME")	; REPLACEME  text will be replaced with the text input
	; GuiSearch("https://duckduckgo.com/?q=REPLACEME")	; REPLACEME  text will be replaced with the text input
	StatExport(gui_search_title)
}
else if RMSearchTerm = pg%A_Space%	; Ping in CMD and keep open
{
	; CustomTool = CMD_KeepOpen
	gui_destroy()
	run, %comspec% /k ping 206.210.40.1 -n 9999
	; gui_search_title = Ping
	; gui_search_icon = %A_ICODir%\Terminal.png
	; GuiSearch("ping -n 10 206.210.40.1")	; REPLACEME  text will be replaced with the text input
	; GuiSearch("https://duckduckgo.com/?q=REPLACEME")	; REPLACEME  text will be replaced with the text input
	StatExport(gui_search_title)
}

else if RMSearchTerm = u%A_Space%
{
	CustomTool = "C:\Program Files\LibreWolf\librewolf.exe"

	gui_search_title = Open URL in Librewolf
	gui_search_icon = %A_ICODir%\Librewolf.png
	GuiSearch("REPLACEME")	; REPLACEME  text will be replaced with the text input
	StatExport(gui_search_title) 
}


else if RMSearchTerm = O%A_Space%
{

	CustomTool = OpenFile

	gui_search_title = Open File
	gui_search_icon = %A_ICODir%\Files1.png
	GuiSearch("REPLACEME")	; REPLACEME  text will be replaced with the text input
	StatExport(gui_search_title)
	return
}


else if RMSearchTerm = dn%A_Space%
{

	gui_destroy()
	run, joplin://x-callback-url/openNote?id=b0b578945bab49e4a118a5f2f8ff16db
}
else if RMSearchTerm = dt%A_Space%
{

    gui_destroy()
    run, joplin://x-callback-url/openNote?id=89c905d6075c43a3a36c154d5b046d4e
}
else if RMSearchTerm = vlan%A_Space%
{

	gui_destroy()
	run, joplin://x-callback-url/openNote?id=0600aae9fa0e4dab936c9f125697cfbe
}
else if RMSearchTerm = octet%A_Space%
{

	gui_destroy()
	run, joplin://x-callback-url/openNote?id=f6429017ed194495a060930616a159edN
}

else if RMSearchTerm = j%A_Space%
{

	CustomTool = Joplin

	gui_search_title = Joplin
	gui_search_icon = %A_ICODir%\Files1.png
	GuiSearch("REPLACEME")	; REPLACEME  text will be replaced with the text input
	StatExport(gui_search_title)
	return
}

else if RMSearchTerm = S%A_Space%
{
	CustomTool = Sublime

	gui_search_title = Sublime
	gui_search_icon = %A_ICODir%\Sublime.png
	GuiSearch("REPLACEME")	; REPLACEME  text will be replaced with the text input
	StatExport(gui_search_title)
	return
}
else if RMSearchTerm = gimp%A_Space%
{
	CustomTool = GIMP

	gui_search_title = Gimp
	gui_search_icon = %A_ICODir%\gimp.png
	GuiSearch("REPLACEME")	; REPLACEME  text will be replaced with the text input
	StatExport(gui_search_title)
	return
}



; Interact with this AHK Script
;------------------------------------------------

else if RMSearchTerm = rl%A_Space% ; Reload This script
{
	gui_destroy()
	Reload
}
else if RMSearchTerm = dir%A_Space% ; Open the directory for this script
{
	gui_destroy()
	Run, %A_ScriptDir%
}
else if RMSearchTerm = host%A_Space% ; Edit host script
{
	gui_destroy()
	run, "C:\Program Files\Sublime Text\sublime_text.exe" "%A_ScriptFullPath%"
}
else if RMSearchTerm = edit%A_Space% ; Edit GUI user commands
{
	gui_destroy()
	; run,  "C:\Program Files\Sublime Text\sublime_text.exe" "%A_ScriptName%"
	run,  "%A_sublimeFilepath%" "C:\Users\%A_username%\Syncthing\Scripts\AutoHotKey\Utilities\AtomSearch\AtomUserCommands.ahk"
}
else if RMSearchTerm = hotstrings%A_Space% ; Edit GUI user commands
{
	gui_destroy()
	run,  "%A_sublimeFilepath%" "C:\Users\%A_username%\Syncthing\Scripts\AutoHotKey\RadialMenu\My codes\My hotstrings.ahk"
}
else if RMSearchTerm = hotkeys%A_Space% ; Edit GUI user commands
{
	gui_destroy()
	run,  "%A_sublimeFilepath%" "C:\Users\%A_username%\Syncthing\Scripts\AutoHotKey\RadialMenu\My codes\My hotkeys.ahk"
}
else if RMSearchTerm = functions%A_Space% ; Edit GUI user commands
{
	gui_destroy()
	run,  "%A_sublimeFilepath%" "C:\Users\%A_username%\Syncthing\Scripts\AutoHotKey\RadialMenu\My codes\My functions.ahk"
}
else if RMSearchTerm = rufay%A_Space% ; Edit GUI user commands
{
	gui_destroy()
	run,  "%A_sublimeFilepath%" "C:\Users\%A_Username%\Syncthing\Scripts\AutoHotKey\Utilities\Rufaydium_Scripts\Fun_Rufaydium_LoginWebsites.ahk"
}
else if RMSearchTerm = browser%A_Space% ; Edit GUI user commands
{
	gui_destroy()
	run,  "%A_sublimeFilepath%" "C:\Users\%A_Username%\Syncthing\Scripts\AutoHotKey\Utilities\open-browser-tab-with\Open Browser Tab WITH.ahk"
}
else if RMSearchTerm = global%A_Space% ; Edit GUI user commands
{
	gui_destroy()
	run,  "%A_sublimeFilepath%" "C:\Users\%A_Username%\Syncthing\Scripts\AutoHotKey\RadialMenu\My codes\My Global Variables.ahk"
}

; Type Raw Text
;------------------------------------------------
else if RMSearchTerm = clip%A_Space% ; Paste clipboard content without formatting
{
	gui_destroy()
	SendRaw, %ClipBoard%
}




; Launch Software/Programs
;------------------------------------------------
else if RMSearchTerm = t%A_Space% ;  ; SimpleTask append
{
	CustomTool = ToDoTxt

	gui_search_title = ToDo.txt Append
	gui_search_icon = %A_ICODir%\ToDoTXT.png
	GuiSearch("REPLACEME")	; REPLACEME  text will be replaced with the text input
	StatExport(gui_search_title)
	return
}
else if RMSearchTerm = fn%A_Space% ;  ; SimpleTask append
{
	gui_search_title = Append Fast Notepad
	gui_search_icon = %A_ICODir%\

	Gui, Add, Text, %gui_control_options% %cYellow% +Center, %gui_search_title%
	Gui, Add, Picture, x2 h45 w45, %gui_search_icon%
	Gui, Add, Edit, x+1 %gui_control_options% %cYellow% +Center vgui_SearchEdit -WantReturn
	Gui, Add, Button, x-10 y-10 w1 h1 +default gAppendtoFastNotepad ; hidden button
	GuiControl, Disable, RMSearchTerm
	Gui, Show, AutoSize
	return

	AppendtoFastNotepad:
	Gui, Submit
	gui_state = closed
	SaveLocation = C:\Users\%A_username%\Syncthing\Joplin\Resources\Text_Files\fastnote

	if(!FileExist(SaveLocation)){
		MsgBox, Folder not found:`n %SaveLocation% 
		return
	}
	FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss 
	filename = %SaveLocation%\%TodayDate%_QuickNotepad.txt
	FileAppend,%gui_SearchEdit%, %filename%
	return
}


else if RMSearchTerm = cmd%A_Space% ; Run CMD
{
	gui_destroy()
	;run, %comspec% /k "C:\Users\me\Downloads\_Old Files"
	run, cmd.exe	;, C:\Users\me\Downloads\_Old Files
}
else if RMSearchTerm = clean%A_Space% ; Clean downloads folder
{
	gui_destroy()
	run, "C:\Users\%A_username%\Syncthing\Scripts\AutoHotKey\Tools\FolderCleaner.ahk"
}
else if RMSearchTerm = write%A_Space% ; Libreoffice Writer
{	gui_destroy()
	run, "C:\Program Files\LibreOffice\program\swriter.exe"
}
else if RMSearchTerm = writel%A_Space% ; Libreoffice Writer
{	gui_destroy()
	run, "C:\Users\me\Documents\LibreOffice\BlankLandscape.odt"
}
else if RMSearchTerm = update%A_Space% ; Upgrade Chocolatey packages
{
	gui_destroy()
	run, "C:\Users\%A_username%\Syncthing\Scripts\AutoHotKey\Tools\Chocolatey\ChocoUpgradeAll.ahk"
}
else if RMSearchTerm = xlsb%A_Space% ; Open Personal XLSB 
{
	gui_destroy()
	run, "C:\Users\%A_UserName%\AppData\Roaming\Microsoft\Excel\XLSTART\Personal.XLSB"
}
else if RMSearchTerm = req%A_Space%  ; Requests
{
	gui_destroy()
	run, "C:\Users\%A_username%\Syncthing\WhiteMountain\Requisitions\IT Requisitions wHistory.xlsm"
}
else if RMSearchTerm = new%A_Space%  ; Requests
{
    gui_destroy()
    run, "C:\Users\ity\Syncthing\WhiteMountain\General\New Employee New User Printout Template.xlsm"
}
else if RMSearchTerm = ram%A_Space%  ; RAM Calculator
{
	CustomTool = RamMultiplier

	gui_search_title = How many GB? > clipboard
	gui_search_icon = %A_ICODir%\Ram_Metro.ico
	GuiSearch("REPLACEME")	; REPLACEME  text will be replaced with the text input
	StatExport(gui_search_title)
}
else if RMSearchTerm = quad%A_Space%  ; Requests
{
	gui_destroy()
	clipboard := "149.112.112.112"
	; run, "C:\Users\%A_username%\Syncthing\WhiteMountain\Requisitions\IT Requisitions wHistory.xlsm"

}


else if RMSearchTerm = time%A_Space%  ; Requests
{
	CustomTool = AHKTimeMultiplier

	gui_search_title = How much time? #M or #H > clipboard
	; gui_search_icon = %A_ICODir%\Ram_Metro.ico
	GuiSearch("REPLACEME")	; REPLACEME  text will be replaced with the text input
	StatExport(gui_search_title)
}

else if RMSearchTerm = ramc%A_Space%  ; Requests
{
	gui_destroy()
	FileRead, RamChart, C:\Users\%A_Username%\Syncthing\Scripts\AutoHotKey\Utilities\AtomSearch\Lib\RAMChart.txt
	msgbox % RamChart
	; run, "C:\Users\%A_Username%\Syncthing\WhiteMountain\General\MbMegabyteToGBGigabyteConversionChart Ram Sizes.xlsx"
}
else if RMSearchTerm = ada%A_Space% ; Adapters
{
	gui_destroy()
	run, "C:\Windows\System32\ncpa.cpl" ; Network Adapters
}
else if RMSearchTerm = disk%A_Space% ; Disk Management
{
    gui_destroy()
    run, "diskmgmt.msc" ; Windows Disk management
}
else if RMSearchTerm = psdhcp%A_Space% ; Powershell - DHCP string Script
{
	gui_destroy()
	run, C:\Users\%A_UserName%\Syncthing\Scripts\AutoHotKey\Utilities\DHCP_PS_StringGenerator.ahk
}
else if RMSearchTerm = ps%A_Space% ; OR RMSearchTerm = psprofile%A_Space% ; Powershell - DHCP string Script
{
	gui_destroy()
	run, "%A_sublimeFilepath%" "C:\Users\%A_Username%\Syncthing\Configurations\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"
}

/*else if RMSearchTerm = power ; Power down the pc
{
	gui_destroy()
	Shutdown, 8	; power off command
}

*/
else if RMSearchTerm = ping ; Ping Google
{
	gui_destroy()
	Run, cmd /K "ping www.google.com"
	Run, cmd /K "ping 8.8.8.8"
}
else if RMSearchTerm = hosts ; Open hosts file in Notepad
{
	gui_destroy()
	Run notepad.exe C:\Windows\System32\drivers\etc\hosts
}
else if RMSearchTerm = date ; What is the date?
{
	gui_destroy()
	FormatTime, date,, LongDate
	MsgBox %date%
	date =
}
else if RMSearchTerm = week ; Which week is it?
{
	gui_destroy()
	FormatTime, weeknumber,, YWeek
	StringTrimLeft, weeknumbertrimmed, weeknumber, 4
	if (weeknumbertrimmed = 53)
	weeknumbertrimmed := 1
	MsgBox It is currently week %weeknumbertrimmed%
	weeknumber =
	weeknumbertrimmed =
}
else if RMSearchTerm = ?%A_Space% ; Tooltip with list of commands
{
	GuiControl,, RMSearchTerm, ; Clear the input box
	gui_destroy()
	Gosub, gui_commandlibrary
}
else if RMSearchTerm = a?%A_Space% ; Tooltip with list of commands
{
	GuiControl,, RMSearchTerm, ; Clear the input box
	gui_destroy()
	Gosub, gui_commandlibrary
}

return

