[AHK] Different default text in comments for different categories

A place to post your ideas and solutions for how best to make use of the software

Moderators: abstr, Niko

Post Reply
Niko
Posts: 239
Joined: Wed Sep 18, 2019 6:48 am

[AHK] Different default text in comments for different categories

Post by Niko » Sun Nov 10, 2019 2:19 pm

By default in Preferences -> Task -> Defaults you can type text which will be shown in the Comments tab of a new task. Unfortunately I didn't find any option that will set different text for different categories. Running UDT with -cm parameter if you have 2-3 categories would be Ok, but, suppose you have 10-12 categories, so you have to choose different buttons or hotkeys for each new task, like in the example below:

Code: Select all

- cm "Comment text category X"
- cm "Comment text category X + 1"
I think it will be more convenient if you press only one button (hotkey) and set different text for different categories of tasks.
Category.gif
Category.gif (669.16 KiB) Viewed 2783 times
Here is the code for AutoHotKey

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Numpad2::
ControlGetText, TextFromRichField, RICHEDIT50W2, ahk_exe ToDoList.exe  ; RICHEDIT50W2 - the name of the comment tab
if StrLen(TextFromRichField) != 0
	MsgBox, you have something in the text field: %TextFromRichField%    ; Checking whether you have any other text in the comment tab
else
	ControlGetText, CategoryName, ComboBox39, ahk_exe ToDoList.exe ; CombBox39 the name of the class of the input field for Category
	if CategoryName = BooksToRead ; BooksToRead - is the name of category, replace it with a category from your TDL
	{
		TextForCategory_1 = Main points of the chapter: `n1. `n2. `n3. `nContradictions: `n1. `n2. ; Replace the text with yours 
		ControlSetText, RICHEDIT50W2, %TextForCategory_1% , ahk_exe ToDoList.exe  ; RICHEDIT50W2 -  the name of the comment tab
		
	}
	if CategoryName = EVD ; The name of second category
	{
		TextForCategory_1 = This text is for another category
		ControlSetText, RICHEDIT50W2, %TextForCategory_1% , ahk_exe ToDoList.exe
	}


Post Reply