B3TA_SCR1PT3R Posted August 12, 2005 Posted August 12, 2005 How would i read all of the contents of a .log file and if the window that pops up matches the name of a line from the .txt it closes like... if winexists(".txt file contents") Then WinKill("^that") [right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]
hgeras Posted August 12, 2005 Posted August 12, 2005 Fronzeyam has done a slight mistake in his code....I'll correct that and tell you what you need to do....I imagine you want to do a popup blocker?Lets assume that your log file is called "popup.txt" and is located in C:\.... $file=FileOpen("C:\popup.txt",0) $NumLine = _FileCountLines($file) While 1 For $CountLines = 0 To $NumLine $LineRead = FileReadLine ($file, $CountLines) If WinExists($LineRead) Then WinKill($LineRead) Next Wend As you can see While 1 is an endless loop that checks For popup Windows all the time....It checks every line it reads if there is a window with that name and if true ,it will kill it....Of course endless loop is an option and you could call it whenever you like through a HotKey or at set intervals with Sleep().... C ya Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF
B3TA_SCR1PT3R Posted August 12, 2005 Author Posted August 12, 2005 (edited) It Dosent seem 2 be working..maybe i worded it rong??? #include <GuiConstants.au3> #include <file.au3> GuiCreate("Insert Title Here",400,300) $aba = GuiCtrlCreateButton("test",0,130,50,25) GuiSetState() While 1 $msg = GuiGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Select Case $msg = $aba $file = FileOpen("C:\blocklist1.log",0) $NumLine = _FileCountLines($file) For $countLines = 0 To $NumLine $LineRead = FileReadLine($file,$CountLines) If WinExists($LineRead) Then WinKill($LineRead) EndSelect WEnd FileClose($file) contents of C:\blocklist1.log: C:\ My Computer Mozilla Firefox Edited August 12, 2005 by B3TA_SCR1PT3R [right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]
B3TA_SCR1PT3R Posted August 12, 2005 Author Posted August 12, 2005 Next ???<{POST_SNAPBACK}>i had that in ther and it still didnt work so i thought that was messin it up so i took it out and now it i dont know [right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]
Valuater Posted August 12, 2005 Posted August 12, 2005 #include <GuiConstants.au3> #include <file.au3> GuiCreate("Insert Title Here",400,300) $aba = GuiCtrlCreateButton("test",0,130,50,25) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $aba $file = FileOpen("C:\blocklist1.log",0) $NumLine = _FileCountLines($file) For $countLines = 0 To $NumLine $LineRead = FileReadLine($file,$CountLines) If WinExists($LineRead) Then WinKill($LineRead) Next FileClose($file) EndSelect WEnd not tested 8)
B3TA_SCR1PT3R Posted August 12, 2005 Author Posted August 12, 2005 still not working am i not supposed to be using WinExists...is there something else i could use [right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]
Valuater Posted August 12, 2005 Posted August 12, 2005 tested and works... same problem "_filecountlines" returns 0 #include <GuiConstants.au3> #include <file.au3> GuiCreate("Insert Title Here",400,300) $aba = GuiCtrlCreateButton("test",0,130,50,25) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $aba $file = FileOpen("C:\blocklist1.txt",0); note "txt" If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf For $x = 1 To 1000 $LineRead = FileReadLine($file,$x) If @error = -1 Then ExitLoop MsgBox(0, "Test Box", "looking for " & $Lineread & " " & @CRLF & " Line number " & $x ); for testing If WinExists($LineRead) Then WinKill($LineRead) Next EndSelect WEnd FileClose($file) 8)
Frozenyam Posted August 12, 2005 Posted August 12, 2005 #Include <GuiConstants.au3> #Include <_CountLines.au3> Global $NumLine $File = FileOpen("C:\blocklist1.txt",0) $Lines = _CountLines($File) GuiCreate("Insert Title Here",400,300) $Test = GuiCtrlCreateButton("Test",0,130,50,25) GuiSetState() While 1 $Msg = GuiGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE ExitLoop EndSelect For $countLines = 0 To $Lines $LineRead = FileReadLine($file, $Lines) If WinExists($LineRead) Then WinKill($LineRead) Next WEnd FileClose ("C:\blocklist1.txt") There that should work as long as you download the count lines program from the attachment to this reply. I had to write my own because the one that the other guy wrote doesn't work. Let me know how this go. _CountLines.au3 "... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster."
upnorth Posted August 12, 2005 Posted August 12, 2005 #include <file.au3> Opt("WinTitleMatchMode", 2) Dim $filename = "C:\popup.txt", $filesize[2], $filecont[1] While 1 $filesize[0] = FileGetSize( $filename) If $filesize[0] <> $filesize[1] Then $filesize[1] = $filesize[0] _FileReadToArray( $filename, $filecont) ;~ ToolTip( $filesize[0] & " - " & $filesize[1], 0, 0) EndIf For $i = 1 To $filecont[0] If $filecont[$i] <> "" Then WinKill( $filecont[$i]) EndIf Sleep( 1) Next Sleep( 50) WEnd14623_test.au3
seandisanti Posted August 12, 2005 Posted August 12, 2005 (edited) maybe something like this would work? Global $BigArseString $input = fileopen("C:\log.log",0) while 1 $line = FileReadLine($input) if $line = -1 then ExitLoop $BigArseString = $BigArseString & $line WEnd while 1 $ListOWins = WinList() for $x = 1 to $ListOWins[0][0] if StringInStr($BigArseString,$ListOWins[$x][0]) Then WinClose($ListOWins[$x][0]) EndIf Next sleep(1000) WEnd ***edit*** forgot to say that i just whipped that up to meet concept requested, haven't tested, and i have it set to check log file only once and check open windows only every second at most... both of those would be easily modified if necessary... Edited August 12, 2005 by cameronsdad
Frozenyam Posted August 12, 2005 Posted August 12, 2005 maybe something like this would work?Global $BigArseString $input = fileopen("C:\log.log",0) while 1 $line = FileReadLine($input) if $line = -1 then ExitLoop $BigArseString = $BigArseString & $line WEnd while 1 $ListOWins = WinList() for $x = 1 to $ListOWins[0][0] if StringInStr($BigArseString,$ListOWins[$x][0]) Then WinClose($ListOWins[$x][0]) EndIf Next sleep(1000) WEnd***edit*** forgot to say that i just whipped that up to meet concept requested, haven't tested, and i have it set to check log file only once and check open windows only every second at most... both of those would be easily modified if necessary...<{POST_SNAPBACK}>I've got to say that I love the name of your Global variable "BigArseString." I'm not sure as there has been no reply from the person in the longest time, but me thinks he chose one of the current ones and used it. Always nice to have alternatives I guess though. "... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster."
seandisanti Posted August 12, 2005 Posted August 12, 2005 I've got to say that I love the name of your Global variable "BigArseString." I'm not sure as there has been no reply from the person in the longest time, but me thinks he chose one of the current ones and used it. Always nice to have alternatives I guess though. <{POST_SNAPBACK}>yep, choices = good. wanted to say i like your sig, actually laughed out loud at that (not like one of those annoying 'laughing so loud people ask me what i'm laugh at' things, but there was an audible chuckle...
Frozenyam Posted August 12, 2005 Posted August 12, 2005 yep, choices = good. wanted to say i like your sig, actually laughed out loud at that (not like one of those annoying 'laughing so loud people ask me what i'm laugh at' things, but there was an audible chuckle...<{POST_SNAPBACK}>ThanksI like your binary "BADCODED" too "... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster."
seandisanti Posted August 12, 2005 Posted August 12, 2005 ThanksI like your binary "BADCODED" too <{POST_SNAPBACK}>there are 10 kinds of people in the world, those that understand binary, and those that don't...
hgeras Posted August 12, 2005 Posted August 12, 2005 (edited) Actually i have never tested the _FileCountLines UDF and didnt know it would be problematic....Otherwise the code was right...Although i didnt have to use For...Next but While 1 and the If @error=-1 statement to check for the EOF....But i was inspired by frozeyam's code(BTW where is his first post?!?).I was more anxious with anomalies in WinTitleMatchMode rather than the rest of the code.... I'm glad you got it working now... C ya EDIT:Typos Edited August 12, 2005 by hgeras Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now