Simple Commenting Tool
Posted: 14 Feb 2019, 03:13
Hey guys,
This is obviously a lot of code for nothing but I always wanted to be able to automatically place a separator comment and the word to be centered without any manual intervention. I tried searching for such a tool countless times but to no avail so i decided to give it a try and see if i will be able to pull this off on my own.
Let me show you what i mean.
;#########################################~Hotkeys~##########################################
;########################################~Hotstrings~#########################################
As I am still a noob there is probably a much better way to achieve this than the way i have done it but for me the important thing is that it does what it has been designed for. I will be happy if someone finds it usefull. If not, i'll still use it for my scripts
I have tested it in notepad and in SciTE and so far it works flawlessly. It is limited to 32 characters but still those are a lot of letters you can use for a comment
This is obviously a lot of code for nothing but I always wanted to be able to automatically place a separator comment and the word to be centered without any manual intervention. I tried searching for such a tool countless times but to no avail so i decided to give it a try and see if i will be able to pull this off on my own.
Let me show you what i mean.
;#########################################~Hotkeys~##########################################
;########################################~Hotstrings~#########################################
As I am still a noob there is probably a much better way to achieve this than the way i have done it but for me the important thing is that it does what it has been designed for. I will be happy if someone finds it usefull. If not, i'll still use it for my scripts
I have tested it in notepad and in SciTE and so far it works flawlessly. It is limited to 32 characters but still those are a lot of letters you can use for a comment
Code: Select all
#SingleInstance, Force
Gui, +AlwaysOnTop
Gui, Font, s10 Verdana
Gui, Add, Edit, vCommentWord h20 w220 Limit32, ; Limit the field entry to 32 symbols
Gui, Add, Button, x95 y35 h22 w60 gOk, OK
Gui, Show, AutoSize
Return
Ok:
Gui, Submit, NoHide
MsgBox, 262180,, Do you wish to use the following as your comment?`n%CommentWord%
IfMsgBox, Yes
{
NumVar := % StrLen(CommentWord) ; Calculating what is the lenght of the word/s you have entered and saving it in a variable
NumVarHalf := NumVar/2 ; Dividing the number and saving it in another variable
GuiControl,, CommentWord ; Clearing the GUI edit box
MsgBox, 262144,, Use F12 to paste the comment!
}
else
GuiControl,, CommentWord
Return
F12::
If (NumVarHalf = 0.5){ ; If the devided number equals 0.5 (i.e. you have entered only 1 symbol) execute the following:
FinalNum := NumVarHalf*90 ; Multiplying the devided number by 90 (just a random number of preference (45 in this case) for the symbols on both sides of the word/s you chose)
FinalNum2 := FinalNum-1 ; As the result is an odd number we remove 1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%} ; The displayed result is 44 "#" symbols ~ the word/s you chose ~ 45 "#" symbols (Again, as it is an odd number by removing the first symbol, visually it should appear as if in the middle)
}
If (NumVarHalf = 1){
FinalNum := NumVarHalf*44
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 1.5){
FinalNum := NumVarHalf*29.5
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 2){
FinalNum := NumVarHalf*21.5
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 2.5){
FinalNum := NumVarHalf*17.5
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 3){
FinalNum := NumVarHalf*14.3
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 3.5){
FinalNum := NumVarHalf*12.2
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 4){
FinalNum := NumVarHalf*10.4
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 4.5){
FinalNum := NumVarHalf*9.2
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 5){
FinalNum := NumVarHalf*8
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 5.5){
FinalNum := NumVarHalf*7.3
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 6){
FinalNum := NumVarHalf*6.5
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 6.5){
FinalNum := NumVarHalf*6
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 7){
FinalNum := NumVarHalf*5.5
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 7.5){
FinalNum := NumVarHalf*5.1
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 8){
FinalNum := NumVarHalf*4.7
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 8.5){
FinalNum := NumVarHalf*4.4
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 9){
FinalNum := NumVarHalf*4
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 9.5){
FinalNum := NumVarHalf*3.8
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 10){
FinalNum := NumVarHalf*3.5
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 10.5){
FinalNum := NumVarHalf*3.4
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 11){
FinalNum := NumVarHalf*3.1
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 11.5){
FinalNum := NumVarHalf*3
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 12){
FinalNum := NumVarHalf*2.8
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 12.5){
FinalNum := NumVarHalf*2.7
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 13){
FinalNum := NumVarHalf*2.5
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 13.5){
FinalNum := NumVarHalf*2.4
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 14){
FinalNum := NumVarHalf*2.25
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 14.5){
FinalNum := NumVarHalf*2.2
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 15){
FinalNum := NumVarHalf*2
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 15.5){
FinalNum := NumVarHalf*1.95
FinalNum2 := FinalNum-1
SendInput, `;{# %FinalNum2%}~%CommentWord%~{# %FinalNum%}
}
If (NumVarHalf = 16){
FinalNum := NumVarHalf*1.87
SendInput, `;{# %FinalNum%}~%CommentWord%~{# %FinalNum%}
}
Return
GuiClose:
ExitApp