Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

HotString GUI


  • Please log in to reply
7 replies to this topic
mallow
  • Members
  • 4 posts
  • Last active: Feb 01 2005 07:18 AM
  • Joined: 27 Jan 2005
Due to your great support, my first script is now ready.
Thank you guys.
; ---------------------------------------------------------------------
; Name:             HotString GUI v0.2
; Author:           mallow
; Datum:            31.01.2005
;
; Language:         german/english
; Platform:         tested with XP
; AutoHotkey Ver.:  1.0.25.10+
;
; Description:
; With this script HotStrings can be managed via a GUI
; ---------------------------------------------------------------------

;*********************Autostart*********************

;*********************Configuration*********************

DefFileName = HotString_Defs.ahk
Menu, Tray, Icon, %A_WinDir%\system32\SHELL32.dll, 174

; Get system language
StringRight, Lng, A_Language, 2
if Lng = 07  ; = Deutsch (0407, 0807, 0c07 ...)
{
   lngMsgDefFileNotFound   = Definitionsdatei nicht gefunden.`r`n Neue Datei wird erstellt.
   lngDelete               = &Löschen
   lngAdd		   = &Hinzufügen
   lngText		   = Text:
   lngOK                   = &OK
   lngCancel               = &Abbrechen
   lngMsgHotStringInUse	   = Dieser HotString wird bereits benutzt.
}
else        ; = other languages

{
   lngMsgDefFileNotFound   = Definition file not found.`r`n New file will be created.
   lngDelete               = &Delete
   lngAdd		   = &Add
   lngText		   = Text:
   lngOK                   = &OK
   lngCancel               = &Cancel
   lngMsgHotStringInUse	   = This HotString is already in use.
}


;*********************End of configuration*********************

IfNotExist, %DefFileName%
{
	MsgBox, %lngMsgDefFileNotFound%
	FileAppend, #NoTrayIcon `n, %DefFileName%
}
Run, autohotkey.exe /f /r %DefFileName%, , , PID


;*********************End of Autostart*********************

^!A::  ; Strg+ALT+A hotkey
;Read definitions from file
FileRead, List, %DefFileName%


;Build GUI
Gui, Add, Text, x16 y10 w190 h20, HotStrings:
Gui, Add, ListBox, gListbox x16 y30 w420 h180,   
Gui, Add, Button, gBtnDelete x336 y210 w100 h20, %lngDelete%
Gui, Add, Button, gBtnAdd x336 y230 w100 h20, %lngAdd%
Gui, Add, Text, x16 y210 w50 h20, HotString:
Gui, Add, Edit, vAbbreviation x75 y207 w243 h20,
Gui, Add, Text, x16 y233 w50 h20, %lngText%
Gui, Add, Edit, vInsertText x75 y230 w243 h20,  
Gui, Add, Button, gBtnSave Default x128 y265 w90 h30, %lngOK%
Gui, Add, Button, gGuiClose x238 y265 w90 h30, %lngCancel%
Gui, Show, x246 y110 h318 w462, AutoText

;Add existing definitions to listbox
StringReplace, List, List, `r`n, `n, All
Loop, parse, List, `n, `r
{
	If A_index > 1
		Control, Add, %A_LoopField%, Listbox1, A
}

Return

Listbox:
;Get selected item, split text and fill edit fields
GuiControlGet, Content, , Listbox1
StringReplace, Content, Content, `:`:, ¢, all
StringTrimLeft, Content, Content, 1
Loop, parse, Content, ¢
{
	GuiControl, , Edit%A_Index%, %A_LoopField%
}
Return

BtnDelete:
;Delete selected item
GuiControl, +AltSubmit, ListBox1
GuiControlGet, Content, , Listbox1
Control, Delete, %Content%, Listbox1
GuiControl, -AltSubmit, ListBox1
GuiControl, , Edit1; reset to blank
GuiControl, , Edit2; reset to blank
Return

BtnAdd:
;Create new listbox item from content of edit fields
NewItem=`:`:
GuiControlGet, Content, , Edit1
NewItem=%NewItem%%Content%
NewItem=%NewItem%`:`:
ControlGet, List, List,, Listbox1, A
IfInString, List, %NewItem%
{
	MsgBox, %lngMsgHotStringInUse%
}
else
{
GuiControlGet, Content, , Edit2
NewItem=%NewItem%%Content%
Control, Add, %NewItem%, Listbox1, A
}
Return

BtnSave:
ControlGet, List, List,, Listbox1, A
Sort, List
FileDelete, %DefFileName%
FileAppend, #NoTrayIcon `n, %DefFileName%
FileAppend, %List%, %DefFileName%
Gui, Destroy
Run, autohotkey.exe /f /r %DefFileName%, , UseErrorLevel, PID
Return

GuiClose:
Gui, Destroy


BoBo
  • Guests
  • Last active:
  • Joined: --
Maybe you should think about to create a new topic at the "Script" section to "relase" it there !? Thx for sharing it :D

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

think about to create a new topic at the "Script" section

Good idea. I've done so.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
I tried out the script above and it is quite nice. A few things I noticed:

1) You use #NoTrayIcon in the generated script. I'm not sure that is the best default, since there would never be a way to exit the script.

2) Perhaps pressing Enter should trigger the Add button rather than the Okay button.

Overall, I like it a lot, especially the way it shows you the hotstrings you've already added, and updates the list as you add new ones.

Thanks for sharing it.

  • Guests
  • Last active:
  • Joined: --
Hello,

are there any prerequisites that have to be set, like PATH variables?
Did a copy and paste of the script above and *nothing* works with that.
It opens a dialog, the language (german) is not found (W2000 Pro), not even the english captions are on the buttons, tab-key does exit the dialog; added hotkeys are not stored etc.

Can "DefFileName" only be used for these hotstrings? I want to store it my my one-and-only-single ahk file.
The fact that it tries to create another Autohotkey.ini in the script folder caused be to add the path for the program:
Run, D:\Programme\AutoHotkey\autohotkey.exe /f /r %DefFileName%, , , PID

That did not help, it still wants that ini in the script folder.
It seems it is easier to make this by myself in Delphi ...

Helmut

helmut_B
  • Members
  • 2 posts
  • Last active: Mar 04 2005 03:33 PM
  • Joined: 27 Feb 2005
Hi All,

in the meantime I found this:
http://www.autohotke... ... hotstrings

That works fine for me - some suggestions in that thread.

Greetings
Helmut
*** keep it easy and simple *** :-)

mjbrown747
  • Members
  • 22 posts
  • Last active: Oct 13 2007 05:06 PM
  • Joined: 12 Nov 2005
I have been trying to come up with a way to dynamicly generate a gui for hotkeys.

Thanks for sharing

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
This is badly writtens script. It starts 2 instances of AHK - 1 for the GUI and 1 for the hotstrings....
Posted Image