Skip to content

Commit 197f038

Browse files
Initial Upload
1 parent 83b97b4 commit 197f038

File tree

4 files changed

+146
-0
lines changed

4 files changed

+146
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
2+
#Warn ; Enable warnings to assist with detecting common errors.
3+
SendMode Play ; Recommended for new scripts due to its superior speed and reliability.
4+
SetWorkingDir %A_ScriptDir% ; Set starting directory to the directory with the script.
5+
#SingleInstance ;Prevent more than one of the same script from running concurrently.
6+
#persistent ;Keep script active with timers running.
7+
SetTitleMatchMode,2 ;Easily find window titles.
8+
9+
10+
; This app works but is incomplete. still needs filtering of special characters and referential file location instead of typing it into the file.
11+
12+
13+
MsgBox, 1, HotStrings by Marc Anderson, This app will enable shortcuts(aka, hotstrings) that will autotype based on a CSV file
14+
IfMsgBox, OK
15+
; loop through the csv file one line at a time
16+
Loop, read, hotstrings.csv
17+
{
18+
; save the line number to a variable
19+
LineNumber := A_Index -1
20+
21+
; skip the first row of content
22+
IfEqual, A_Index, 1, Continue
23+
24+
; parse each cell into variables
25+
Loop, parse, A_LoopReadLine, CSV
26+
{
27+
; if the cell number is odd, assign the current cell to the HotStringShortCut variable
28+
if ( Mod(A_Index, 2) != 0) {
29+
HotStringShortCut := A_LoopField ;else
30+
; MsgBox, 4, , %LineNumber%-%A_Index% is:`n%A_LoopField%`n%HotStringShortCut%`nContinue?
31+
32+
; if the cell number is even, assign the current cell to the HotStringExtended variable
33+
} else {
34+
HotStringExtended := A_LoopField
35+
; MsgBox, 4, , %LineNumber%-%A_Index% is:`n%A_LoopField%`n%HotStringExtended%`nContinue?
36+
}
37+
38+
; if the cell number is even, assign both variables to a hotkey
39+
if ( Mod(A_Index, 2) = 0) {
40+
; MsgBox, 4, , %HotStringShortCut% - %HotStringExtended%`n`nContinue?
41+
hotstring(":*:" "<" HotStringShortCut, HotStringExtended)
42+
}
43+
44+
; %LineNumber% is the current row
45+
; %A_Index% is the current column
46+
; %A_LoopField% is the current field
47+
48+
; MsgBox, 4, , Field %LineNumber%-%A_Index% is:`n%A_LoopField%`n`nContinue?
49+
IfMsgBox, No
50+
return
51+
}
52+
}
53+
else IfMsgBox, Cancel
54+
ExitApp
55+
56+
^1::
57+
Reload
58+
Sleep, 2000

CSV Text Expander/hotstrings.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
HotKey,Extended Text
2+
else,Please let me know if there is anything else I can do.
3+
sorry,I am sorry for the inconvenience.
4+
nobil,We do not include billing details with any of our shipments.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
2+
#SingleInstance, Force
3+
#Warn ; Enable warnings to assist with detecting common errors.
4+
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
5+
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
6+
SetTitleMatchMode, 2
7+
; VERSION 100
8+
9+
; This app works but is incomplete. still needs referential file location instead of typing it into the file.
10+
11+
; initialize the XL variable
12+
XL :=
13+
14+
; fetch the correct file path
15+
tgtFilePath := A_ScriptDir "\hotstrings.xlsx"
16+
17+
18+
MsgBox, 1, AutoHotkey Text Expander, This text expander app allows you to automatically convert short phrases into long blocks of text.`n`nFor example, typing <now will automatically expand into the current date and time. All shortcuts used in this app are prefixed with the < symbol.`n`nNew shortcuts can be added in the hotstrings.xlsx file included with this app.
19+
IfMsgBox, Cancel
20+
Return
21+
IfMsgBox, OK
22+
try {
23+
; Check if excel is active
24+
XL := ComObjectActive("Excel.Application")
25+
} catch {
26+
; If Excel is not active, create an instance
27+
XL := ComObjCreate("Excel.Application")
28+
}
29+
; MsgBox, % IsObject(XL) ; Is excel an object?
30+
try {
31+
; Check if the workbook exists
32+
XL.Workbooks.Open(tgtFilePath)
33+
} catch {
34+
; Quit the application
35+
if(XL.Workbooks.Count = 1){
36+
XL.Quit
37+
}
38+
; Alert the user that the file was not found
39+
MsgBox, The necessary workbook was not found. Please create a hotstrings.xlsx file to continue.
40+
ExitApp
41+
Sleep, 2000
42+
}
43+
44+
; Make Excel Visible
45+
XL.Visible := 0
46+
47+
; select the sheet name containing the templates
48+
tgtSheet := XL.Worksheets("Templates")
49+
50+
; Sort the data by column C so it can loop over all of the hotstrings without empty cells
51+
tgtSheet.UsedRange.Offset(1).Sort(XL.Columns(3), 1)
52+
53+
; Loop through all of the active cells
54+
while(tgtSheet.Range("C" . A_Index).Value != "") {
55+
56+
; Skip the first row as they are the header
57+
IfLess, A_Index, 2, Continue
58+
59+
; assign the value in column C of the current row to HotStringShortCut variable
60+
HotStringShortCut := tgtSheet.Range("C" . A_Index).Value
61+
62+
; assign the value in column D of the current row to HotStringExtended variable
63+
HotStringExtended := tgtSheet.Range("D" . A_Index).Value
64+
65+
; replaces any exclamation points and carriage returns with appropriate characters
66+
HotStringExtended := StrReplace(StrReplace(StrReplace(HotStringExtended, "!","{!}"),"`r","{enter}"),A_Space A_Space,"{space 2}")
67+
68+
; assign both variables to a hotkey
69+
hotstring(":*:" "<" HotStringShortCut, HotStringExtended)
70+
; MsgBox, 4, , %HotStringShortCut% - %HotStringExtended%`n`nContinue?
71+
72+
}
73+
; tell excel it's save so it wont harass you and close the document
74+
XL.Application.ActiveWorkbook.saved := true
75+
if(XL.Workbooks.Count = 1){
76+
XL.Quit
77+
} else {
78+
XL.Application.ActiveWorkbook.Close
79+
}
80+
81+
:*:<now::
82+
FormatTime, CurrentDateTime,, MM/dd/yyyy hh:mm:ss
83+
SendInput, %CurrentDateTime%
84+
return

XLSX Text Expander/hotstrings.xlsx

9.69 KB
Binary file not shown.

0 commit comments

Comments
 (0)