Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

PureText from *.smi or html


  • Please log in to reply
2 replies to this topic
newfin
  • Guests
  • Last active:
  • Joined: --
Thank you for the great program.
Before I met AutoHotkey, I just know how to turn on and off my computer. ^^

Still, I've never had programming experience or something.
But I am enjoying scripting AutoHotkey, now.

Autohotkey documentation is the best I've read ever!
It helped me, who have nothing to do with that damn computer, to make a small application(?) that I like myself.

Anyway, as an English language learner I usually study English watching American Movies and reading the subtitles for the movies.

This script extracts pure text from *.smi, or html, though there are some modifications needed(for table etc,.)

This is the first post in the Autohotkey forum and an English-speaking BBS.
so excuse and point out any mistakes in my post.



detecthiddenwindows, on
settitlematchmode, 2

Gui, +alwaysontop +resize
Gui, color, 000000, 000000      
Gui, Font, S14 CYellow bold, Arial
Gui, Add, Edit, x50 y0 w405 h275, Drop multiple *.smi or *.htm or *.html files etc,.
Gui, Show, x-2 y-1 h276 w436, SMI2TEXT
Return

GuiSize:
controlmove, Edit1,,, % a_GuiWidth - 30, %a_GuiHeight%, SMI2TEXT
return

guidropfiles:

begin := a_tickcount

loop, parse, A_GuiControlEvent, `n
{
   dropcount = %a_index%
}

winhide, SMI2TEXT


progress, w350 h120 zh30 zy10  Fm9 Fs9, , 1/%dropcount% progressing....., SMI2TEXT
settimer, progressbar, 100 



; When you put this progressbar routine in the loop below, It slows the speed, 
; So, I made this settimer routine
; check the tickcount


loop, parse, A_GuiControlEvent, `n
{  
	cur_filedir = %a_loopfield%
        cn = %a_index%

	fileread, cur_file, %cur_filedir%

        loop, parse, cur_file, >, <
	{
	  estimate = %a_index%
         }

	   StringGetPos, startPos, cur_file, >
	   StringGetPos, endPos, cur_file, <,, %startPos%

	   stringmid, puretext, cur_file, % startPos + 2, % endPos - startPos -1
           

		  loop
		  {
		     stringGetpos, startPos, cur_file, >,, %endPos%
		     stringGetpos, endPos, cur_file, <,, %startPos%
			  if errorlevel <>  0
			     break
		     stringmid, addstring, cur_file, % startPos + 2, % endPos- startPos -1
		     setenv, puretext, %puretext%%addstring%
                     percent := (a_index/estimate)*100
		   }

	stringreplace, puretext, puretext,  ,, all   ; for smi file dummy text

	fileappend, %puretext%, %cur_filedir% [PureText].txt


       ;;;;;;;;;;;; done ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        ;stringreplace, puretext, puretext, %a_tab%,`r`n, all  ; if you need clean text for html table, you need to modify here, I think.

        ;;;;;;;;;;;;;; below is for saving paper and ink for print

	stringreplace, savepaper, puretext, `r`n, %a_space%, all
	stringreplace, savepaper, savepaper, %a_space%%a_space%%a_space%, %a_space%, all
	stringreplace, savepaper, savepaper, %a_space%%a_space%, %a_space%, all

	puretext =

	fileappend, %savepaper%, %cur_filedir% [SaveInk].txt

}


settimer, progressbar, off
progress, off

elapsedtime := a_tickcount - begin
msgbox, %elapsedtime%


winshow, SMI2TEXT
return

GuiClose:
ExitApp


progressbar:

progress, %percent%, %cur_filedir%,%cn%/%dropcount% 진행 중 ......., SMI2TEXT

return



Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Nice looking script. As an added bonus, you provided a user interface with it, which I'm sure will encourage more people to try it out and possibly make refinements to it.

AGU
  • Guests
  • Last active:
  • Joined: --

This is the first post in the Autohotkey forum and an English-speaking BBS.

So where do you originally come from? :mrgreen:
____________
Cheers
AGU