Thank you both for your work on this project as it has opened some new ideas for what I am trying to accomplish.
My problem is that once a string has been created it has to be edited within the showhotstring GUI using the same input text or it will continue to run in the background.
I want to be able to destroy that hotstring if I replace it with a new input/output within that GUI. Is this possible?
I have tried to use stringreplace without success (notated in code) and experimented with clipboard commands and haven't had any luck.
This is a snippet of the whole code to keep things simple. I have 5 other custom buttons (buttoncustom-2,buttoncustom-3....etc) that are in the main GUI that have the same function.
After I figure this out I would like to find a way to save the commands to file so they can be reloaded to the GUI next time the program runs.
Code: Select all
Gui, Add, Button, x551 y12 w100 h30 vcustom1 , Custom-1
Gui, Show, x674 y381 h233 w652,
return
buttonCustom-1:
Gui new:+LastFoundExist
IfWinExist
{
Gui, new:Show
ControlFocus, Edit1
}
else
{
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance off
Gui, new:Add, Text,, Enter Custom Command
Gui, new:Add, Edit, vHString ys
Gui, new:Add, Edit, w400 r8 vTextInsert xs, <Insert command text here>
Gui, new:Add, Button, gSetupString, Set Custom Command #1
Gui, new:Show, , Custom Shorthand #1
Return
SetupString:
Gui, new:Submit
If HString !=
{
NewText := Hotstring(":*:"Hstring, TextInsert)
gosub, TextAdd
SetTimer, update1,-250
}
Else {
msgbox
(
No custom command created. You must enter a command and a command output text. Please try again.
)
gosub, ShowHotstring
SetTimer, update-1,-250
}
TextAdd:
OldClip = Clipboard
Clipboard =
Clipboard = %NewText%
Clipwait, 0.3
Send, ^
Clipboard = %OldClip%
OldClip =
;---------------------- Below settimer command had no effect--------------------------------------
Settimer, changed1
changed1:
StringReplace, clipboard, clipboard, %Hstring%, %TextInsert%, All
;---------------------- Above settimer command had no effect--------------------------------------
update1:
GuiControl, , custom1 , %HString%
return
update-1:
GuiControl, , custom1 , Custom-1
return
ShowHotstring:
Gui, new:Show
ControlFocus, Edit1
Return
}
return