I was looking for a way to make it automatically check for updates, and I know there is a better way to do this, but i'm a n00b. so heres my attempt at it.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Debug = -1
#persistent
SetBatchLines, 10ms
Menu, tray, Icon, %ProgramFiles%\Internet Explorer\iexplore.exe, 1
Menu, tray, nostandard
Menu, tray, add, Credit, credits
Menu, tray, add, Add new URL, newurl
Menu, tray, add, Check All URLs, CheckAll
Menu, tray, add
Menu, tray, add, Check Particular URL, Check
Menu, tray, add, Remove Particular URL, Remove
Menu, tray, add, Edit Particular URL, EditURL
Menu, tray, add
Menu, tray, add, Debug
Menu, tray, add, Restart
Menu, tray, add, Exit, Quit
Menu, tray, add
Menu, tray, add, Auto-check updates, Autocheck
;URL# has url
;URL#x has starting code
;URL#y has ending code
Loop, read, %a_scriptdir%\WebWatch.ini
{
IfNotInString, a_loopreadline, http://, Continue
num++
StringGetPos, eqpos, a_loopreadline, =
StringLeft, URL%num%, a_loopreadline, %eqpos%
StringTrimRight, URLx, URL%num%, 0
IniRead, param, %a_scriptdir%\WebWatch.ini, WebWatch, %URLx%
StringGetPos, sep, param, |***|
StringLeft, URL%num%x, param, %sep%
sep +=5
StringTrimLeft, URL%num%y, param, %sep%
}
;URL#name has main id of website
;URL#data has relevant code
Loop, %num%
{
StringGetPos, spos, URL%a_index%, //
spos += 2
StringTrimLeft, URL%a_index%name, URL%a_index%, %spos%
StringReplace, URL%a_index%name, URL%a_index%name, /, _, All
StringTrimRight, currname, URL%a_index%name, 0
StringTrimRight, currdata, URL%a_index%data, 0
}
Exit
;___________________________________________
CheckAll:
;%updated% has list of updated websites delimited by `n
Updated =
Loop, %num%
{
StringTrimRight, currurl, URL%a_index%, 0
StringTrimRight, currname, URL%a_index%name, 0
StringTrimRight, currdata, URL%a_index%data, 0
StringTrimRight, currx, URL%a_index%x, 0
StringTrimRight, curry, URL%a_index%y, 0
Currdata =
Loop, read, %a_scriptdir%\%currname%.txt
currdata = %currdata%`n%a_loopreadline%
StringTrimLeft, currdata, currdata, 1
URL%a_index%data = %currdata%
TempIndex = %A_Index%
Random, randa, 1, 99999
Random, randb, 1, 99999
FileDelete, %temp%\temp.html
IfLess, Debug, 0, URLDownloadToFile, %currurl%?fakeParam=%Randa%%Randb%, %temp%\temp.html
IfGreater, Debug, 0, URLDownloadToFile, %currurl%, %temp%\temp.html
x = 0
y = 0
tempdata =
Loop, read, %temp%\temp.html
{
IfEqual, x, 0, IfNotInString, a_loopreadline, %currx%, continue
IfEqual, x, 0
{
StringGetPos, xpos, a_loopreadline, %currx%
StringLen, len, currx
xpos += %len%
StringTrimLeft, templine, a_loopreadline, %xpos%
x = 1
}
IfNotEqual, x, 0, Setenv, templine, %a_loopreadline%
IfInString, templine, %curry%
y = 1
tempdata = %tempdata%`n%templine%
IfEqual, y, 1, break
}
StringTrimLeft, tempdata, tempdata, 1
IfNotEqual, tempdata,, IfNotEqual, currdata, %tempdata%
{
FileDelete, %a_scriptdir%\%currname%.txt
FileAppend, %tempdata%, %a_scriptdir%\%currname%.txt
StringTrimRight, URL%TempIndex%data, tempdata, 0
Updated = %Updated%`n%currurl%
msgbox, 4, WebWatch, %currurl% updated`n`n Do you want to see the updated page?
IfMsgBox, Yes, Run, %currurl%?fakeParam=%Randa%%Randb%
}
}
StringTrimLeft, Updated, Updated, 1
IfEqual, Updated,, TrayTip,, No Updates, 1
Return
;___________________________________________
newurl:
InputBox, newURL, WebWatch, Enter the URL for update check:
IfEqual, errorlevel, 1, Return
IfEqual, newURL,, Return
IfNotInString, newURL, http://, SetEnv, newURL, http://%newURL%
InputBox, newURLx, WebWatch, Enter the URL's starting code:
IfEqual, errorlevel, 1, Return
IfEqual, newURL,, Return
InputBox, newURLy, WebWatch, Enter the URL's ending code:
IfEqual, errorlevel, 1, Return
IfEqual, newURL,, Return
IniWrite, %newURLx%|***|%newURLy%, %a_scriptdir%\WebWatch.ini, WebWatch, %newURL%
Msgbox, 4, WebWatch, The program needs to restart to process new URL.`nRestart now?
IfMsgbox, Yes, Reload
Return
;___________________________________________
Check:
Gosub, ShowMenu
IfGreater, mY, %MenuItems%, Return
StringTrimRight, currurl, URL%mY%, 0
StringTrimRight, currname, URL%mY%name, 0
StringTrimRight, currx, URL%mY%x, 0
StringTrimRight, curry, URL%mY%y, 0
Currdata =
Loop, read, %a_scriptdir%\%currname%.txt
currdata = %currdata%`n%a_loopreadline%
StringTrimLeft, currdata, currdata, 1
URL%mY%data = %currdata%
;Checking particular URL
Random, randa, 1, 99999
Random, randb, 1, 99999
FileDelete, %temp%\temp.html
IfLess, Debug, 0, URLDownloadToFile, %currurl%?fakeParam=%Randa%%Randb%, %temp%\temp.html
IfGreater, Debug, 0, URLDownloadToFile, %currurl%, %temp%\temp.html
x = 0
y = 0
tempdata =
Updated =
Loop, read, %temp%\temp.html
{
IfEqual, x, 0, IfNotInString, a_loopreadline, %currx%, continue
IfEqual, x, 0
{
StringGetPos, xpos, a_loopreadline, %currx%
StringLen, len, currx
xpos += %len%
StringTrimLeft, templine, a_loopreadline, %xpos%
x = 1
}
IfNotEqual, x, 0, Setenv, templine, %a_loopreadline%
IfInString, templine, %curry%
y = 1
tempdata = %tempdata%`n%templine%
IfEqual, y, 1, break
}
StringTrimLeft, tempdata, tempdata, 1
IfNotEqual, tempdata,, IfNotEqual, currdata, %tempdata%
{
FileDelete, %a_scriptdir%\%currname%.txt
FileAppend, %tempdata%, %a_scriptdir%\%currname%.txt
StringTrimRight, URL%mY%data, tempdata, 0
Updated = %Updated%`n%currurl%
}
StringTrimLeft, Updated, Updated, 1
IfNotEqual, Updated,
{
MsgBox, 4, WebWatch, %currurl% is updated.`nDo you want to see the updated page?
IfMsgbox, Yes, run, %currurl%
}
IfEqual, Updated,, TrayTip,, No Updates, 1
Return
;___________________________________________
Remove:
Gosub, ShowMenu
IfGreater, mY, %MenuItems%, Return
StringTrimRight, currurl, URL%mY%, 0
StringTrimRight, currname, URL%mY%name, 0
Msgbox, 4, WebWatch, Confirm deletion of all data relating to`n%currurl%
IfMsgbox, yes
{
IniDelete, %a_scriptdir%\WebWatch.ini, WebWatch, %currurl%
FileDelete, %a_scriptdir%\%currname%.txt
ToDo =
Return
}
Return
;___________________________________________
EditURL:
Gosub, ShowMenu
IfGreater, mY, %MenuItems%, Return
StringTrimRight, currurl, URL%mY%, 0
StringTrimRight, currx, URL%mY%x, 0
StringTrimRight, curry, URL%mY%y, 0
InputBox, newx, WebWatch, Enter the URL's starting code:,,,,,,,, %currx%
InputBox, newy, WebWatch, Enter the URL's ending code:,,,,,,,, %curry%
IniWrite, %newx%|***|%newy%, %a_scriptdir%\WebWatch.ini, WebWatch, %currurl%
Msgbox, 4, WebWatch, The program needs to restart to process new info.`nRestart now?
IfMsgbox, Yes, Reload
Return
;___________________________________________
ShowMenu:
MenuTitle = Select URL to check
URLMenu = %MenuTitle%
MenuItems =
Loop, %Num%
{
StringTrimRight, currurl, URL%a_index%, 0
MenuItems ++
URLMenu = %URLMenu%`n%currurl%
}
MouseGetPos, mX, mY
ToolTip, %URLMenu%, %mX%, %mY%
WinActivate, %MenuTitle%
;Waiting for mouse button down
Loop
{
GetKeyState, State, LButton
if State = D
Break
Sleep, 10
}
IfWinNotActive, %MenuTitle%
{
ToolTip
Return
}
CoordMode, Mouse, Relative
MouseGetPos, mX, mY
ToolTip
mY -= 3 ;space after which first line starts
mY /= 13 ;space taken by each line
Return
;___________________________________________
Debug:
menu, tray, ToggleCheck, Debug
Debug *= -1
IfGreater, Debug, 0, Menu, tray, standard
IfLess, Debug, 0, Menu, tray, nostandard
Return
Restart:
Reload
Return
Autocheck:
Loop,24 ;24
{
TrayTip,, Scanning, 1
;%updated% has list of updated websites delimited by `n
Updated =
Loop, %num%
{
StringTrimRight, currurl, URL%a_index%, 0
StringTrimRight, currname, URL%a_index%name, 0
StringTrimRight, currdata, URL%a_index%data, 0
StringTrimRight, currx, URL%a_index%x, 0
StringTrimRight, curry, URL%a_index%y, 0
Currdata =
Loop, read, %a_scriptdir%\%currname%.txt
currdata = %currdata%`n%a_loopreadline%
StringTrimLeft, currdata, currdata, 1
URL%a_index%data = %currdata%
TempIndex = %A_Index%
Random, randa, 1, 99999
Random, randb, 1, 99999
FileDelete, %temp%\temp.html
IfLess, Debug, 0, URLDownloadToFile, %currurl%?fakeParam=%Randa%%Randb%, %temp%\temp.html
IfGreater, Debug, 0, URLDownloadToFile, %currurl%, %temp%\temp.html
x = 0
y = 0
tempdata =
Loop, read, %temp%\temp.html
{
IfEqual, x, 0, IfNotInString, a_loopreadline, %currx%, continue
IfEqual, x, 0
{
StringGetPos, xpos, a_loopreadline, %currx%
StringLen, len, currx
xpos += %len%
StringTrimLeft, templine, a_loopreadline, %xpos%
x = 1
}
IfNotEqual, x, 0, Setenv, templine, %a_loopreadline%
IfInString, templine, %curry%
y = 1
tempdata = %tempdata%`n%templine%
IfEqual, y, 1, break
}
StringTrimLeft, tempdata, tempdata, 1
IfNotEqual, tempdata,, IfNotEqual, currdata, %tempdata%
{
FileDelete, %a_scriptdir%\%currname%.txt
FileAppend, %tempdata%, %a_scriptdir%\%currname%.txt
StringTrimRight, URL%TempIndex%data, tempdata, 0
Updated = %Updated%`n%currurl%
msgbox, 4, WebWatch, %currurl% updated`n`n Do you want to see the updated page?
IfMsgBox, Yes, Run, %currurl%?fakeParam=%Randa%%Randb%
}
}
StringTrimLeft, Updated, Updated, 1
IfEqual, Updated,, TrayTip,, No Updates, 1
sleep 600000 ;600000
}
msgbox, Done checking
Return
credits:
msgbox, All credit goes to Rajat and his "Smart Webpage Update Checker" `n(http://www.autohotkey.com/forum/topic550.html&highlight=website+update)
Return
Quit:
ExitApp
Return