Skip to content

Instantly share code, notes, and snippets.

@aviaryan
Created April 8, 2013 06:47
Show Gist options
  • Save aviaryan/5334731 to your computer and use it in GitHub Desktop.
Save aviaryan/5334731 to your computer and use it in GitHub Desktop.
Replace variables denoted by delimiters in Notepad
/*
Program Author = Avi Aryan
USAGE::
Run the Script
Open your text file with all variables in NOTEPAD..By Notepad , i mean Notepad
Hit Ctrl+Alt+F to start.
When First Match is found,Change the text to required text and then hit F6 . Spaces will be automatic.
...
PREREQUISITIES::
Have Single Space in between all your Text.. eg --> Avi Aryan and not Avi Aryan
KNOWN BUG::
If last line is a variable, enter a Space after it..
Eg -->
Make - [line]
[line]%a_space%
Please Dont post it anywhere without my permission.
*/
;CONFIGURE
StartVariableSign = [
lastlineno = 20 ;number of words in the last line of text file
waitingtime = 100 ;if you have problems with script , better increase it.
;***************************************************************************************
SetBatchLines, -1
^!f::
oldclip := Clipboard
Send, ^{Home}
loop
{
Send, +{Down}
Send, ^c{up}
IfNotEqual,secondline
{
IfInString,clipboard,%secondline%
{
gosub, lastlinemanagement
break
}
}
StringReplace,firstline,clipboard,`r`n,
secondline := firstline
gosub, middleloop ;Middle
Send, {Down}{Home}
}
return
middleloop:
loop
{
StringGetPos,pos,firstline,%StartVariableSign%,L
if (pos == -1)
break
else
{
if (pos==0)
{
Sendplay, ^+{right}
Tooltip,Write your Replacement`nDont Enter Space`nIt will be added automatically`nHit F6 to Continue.
keywait, F6, D
Send, {Space}
Tooltip
}
else
Send, ^+{right}
Send, {left}{right}
StringGetPos,pos_space,firstline,%a_space%,L
StringGetPos,pos_tab,firstline,%a_tab%,L
IfGreater,pos_tab,%pos_space%
linecutindex := pos_tab
else
linecutindex := pos_space
linecutindex+=1
StringTrimLeft,firstline,firstline,%linecutindex%
sleep, %waitingtime%
}
}
return
lastlinemanagement:
Send, {Down}
Send, {Ctrl Down}
Send, {lShift Down}
Send, {right %lastlineno%}
Send, ^c
Send, {Ctrl up}
Send, {Shift up}
Send, {Home}
StringReplace,firstline,clipboard,`r`n,
gosub, middleloop
MsgBox, 64, Done, Done
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment