#singleinstance,force Autotrim,off ScriptVersion=3.1 ;filetoread contains the name of the file to read filetoread=textfile.txt ;file to write contains the name of the file to write filetowrite=hotstringsScript.ahk ;to add a trigger, put it after the '='.please notice that colons have to be added like this: `, trigger= ;the time for the display of the tooltip (in milliseconds) TooltipTime=1000 ;the time for the timeout of the trigger triggertimeout=3000 ;the variable that controls if the script should search for repeated entries repeated=1 ;separator to be used in the repeated entries check: (internal option, don't change) separator=`= GoSub,ReadIni MsgBox,4,Show Gui?,Do you want to use the gui interface?,30000 IfMsgBox,Yes GoSub,MostraGui IfMsgBox,No GoSub,CreateFile return MostraGui: ;12 elements, h23, spaced 7 Gui, Add, ListView,gLstView x9 y5 w240 h413 , Trigger String|Result String GoSub,UpdateListView Gui, Add, Button, x258 y5 w120 h23 gGuiAccept +default , &Create File! Gui, Add, Text, x258 y35 w120 h23 ,Trigger: Gui, Add, Edit, x258 y65 w120 h23 vtrigger,%trigger% Gui, Add, Text, x258 y95 w120 h23 ,Time for the tooltip: Gui, Add, Edit, x258 y125 w120 h23 vtooltiptime,%tooltiptime% Gui, Add, Text, x258 y155 w120 h23 ,Trigger Timeout: Gui, Add, Edit, x258 y185 w120 h23 vTriggerTimeout,%triggerTimeout% Gui, Add, Text, x258 y215 w120 h23 ,File to Write: Gui, Add, Edit, x258 y245 w120 h23 vfiletowrite,%filetowrite% Gui, Add, Text, x258 y275 w120 h23 ,File to Read: Gui, Add, Edit, x258 y305 w120 h23 vfiletoread,%filetoread% Gui, Add,Checkbox,x258 y335 w120 h23 Checked%repeated% vRepeated, Check for repeated entries? Gui, Add, Button, x258 y365 w120 h23 gReadFile,&Reload Gui, Add, Button, x258 y395 w120 h23 gAboutBox,About/&Donate Gui, Show,, by jgpaiva`, donationcoder`.com forums Return ReadFile: Gui,Submit Gui,Destroy GoSub,MostraGui return CreateFile: IfExist,%filetowrite% { MsgBox,4,Question,Do you want to overwrite the file %filetowrite%?,30000 IfMsgBox,Yes FileDelete,%filetowrite% else gosub,GuiClose } TrayTip,HotString creator,Now writing %filetowrite%...,10,1 if trigger!= FileAppend,SetKeyDelay `,-1`nSuspend`,on`nreturn`n`njgpaivabeginning:`nsuspend`,off`nsettimer`,jgpaiva`,%triggertimeout%`nsleep`,%tooltiptime%`ntooltip`nreturn`n`njgpaiva:`nsuspend`,on`nreturn`n`n`n`n,%FileToWrite% else FileAppend,SetKeyDelay `,-1`nreturn`n`n,%FileToWrite% loop,Read,%filetoread%, { string=%A_LoopReadLine% StringSplit,result,string,=, replaceable:=result1 replaced:=result2 if trigger!= { stringreplace,replaced_,replaced,`%,```%,replaceall stringreplace,replaced,replaced_,`,,```,,replaceall stringreplace,replaceable_,replaceable,`%,```%,replaceall stringreplace,replaceable,replaceable_,`,,```,,replaceall StringLower, replaced, replaced StringLower, replaceable, replaceable FileAppend,:*B0:%Replaceable%::`nsuspend`,permit`ntooltip`,%Replaced%`ngosub`,jgpaivabeginning`nreturn`n`n,%FileToWrite% FileAppend,:*C:%Replaceable%%trigger%::`nsend`,%Replaced%`nreturn`n`n,%FileToWrite% StringLeft,tempo,replaceable,1 StringUpper,tempo,tempo StringTrimLeft,replaceable,replaceable,1 Replaceable=%tempo%%replaceable% StringLeft,tempo,replaced,1 StringUpper,tempo,tempo StringTrimLeft,replaced,replaced,1 replaced=%tempo%%replaced% FileAppend,:*C:%Replaceable%%trigger%::`nsend`,%Replaced%`nreturn`n`n,%FileToWrite% StringUpper, replaceable, replaceable StringUpper, replaced, replaced FileAppend,:*C:%Replaceable%%trigger%::`nsend`,%Replaced%`nreturn`n`n`n,%FileToWrite% } else { stringreplace,replaced_,replaced,`%,```%,replaceall stringreplace,replaced,replaced_,`,,```,,replaceall stringreplace,replaceable_,replaceable,`%,```%,replaceall stringreplace,replaceable,replaceable_,`,,```,,replaceall StringLower, replaced, replaced StringLower, replaceable, replaceable FileAppend,:*C:%Replaceable%::`nTooltip`,%Replaced%`nsend`,%Replaced%`nSleep`,%TooltipTime%`nTooltip`nreturn`n`n,%FileToWrite% StringLeft,tempo,replaceable,1 StringUpper,tempo,tempo StringTrimLeft,replaceable,replaceable,1 Replaceable=%tempo%%replaceable% StringLeft,tempo,replaced,1 StringUpper,tempo,tempo StringTrimLeft,replaced,replaced,1 replaced=%tempo%%replaced% FileAppend,:*C:%Replaceable%::`nTooltip`,%Replaced%`nsend`,%Replaced%`nSleep`,%TooltipTime%`nTooltip`nreturn`n`n,%FileToWrite% StringUpper, replaceable, replaceable StringUpper, replaced, replaced FileAppend,:*C:%Replaceable%::`nTooltip`,%Replaced%`nsend`,%Replaced%`nSleep`,%TooltipTime%`nTooltip`nreturn`n`n,%FileToWrite% } } GoSub,WriteIni traytip, MsgBox,4,File Creation Complete,The file %FileToWrite% has been writter.`nWould you like to run the hotstrings script?,30000 IfMsgBox,Yes Run,%FileToWrite% exitapp GuiAccept: Gui,Submit if Repeated GoSub,RepeatedCheck GoSub,CreateFile return LstView: return UpdateListView: loop,Read,%filetoread%, { string=%A_LoopReadLine% StringSplit,result,string,=, LV_Add("",result1,result2) } return GuiEscape: GuiClose: Gui,Destroy Tooltip,File Creation Canceled sleep,%TooltipTime% Tooltip ExitApp ReadIni: IfExist,%A_ScriptName%.ini { IniRead,FileToRead, %A_ScriptName%.ini,Settings,FileToRead,%FileToRead% IniRead,FileToWrite, %A_ScriptName%.ini,Settings,FileToWrite,%Trigger% IniRead,Trigger, %A_ScriptName%.ini,Settings,Trigger,%Trigger% IniRead,ToolTipTime, %A_ScriptName%.ini,Settings,ToolTipTime,%ToolTipTime% IniRead,TriggerTimeout,%A_ScriptName%.ini,Settings,TriggerTimeout,%TriggerTimeout% IniRead,Repeated, %A_ScriptName%.ini,Settings,Repeated,%Repeated% If trigger=A_Space Trigger=%A_Space% If trigger=A_Tab Trigger=%A_Tab% } else GoSub,WriteIni return WriteIni: IfNotExist,%A_ScriptName%.ini FileAppend,%A_ScriptName%, If trigger=%A_Space% Trigger="A_Space" If trigger=%A_Tab% Trigger="A_Tab" IniWrite,%FileToRead%, %A_ScriptName%.ini,Settings,FileToRead IniWrite,%FileToWrite%, %A_ScriptName%.ini,Settings,FileToWrite IniWrite,%Trigger%, %A_ScriptName%.ini,Settings,Trigger IniWrite,%ToolTipTime%, %A_ScriptName%.ini,Settings,ToolTipTime IniWrite,%TriggerTimeout%,%A_ScriptName%.ini,Settings,TriggerTimeout IniWrite,%Repeated%, %A_ScriptName%.ini,Settings,Repeated Return RepeatedCheck: SetBatchLines,-1 FileRead,CompleteFile,%FileToRead% StringSplit,index,CompleteFile,%separator%`n, found= index0-=1 count:=floor(index0/2) count2:=count GoSub,CreateGui2 ProgressFlag:=false loop,%count% { GuiControl,2:,bar,%A_Index% If ProgressFlag break position:=2*A_Index-1 Word:=index%position% IfInString,found,%Word% continue ;msgbox,Word1=%word% count2-=1 ;msgbox,count2=%count2% loop, %count2% { position2:=position+(2*a_index) ;msgbox,position2=%position2% Word2:=index%position2% ;msgbox,Word2=%Word2% if Word=%word2% found=%found% %Word% , } } Gui, 2:destroy if found= return else { StringTrimRight,found2,found,2 msgbox,2,Repeated entries,Please remove the following repeated strings from the source file or the hotstring script might not behave correctly.`n%found2% ifmsgbox, Abort Exitapp ifmsgbox, Retry GoSub, RepeatedCheck ifmsgbox, Ignore return } Return CreateGui2: Gui, 2:Add,Text,,Now checking for duplicate entries. Press esc to skip. Gui, 2:Add, Progress,vbar w300 h20 -smooth Range0-%count%, Gui, 2:Show,,Checking for duplicates... return 2GuiClose: exitapp 2GuiEscape: Gui, 2:destroy ProgressFlag:=true return AboutBox: Gui,3:Font,Bold Gui,3:Add,Text,x+10 yp+10,HotString Script Creator V%ScriptVersion% by jgpaiva Gui,3:Font Gui, 3:Add,Text,xm,This is a small program that creates a autohotkey script with the strings that exist on a text file. Gui, 3:Add,Text,xm,It was proposed by Harrie at DonationCoder.com forums, in the following thread: Gui,3:Font,CBlue Underline Gui,3:Add,Text,xm GPost,http://www.donationcoder.com/Forums/bb/index.php?topic=2598.msg17731#msg17731 Gui,3:Font Gui,3:Add,Text,xm,Please visit us at: Gui,3:Font,CBlue Underline Gui,3:Add,Text,xm GMainSite,http://www.donationcoder.com/ Gui,3:Font Gui,3:Add,Text,xm,`nIf you like this program, please contribute to DonationCoder.com. Gui,3:Add, Button,gdonatesite x6 y160 w160 h30,&Donate To DonationCoder.com Gui,3:Add, Button,gdonateAuthor x170 y160 w115 h30,Donate To The &Author Gui,3:Add, Button,gAboutOk x346 y160 w100 h30,&Ok Gui, 3:Show,,About Box return Post: Run,http://www.donationcoder.com/Forums/bb/index.php?topic=2598.msg17731#msg17731 return MainSite: Run,http://www.donationcoder.com/ return DonateSite: Run,http://www.donationcoder.com/Donate/index.html return DonateAuthor: Run,https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=jgpaiva`%40gmail`%2ecom&item_name`=donate`%20to`%20jgpaiva&item_number`=donationcoder`%2ecom&no_shipping=1&cn=Please`%20drop`%20me`%20a`%20line`%20`%3aD&tax`=0¤cy_code=EUR&bn=PP`%2dDonationsBF&charset=UTF`%2d8 return 3GuiClose: 3GuiEscape: AboutOk: Gui,3:destroy return