/*
AceText Helper - An AutoHotkey script for enhancing the clip-capturing capabilities of Acetxt (www.acetext.com)
So you got Autohotkey up-and-running! It inspired me to write this helper script to
add additional clip-capturing funcrtions to AceText - http://www.acetext.com/ - my clipboard manager of choice.
On first run the script creates this atc file.
The file should be called 2008.atc. If it's 2009, then name it 2009.atc etc. (i.e. one file is used for each year).
This fille is saved to you root folder e.g. C:\-Year-.atc
You can of course change these settings in the script.
You're ready to go! Start clipping with the hotkeys below.
NOTE: The atc collection should not be open in AceText during clipping - it is write-protected!
So press Cntrl+w after reviewing the hotkkeys.
Hope you find it useful!
_______________
Win+w: WEBCLIP1 - Copy & Paste selected webpage text and the URL reference to an Acetext websnippet
______________
Alt+w: WEBCLIP2 - Saves the existing clipboard contents as clip to acetext collection
Use in conjunction with Alt1 or CapsLock, which has been re-mapped to append current selected text to clipboard. Usng this combo you can collect diverse clips froom throughout a webpage. These are saved as a single websnippet. Normal Capslock function is accessed using shift+caplock. Try iit!
_____________
Win+f: FILECLIP - Opens a file selector and then a textbox. The label/text are saved,
along with the full filepath, as a websnippet. The file can be accessed from within aceText by clicking on the web icon.
__________
Win+c: CLIP - Opens a text box. Entered label and text are saved as Plain text clip
_______________
Win+I: IMAGECLIP - Copies the Image URL referenced by current moouse position, then textbox. All saved as an acetext WebSnippet. Image can be reloaded from within AceText by clicking the Web icon.
_______________
Alt+1 or CapsLock: (1) Append paragraph plus selected text to clipboard.
_____
Alt+2: Save Clipboard contents as websnippet (replicates Alt+w)
_____
Alt+3: Remove whitespace and formatting from clipboard text
_____
Alt+4: Remove ALL whitespace, including carriage returns
_____
Alt+5: Swaps selected text with text from the clipboard
Issues:
-The .atc file must not be in use by acetext - it will be read only and won't save your clips!
- Although I have escaped xml illegal characters, copying of some characters may causemthe collection noot to open later.
Next steps:
-Copy text from any open file and save this, with filepath, as websnippet
080614JHAceTextHelper
*/
; Forces singe instance of this script
#SingleInstance force
;____________________________________________________________________________________
; GLOBAL VARIABLES
;____________________________________________________________________________________
; Create date variables
FormatTime, TodaysDate,, yyyy-MM-dd ; todays date
FormatTime, TimeNow,, HH:mm:ss ; timestamp
FormatTime, YearToday,, yyyy ; Year
IfNotExist, \%YearToday%.atc
MsgBox, A new AceText collection has been created in your root folder: \%YearToday%1`r`r`rYou can change these setting in the script
IfNotExist, \%YearToday%.atc
FileAppend,
(
So you got Autohotkey up-and-running! It inspired me to write this helper script to add additional clip-capturing funcrtions to acetext - http://www.acetext.com/
On first run the script creates this atc file. The file should be called 2008.atc. If it's 2009, then name it 2009.atc etc. (i.e. one file is used for each year). This fille is saved to you root folder e.g. C:\-Year-.atc
You can of course change these settings in the script.
You're ready to go! Start clipping with the hotkeys below.
NOTE: The atc collection should not be open in AceText during clipping - it is write-protected! So preee Cntrl+w after reviewing the hotkkeys.
Hope you find it useful!
_______________
Win+w: WEBCLIP1 - Copy & Paste selected webpage text and the URL reference to an Acetext websnippet
______________
Alt+w: WEBCLIP2 - Saves the existing clipboard contents as clip to acetext collection
Use in conjunction with Alt1 or CapsLock, which has been re-mapped to append current selected text to clipboard. Usng this combo you can collect diverse clips froom throughout a webpage. These are saved as a single websnippet. Normal Capslock function is accessed using shift+caplock. Try iit!
_____________
Win+f: FILECLIP - Opens a file selector and then a textbox. The label/text are saved, along with the full filepath, as a websnippet. The file can be accessed from within aceText by clicking on the web icon.
__________
Win+c: CLIP - Opens a text box. Entered label and text are saved as Plain text clip
_______________
Win+I: IMAGECLIP - Copies the Image URL referenced by current moouse position, then textbox. All saved as an acetext WebSnippet. Image can be reloaded from within AceText by clicking the Web icon.
_______________
Alt+1 or CapsLock: (1) Append paragraph plus selected text to clipboard.
_____
Alt+2: Save Clipboard contents as websnippet (replicates Alt+w)
_____
Alt+3: Remove whitespace and formatting from clipboard text
_____
Alt+4: Remove ALL whitespace, including carriage returns
_____
Alt+5: Swaps selected text with text from the clipboard
Issues:
-The .atc file must not be in use by acetext - it will be read only and won't save your clips!
- Although I have escaped xml illegal characters, copying of some characters may causemthe collection noot to open later.
Next steps:
-Copy text from any open file and save this, with filepath, as websnippet
080614JHAceTextHelper
), \%YearToday%.atc
;____________________________________________________________________________________
; FUNCTIONS
;____________________________________________________________________________________
; Acetext parser
AceParse(Str) {
StringReplace, Str, Str, & , &`; , All
StringReplace, Str, Str, < , <`; , All
StringReplace, Str, Str, > , >`; , All
StringReplace, Str, Str, " , "`; , All
StringReplace, Str, Str, ' , &apos`; , All
Return str
}
;This checks if a window is, in fact a window.
;As opposed to the desktop or a menu, etc.
IsWindow(hwnd)
{
WinGet, s, Style, ahk_id %hwnd%
return s & 0xC00000 ? (s & 0x80000000 ? 0 : 1) : 0
;WS_CAPTION AND !WS_POPUP(for tooltips etc)
}
;REMOVE WHITESPACE
Whitespace(str) {
xAT := A_AutoTrim
AutoTrim, Off
Loop, Parse, str
{ If A_LoopField is space
IfEqual, xs, 1, Continue
Else xs = 1
Else xs = 0
s =%s%%A_LoopField%
} AutoTrim, %xAT%
Return, s
}
;____________________________________________________________________________________
; CLIP COMMANDS - ALT+1...0
;____________________________________________________________________________________
; Useful Clipboard hokey additions
; Ja's version 2008
!1:: ; (1) Append newline plus selected text to clipboard.
oldclip = %clipboard%
Send, ^c
Clipwait, 1
clipboard = %oldclip%`r`r`n%clipboard%
Return
!2:: ; (2) Send Clipboard contents to websnippet
Send !w
Return
!3:: ; (6)Remove whitespace and formatting from clipboard text
ClipBoard = %ClipBoard% ; Convert to text
StringReplace, clipboard, clipboard, `n, , All ; remove newlines from clipboard text
string = %clipboard%
clipboard = % Whitespace(string) ; invoke Remove Whitespace function
Return
!4:: ; (4) Remove ALL whitespace, including carriage returns
ClipBoard = %ClipBoard% ; Convert to text
StringReplace, clipboard, clipboard, `r`n, , All ; remove newlines from clipboard text
string = %clipboard%
clipboard = % Whitespace(string) ; invoke Remove Whitespace function
Return
!5:: ; (5) Swaps selected text with text from the clipboard
clipOne = %clipboard%
Send, ^c
clipTwo = %clipboard%
clipboard = %clipOne%
Send, ^v
clipboard = %clipTwo%
Return
!0:: ; (0) Clear, Ctrl+Shift+X, clear the clipboard
clipboard = ;clears clippboard
Return
; Change CapsLock key into something useful:
Capslock::Send !1
; To use Capslock, if ever, use shift
+Capslock::Capslock
;____________________________________________________________________________________
; ACETEXT CLIPPERS - WIN+
; All notes are saved in the dayfile - generated automatically each day in format yymmdd
;____________________________________________________________________________________
!w:: ; WEBCLIP - Saves clipboard contents as clip to acetext collection
NoteBody = %clipboard%
Send !d
Send ^c
ClipWait, 1
NoteUrl = %clipboard%
; Escape illegal xml characters in URL
NoteUrl := AceParse(NoteUrl)
;Remove all CR+LF's
;StringReplace, NoteBody, Notebody, `r`n, , All
;Remove all whitespace
;NoteBody = % Whitespace(NoteBody)
;Store first 16 characters into a variable, for the label
StringLeft, OutputVar, Notebody, 32 ; Stores the string "This" in OutputVar.
cliplabel = %OutputVar%
; Escape illegal xml characters in NoteBody
NoteBody := AceParse(NoteBody)
;Read the collection into a variable
FileRead data, \%YearToday%.atc
;Delete the collection
FileDelete, \%YearToday%.atc
; Remove the end tags of the atc file
StringReplace, NewStr, data, ,, All
StringReplace, NewStr, NewStr, ,, All
; Append the old atc (minus end tags) plus new clip + new end tags to new atc file
FileAppend,
(
%NewStr%
%NoteBody%
%NoteUrl%
), \%YearToday%.atc
Return
;______________________________________________
#w:: ; WEBCLIP - Copy & Paste selected webpage text and the URL reference to an Acetext collection
Send ^c
NoteBody = %clipboard%
Send !d
Send ^c
ClipWait, 1
NoteUrl = %clipboard%
; Escape illegal xml characters in URL
NoteUrl := AceParse(NoteUrl)
;Remove all CR+LF's
;StringReplace, NoteBody, Notebody, `r`n, , All
;Remove all whitespace
;NoteBody = % Whitespace(NoteBody)
;Store first 16 characters into a variable, for the label
StringLeft, OutputVar, Notebody, 32 ; Stores the string "This" in OutputVar.
cliplabel = %OutputVar%
; Escape illegal xml characters in NoteBody
NoteBody := AceParse(NoteBody)
;Read the collection into a variable
FileRead data, \%YearToday%.atc
;Delete the collection
FileDelete, \%YearToday%.atc
; Remove the end tags of the atc file
StringReplace, NewStr, data, ,, All
StringReplace, NewStr, NewStr, ,, All
; Append the old atc (minus end tags) plus new clip + new end tags to new atc file
FileAppend,
(
%NewStr%
%NoteBody%
%NoteUrl%
), \%YearToday%.atc
Return
;__________________________________________
#f:: ; Opens a file selector and then a textbox. File location and text / tags are stored in dayfile
;Clear variables
NoteBody =
NoteTag =
Gui, Destroy ;Clears the GUI space
FileSelectFile, SelectedFile, 3, \DOCS\, Choose a file, All Files (*.*)
if SelectedFile =
Return
else
Gui, Add, Edit, w350 vFTagEditBox
Gui, Add, Edit, w350 h100 vEditBox
Gui, Add, Button, Default gSubmitA, Tag this fiile!
Gui, Show
Return
SubmitA:
Gui, Submit
GuiControlGet, Text,, EditBox
GuiControlGet, TagText,, FTagEditBox
if Text =
Send {Space}
else
NoteBody = %Text%
NoteTag = %TagText%
; Escape illegal xml characters in NoteBody
NoteBody := AceParse(NoteBody)
NoteTag := AceParse(NoteTag)
;Read the collection into a variable
FileRead data, \%YearToday%.atc
;Delete the collection
FileDelete, \%YearToday%.atc
; Remove the end tags of the atc file
StringReplace, NewStr, data, ,, All
StringReplace, NewStr, NewStr, ,, All
FileAppend,
(
%NewStr%
%NoteBody%
%SelectedFile%
), \%YearToday%.atc
Return
;____________________________________________
#c:: ;Collect a clip and send to AceText collection
;Clear variables
NoteBody =
NoteTag =
Gui, Destroy ;Clears the GUI space
Gui, Add, Edit, w350 vTagEditBox
Gui, Add, Edit, w350 h100 vEditBox
Gui, Add, Button, Default gSubmitD, Enter you clip!
Gui, Show
Return
SubmitD:
Gui, Submit
GuiControlGet, Text,, EditBox
GuiControlGet, TagText,, TagEditBox
if Text =
Return
else
NoteBody = %Text%
NoteTag = %TagText%
; Escape illegal xml characters in NoteBody and NoteTag
NoteBody := AceParse(NoteBody)
NoteTag := AceParse(NoteTag)
;Read the collection into a variable
FileRead data, \%YearToday%.atc
;Delete the collection
FileDelete, \%YearToday%.atc
; Remove the end tags of the atc file
StringReplace, NewStr, data, ,, All
StringReplace, NewStr, NewStr, ,, All
FileAppend,
(
%NewStr%
%NoteBody%
), \%YearToday%.atc
Return
;____________________________________________________________________________________
; Capture Web Image location to Acetext Collection - ALT+
; ALT+arrow keys control the recorder
;____________________________________________________________________________________
#i:: ;Copies the Image location as an acetext WebSnippet
Gui, Destroy ;Clears the GUI space
;Clear all variables
clipboard =
NoteBody =
NoteTag =
NoteUrl =
Sendplay {Click right}
Send o
Clipwait
NoteUrl=%clipboard%
Gui, Add, Edit, w350 vITagEditBox
Gui, Add, Edit, w350 h100 vEditBox
Gui, Add, Button, Default gSubmitE, Tag this image!
Gui, Show
Return
SubmitE:
Gui, Submit
GuiControlGet, Text,, EditBox
GuiControlGet, TagText,, ITagEditBox
if Text =
Send {Space}
else
NoteBody = %Text%
NoteTag = %TagText%
; Escape illegal xml characters in NoteBody
NoteBody := AceParse(NoteBody)
NoteTag := AceParse(NoteTag)
;Read the collection into a variable
FileRead data, \%YearToday%.atc
;Delete the collection
FileDelete, \%YearToday%.atc
; Remove the end tags of the atc file
StringReplace, NewStr, data, ,, All
StringReplace, NewStr, NewStr, ,, All
FileAppend,
(
%NewStr%
%NoteBody%
%NoteUrl%
), \%YearToday%.atc
Return