Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

eBook Reader


  • Please log in to reply
7 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
This is for someone into reading. This eBook reader is for plain text eBooks (not for PDF etc.).
(Thanx to Chris for putting all those nice customisabilities in Progress command)

here's a scaled down screenshot.

Posted Image


The features are:
Remembers the last eBook being read.
Remembers where you left reading the eBook, and opens at the same place.
Shows progress bar reflecting the current position in the complete eBook.

Controls:
Mouse Wheel up/down
Page up/down
Esc to exit

To open another eBook use tray menu

;___________________________________________
;_______eBook Reader  - Rajat_______________


;_______User Settings_______________________

;Set Lines, Font size, Window Height & Width here.

Lines = 22
FSize = 12
Height = 500
Width = 700

;___________________________________________



SetBatchLines, 10ms
SetFormat, Float, 0.0

;opens fileopen window if no last open file found
IniRead, eBook, %a_scriptdir%\eBookreader.ini, eBooks, LastFile, Error
IfEqual, eBook, Error, FileSelectFile, eBook, 1,, Open eBook
IfNotExist, %eBook%, ExitApp

;records lastfile
IniWrite, %eBook%, %a_scriptdir%\eBookreader.ini, eBooks, LastFile


;Counts total lines
runwait, %comspec% /c find /c /v "fdsaqfjd sf-5399534" "%eBook%" >%temp%\lines.txt,, hide
FileReadLine, TotalLines, %temp%\lines.txt, 2
StringGetPos, spos, TotalLines, %a_space%, R
spos ++
StringTrimLeft, TotalLines, TotalLines, %spos%
TotalLines ++
FileDelete, %temp%\lines.txt


;adds custom menu item on top
Menu, tray, nostandard
Menu, tray, add, Open eBook, OpenBook
Menu, tray, standard


;creates reader window
Progress, C0 T W%Width% H%Height% FS%FSize% ZX20 M1 Y5, `n`n%eBook%,, eBook Reader
WinSet, AlwaysOnTop, Off, eBook Reader
WinActivate, eBook Reader
IniRead, LineNum, %a_scriptdir%\eBookreader.ini, eBooks, %eBook%, 1
Sleep, 1000
Gosub, PageShow

Exit


OpenBook:
	FileSelectFile, eBook, 1,, Open eBook

	runwait, %comspec% /c find /c /v "fdsaqfjd sf-5399534" "%eBook%" >%temp%\lines.txt,, hide
	FileReadLine, TotalLines, %temp%\lines.txt, 2
	StringGetPos, spos, TotalLines, %a_space%, R
	spos ++
	StringTrimLeft, TotalLines, TotalLines, %spos%
	TotalLines ++
	FileDelete, %temp%\lines.txt
	
	Progress, C0TW%Width%H%Height%FS%FSize%ZX20M1Y5, `n`n%eBook%,, eBook Reader
	WinSet, AlwaysOnTop, Off, eBook Reader
	WinActivate, eBook Reader
	IniRead, LineNum, %a_scriptdir%\eBookreader.ini, eBooks, %eBook%, 1
	Sleep, 1000
	Gosub, PageShow
Return
	

PageShow:
	LineCount = %LineNum%
	Loop, %Lines%
	{
		FileReadLine, CurrLine, %eBook%, %LineCount%
		LineCount ++
		IfGreaterOrEqual, LineCount, %TotalLines%, Break
		Text = %Text%`n%CurrLine%
	}
	
	Percent = %LineNum%
	
	EnvAdd, Percent, 0.0
	EnvAdd, TotalLines, 0.0
	
	Percent *= 100
	Percent /= %TotalLines%
	
	Progress, %Percent%
	
	Progress,, %Text%
	Text =
Return



~WheelDown::
	IfWinNotActive, eBook Reader,, Return
	Test = %LineNum%
	Test += 3
	IfGreaterOrEqual, Test, %TotalLines%, Return
	LineNum += 3
	Gosub, PageShow
Return



~WheelUp::
	IfWinNotActive, eBook Reader,, Return
	LineNum -= 3
	IfLess, LineNum, 1, SetEnv, LineNum, 1
	Gosub, PageShow
Return



~PgDn::
	IfWinNotActive, eBook Reader,, Return
	Test = %LineNum%
	Test += %Lines%
	IfGreaterOrEqual, Test, %TotalLines%, Return
	LineNum += %Lines%
	LineNum --
	Gosub, PageShow
Return



~PgUp::
	IfWinNotActive, eBook Reader,, Return
	LineNum -= %Lines%
	LineNum ++
	IfLess, LineNum, 1, SetEnv, LineNum, 1
	Gosub, PageShow
Return



~Esc::
	IfWinNotActive, eBook Reader,, Return
	IniWrite, %LineNum%, %a_scriptdir%\eBookreader.ini, eBooks, %eBook%
	IniWrite, %eBook%, %a_scriptdir%\eBookreader.ini, eBooks, LastFile
	ExitApp
Return


MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
You've got a script for everything under the sun!

beardboy
  • Members
  • 443 posts
  • Last active: May 27 2017 08:41 AM
  • Joined: 02 Mar 2004
Thanks to AutoHotkey he has the flexibility to write anything under the sun. ;)

thanks,
beardboy

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
beardboy is right Chris, had it not been ur efforts to make ahk better everyday, i could only imagine what i wanted to have... not create it!

and then most of my scripts do things that i wanted to have and the existing softwares didn't cater.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
This is a wkd script!

Only one bug: The last line appears many times, example:

Line 1
Line 2
Line 3
Line 3
Line 3
Line 3 (Line 3 appears many times)


autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
thanx. i'll look into that.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
i've fixed the bug, thanx Titan.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012

Thanks to AutoHotkey he has the flexibility to write (and fix) anything under the sun. ;)

thanks,
beardboy


:D

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit