2013-07-29 95 views
0

我想在某些會員登錄網站時收到通知。該網站的登錄成員列表通常會擴展到三個或四個HTML頁面,除了結尾的頁碼外,每個URL都相同。我有一個文本文件,列出了我希望通知的幾個成員。下面的腳本成功地通知我列表中的任何成員是否登錄。它會下載第一頁,搜索該頁面上的每個成員,如果找到則通知該成員,然後在睡眠五分鐘之前重複該過程以及每個剩餘頁面並開始過度。AutoHotKey。網站登錄通知

有幾十個,我想改進這種方法,但對於初學者,我想解決一個重複通知的問題。只要他們已經登錄,我會每五分鐘收到一次有關同一成員的通知。一旦我確定某個成員的MsgBox,我希望腳本繼續搜索沒有重新通知我的成員任何先前已確認的登錄信息。我想知道是否應該重新考慮這件事,完全擺脫MsgBox,並且有一個帶有成員/狀態列表的始終打開的窗口,以及僅當狀態發生變化時纔有SoundBeep。 AutoHotKey可以用來實現嗎?我最近才發現了AHK,而且我沒有編程或腳本編程經驗,所以我花了很長時間纔想出了我目前爲止所做的。感謝您的任何幫助和建議。

Loop 
{ 
    n := 1 
    While n < 5 
    { 
     UrlDownloadToFile, website/LoggedIn&page=%n%, Source_%n%.txt 
     FileRead, PageVar_%n%, Source_%n%.txt 
     Loop, read, MemberList.txt 
     { 
      Loop, parse, A_LoopReadLine, `n 
      { 
       MemberVar = %A_LoopField% 
       IfInString, PageVar_%n%, %MemberVar% 
       { 
        SoundBeep 
        MsgBox, 4096, Logged In, %MemberVar% is logged in 
       } 
      } 
     } 
     n := n + 1 
    } 
    Sleep 300000 
} 

回答

0

好吧,這可能是一個豆蔻更多,那麼你需要

但嘗試一下,看看它是否適合你...

; Create the ListView with one column, Name: 
Gui, Add, ListView, r20 w200 vMyListView, Name 
; Create a object "online" 
online := [] 
gosub, check ; Run the subpart one time 
Settimer, check, 300000 ; and then this will run the cheak evry 300000 ms 
return 


check: 
Gui, show ; Show the listveiw 
GuiControl, -Redraw, MyListView ; Stop the listveiw from updateing 
While A_Index < 5 
{ 
    Url = website/LoggedIn&page=%A_Index% 
    Source := URLToVar(URL) 
    FileRead, Membs, MemberList.txt 
    Loop, parse, Membs, `n 
    { 
     IfInString, Source, %A_LoopField% 
     { 
       SoundBeep 
       Online[A_LoopField] := true 
     } 
     else if Online[A_LoopField] 
      Online.Remove(A_LoopField) 
    } 
} 
LV_Delete() 
for key in online 
{ 
    msgbox % Key 
    LV_Add("", Key) 
} 
GuiControl, +Redraw, MyListView ; let the listveiw update 
Return 

GuiClose: ; Indicate that the script should exit automatically when the window is closed. 
ExitApp 

URLToVar(URL) { 
    ComObjError(0) 
    WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1") 
    WebRequest.Open("GET", URL) 
    WebRequest.Send() 
    Return WebRequest.ResponseText() 
     , ComObjError(0) 
    } 

希望它可以幫助你走出

+0

感謝您的快速反應,blackholyman。我會試試這個,讓你知道它是怎麼回事。 –