Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Script for regularly checking for new Stack Exchange tag questions and/or new inbox items.
- This script is obviously only helpful if you have your Windows PC turned on with the script active.
- (c)2015_03_02 Blauhirn
- eochgls@web.de
- .___.
- {o,o}
- /)___)
- --"-"--
- Important: You need to be logged in permanenlty to StackExchange WITHIN INTERNET EXPLORER. Ahk accesses cache from there.
- One might want to put this script into his/her Windows startup folder
- Win7: C:UsersUSERNAMEAppDataRoamingMicrosoftWindowsStart MenuProgramsStartup
- */
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; USER-DEFINED SECTION
- /*
- INTERVALS
- between two checks
- ENTITY: SECONDS
- For no checks at all, state a number <= 0, e.g. -1
- */
- check_tags_interval = 60
- check_inbox_interval = 300
- /*
- EMAIL
- (optional)
- state a GOOGLE MAIL account NAME (withOUT the "@gmail.com"-part), if you want to automatically send an E-Mail to yourself when this very ahk-script has got a new notification.
- If you do not want to use this feature, leave the account name empty
- */
- gmail_accountName =
- gmail_accountPass =
- /*
- INBOX
- State the link to your Stack Exchange inbox, if you want to use this feature. If not, set check_inbox_interval to -1.
- You can get your inbox Link by clicking on the inbox and scrolling to its very bottom
- example:
- http://stackexchange.com/users/4667026/blauhirn?tab=inbox
- */
- linkToTheUserprofileInbox =
- /*
- TAGS
- note: you do NOT HAVE TO subscribe to these within StackExchange itself
- state Stack Exchange tag sites to check after each check_tags_interval. If you do not want to check for any tags at all, set check_tags_interval to -1.
- syntax:
- site1 = http://stackoverflow.com/questions/tagged/autohotkey
- site2 = http://codereview.stackexchange.com/questions/tagged/java
- note: THE SITES HAVE TO BE IN ORDER, STARTING WITH 1
- add any tag sites of your preference:
- */
- site1 = http://stackoverflow.com/questions/tagged/autohotkey
- site2 = http://codereview.stackexchange.com/questions/tagged/java
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; THE CODE BELOW DOES NOT HAVE TO BE CHANGED
- #NoEnv
- #persistent
- SendMode Input
- SetWorkingDir %A_ScriptDir%
- if(check_tags_interval > 0)
- {
- loop
- {
- site_ := site%a_index%
- if site_ =
- {
- if a_index = 1
- {
- msgbox, You set a timer for tags but did not include any sites to check! Script will exit.
- exitapp
- }
- break
- }
- else
- tmp = §§§K§J§KJ§§J§J§%site_%§§L§L§L§OL§
- site%a_index%_short := regExReplace(tmp, "U)§§§K§J§KJ§§J§J§http://(.+)..*§§L§L§L§OL§","$1")
- site__short := site%a_index%_short
- iniRead, lastNewQuestion_%site__short%, config.ini, %site__short%, lastNewQuestion, default
- }
- goSub, checkTags
- check_tags_interval := check_tags_interval * 1000
- setTimer, checkTags, %check_tags_interval%
- }
- if(check_inbox_interval > 0)
- {
- iniRead, lastInbox, config.ini, Inbox, lastInbox, default
- goSub, checkInbox
- check_inbox_interval := check_inbox_interval * 1000
- setTimer, checkInbox, %check_inbox_interval%
- }
- return
- ; the following function origins from Sergio @ http://www.autohotkey.com/board/topic/95823-send-email-through-gmail-using-mailsend/
- sendMail(emailToAddress,emailPass,emailFromAddress,emailSubject,emailMessage)
- {
- mailsendlocation := A_MyDocuments
- IfNotExist, %mailsendlocation%mailsend1.17b12.exe
- URLDownloadToFile, https://mailsend.googlecode.com/files/mailsend1.17b12.exe, %mailsendlocation%mailsend1.17b12.exe
- Run, %mailsendlocation%mailsend1.17b12.exe -to %emailToAddress% -from %emailFromAddress% -ssl -smtp smtp.gmail.com -port 465 -sub "%emailSubject%" -M "%emailMessage%" +cc +bc -q -auth-plain -user "%emailFromAddress%" -pass "%emailPass%"
- }
- checkTags:
- loop
- {
- site_ := site%a_index%
- site__short := site%a_index%_short
- if site_ =
- break
- fileDelete, tmp_tag.html
- urlDownloadToFile, %site_%, tmp_tag.html
- fileRead, tag_fileContent, tmp_tag.html
- fileDelete, tmp_tag.html
- tag_fileContent = §§§K§J§KJ§§J§J§%tag_fileContent%§§L§L§L§OL§
- firstNewQuestion := regExReplace(tag_fileContent,"U)§§§K§J§KJ§§J§J§[wW]*<div class=[W]summary[W]>[W]*<h3><a href=[W]([^>]+)[W] class=[W]question-hyperlink[W]>[wW]*§§L§L§L§OL§","$1")
- tmp := lastNewQuestion_%site__short%
- if firstNewQuestion != %tmp%
- {
- tooltip, New Question for Tag "%site__short%"!!`n(%firstNewQuestion%)
- IniWrite, %firstNewQuestion%, config.ini, %site__short%, lastNewQuestion
- lastNewQuestion_%site__short% = %firstNewQuestion%
- if gmail_accountName !=
- {
- accn = %gmail_accountName%@gmail.com
- FormatTime, CurrentDateTime, M/d/yyyy, yyyy_MM_dd_H.mm
- msg = New Question for Tag "%site__short%"!!`n(%firstNewQuestion%)`n`nAlso see %site_%.`n`n(Sent from ahk-application Desktop @ %CurrentDateTime%)
- sendMail(accn,gmail_accountPass,acc,"New Stack Exchange notification",msg)
- }
- msgbox,4,, New Question for Tag "%site__short%"!!`n(%firstNewQuestion%)`n`nOpen "%site_%" in Browser now?
- ifmsgbox yes
- run %site_%
- sleep, 1500
- tooltip
- }
- }
- return
- checkInbox:
- fileDelete, tmp_inbox.html
- urlDownloadToFile, *0 %linkToTheUserprofileInbox%, tmp_inbox.html
- fileRead, inbox_fileContent, tmp_inbox.html
- fileDelete, tmp_inbox.html
- ifinstring, inbox_fileContent, sign up
- {
- msgbox, Inbox check failed! You're not logged in!`nImportant: You need to be logged in permanenlty to StackExchange WITHIN INTERNET EXPLORER. Ahk accesses cache from there.
- return
- }
- inbox_fileContent = §§§K§J§KJ§§J§J§%inbox_fileContent%§§L§L§L§OL§
- firstNewInbox := regExReplace(inbox_fileContent, "U)§§§K§J§KJ§§J§J§[wW]*<table class=[W]history-table[W]>[Ww]*<span[Ww]*>([^n]+)</span>[Ww]*§§L§L§L§OL§", "$1")
- if firstNewInbox != %lastInbox%
- {
- tooltip, New Inbox Item!!`n(%firstNewInbox%)
- IniWrite, %firstNewInbox%, config.ini, Inbox, lastInbox
- lastInbox = %firstNewInbox%
- if gmail_accountName !=
- {
- accn = %gmail_accountName%@gmail.com
- FormatTime, CurrentDateTime, M/d/yyyy, yyyy_MM_dd_H.mm
- msg = New Inbox Item!!`n(%firstNewInbox%)`n`nAlso see %linkToTheUserprofileInbox%.`n`n(Sent from ahk-application Desktop @ %CurrentDateTime%)
- sendMail(accn,gmail_accountPass,acc,"New Stack Exchange notification",msg)
- }
- msgbox,4,, New Inbox Item!!`n(%firstNewInbox%)`n`nOpen "%linkToTheUserprofileInbox%" in Browser now?
- ifmsgbox yes
- run %linkToTheUserprofileInbox%
- sleep, 1500
- tooltip
- }
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement