GUI SCRIPT | URL Browser Specific | add function to callout cmd commands
Hey plul, your script is amazing work. It's really the ground work that makes ahk a whole lot easier to use and I don't have to memorize all my hidden keys. So all I need to know how the name of the command and I don't have to worry about accidental presses on my keyboard. I have the option to view what commands I use via ? which is helpful.
I did however come across a situation where I want to use gui_search_title to input cmd commands without having to launch a command-prompt window just yet. How would I be able to do this?
I've experimented with REPLACEME but it looks like that it's only browser url specific.
MY ATTEMPT (NOT WORKING)
else if thisguysdope = doping%A_Space%
{
gui_destroy()
gui_search_title = Ping...
Run, cmd /K "ping REPLACEME"
}
For that you would need to modify the logic of one of the functions in the GUI.ahk file.
I've done this for other types of searches where I needed cleartext searches without translating the input into URL-safe characters.
The simplest way to change the code, would be to add an if-statement under the gui_SearchEnter function:
gui_SearchEnter:
Gui, Submit
gui_destroy()
query_safe := uriEncode(gui_SearchEdit)
Loop, %search_urls%
{
if commander = True
{
StringReplace, search_final_url, search_url%A_Index%, REPLACEME, %gui_SearchEdit%
run cmd /K %search_final_url%
}
else
{
StringReplace, search_final_url, search_url%A_Index%, REPLACEME, %query_safe%
run %search_final_url%
}
}
search_urls := 0
commander := 0
return
After this, you could just create a new command in your UserCommands.ahk file like so:
else if Pedersen = doping ; Pings a thing that you give it
{
gui_search_title = Ping this please!
commander = True
gui_search("ping REPLACEME")
}
The commander = True part of the new command triggers the if-statement we created earlier. Also note the commander := 0 part in the GUI.ahk. Its needed to "return" the script to it's normal behavior after it's done with executing the commands.
While you're changing this you might also want to update the GuiEscape code aswell, so that it will clear information correctly if you abort a command:
GuiEscape:
gui_destroy()
search_urls := 0 ; Clears any potential commands given to the script.
commander := 0
return
Thank-You very much. Modified file-gui for both titles SearchEnter & GuiEscape. The modification is to include if-statement and a way to correctly clear info when command is aborted.
Needed a way to input commands in cmd via REPLACEME (only if you're familiar with plul's commandsearch it uses a gui-search-title) REPLACEME was intended for url searches only Got help from Nollikino at Github
Just in case, i have another solution :
In user commands :
else if Pedersen = run
{
gui_search_title := "run,"
gui_Addrunboxfunction()
}
in gui.ahk :
gui_Addrunboxfunction()
{
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_Addrunbox
}
}
gui_Addrunbox:
Gui, Add, Text, %gui_control_options% %cYellow%, %gui_search_title%
Gui, Add, Edit, %gui_control_options% %cYellow% vgui_AddrunboxEdit -WantReturn
Gui, Add, Button, x-10 y-10 w1 h1 +default ggui_Addrunboxp2 ; hidden button
GuiControl, Disable, Pedersen
Gui, Show, AutoSize
return
gui_Addrunboxp2:
Gui, Submit
gui_destroy()
run, %gui_AddrunboxEdit%
;msgbox, %gui_AddrunboxEdit%
return