관리 메뉴

ㄴrㅎnㅂrㄹrㄱi

HotString GUI 본문

AUTOHOTKEY/스크립트

HotString GUI

님투 2007. 10. 23. 15:13
반응형
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
; http://www.autohotkey.com/forum/viewtopic.php?t=2066
; ---------------------------------------------------------------------

;*********************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               = &Loschen
   lngAdd         = &Hinzufugen
   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
반응형
Comments