AutoHotkey Community

It is currently May 26th, 2012, 4:42 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: March 31st, 2009, 10:09 am 
Offline

Joined: March 23rd, 2009, 12:27 pm
Posts: 27
Code:
WWBBWWWWWWWBBBBBWWWWWBBBBBWWWWWWWWWWWWWWBBBBBWWWWBBBBBBWWBBBBBBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
WWBBWWWWWWBBBBBBBWWWBBBBBBBWWWWWWWWWWWWBBBBBBBWWWBBBBBWWWBBBBBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWBBWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWWWWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWWWWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW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WBBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
WWBBBBBBWWBBBBBBBWWWBBBBBBBWWWWWWWWWWWWBBBBBBBWWWBBWWWWWWBBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
WWBBBBBBWWWBBBBBWWWWWBBBBBBWWWWWWWWWWWWWBBBBBWWWWBBWWWWWWBBWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW


If you look closely, you will notice that is the phrase LOG OFF. The text
are the B letters, the background are the W letters.

I am using using some code to extract Pixels from a video game. It then
decides whether the pixel is a background color, or a text color, and it
adds each pixel into a blob of text I will be able to save and compare in
the future.

My challenge: I need to remove all the lines of background that appear
before the phrase, between the letters, and after the phrase.

How can I erase the columns where the column is only W's, and it doesn't
have any B's? I was thinking of using arrays, but it seems the arrays in
AutoHotKey aren't complex enough.

Do you have any ideas?

Thnx


Last edited by EveOnline001 on March 31st, 2009, 11:10 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2009, 11:08 am 
Quote:
Choose a descriptive subject line. For example, avoid titles like "Need help with something simple". Instead, use a specific title like "How to programmatically select text in Notepad".
:?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2009, 7:07 pm 
Offline

Joined: March 23rd, 2009, 12:27 pm
Posts: 27
Does anyone have suggestion?

Thnx


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2009, 9:00 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Two examples, one that removes all similar columns e.g. all W and all B will be removed the second will do what you want I think. Remove only W cols
Code:
SetBatchLines, -1
String= ; replace by fileread
(
WWBBWWWWWWWBBBBBWWWWWBBBBBWWWWWWWWWWWWWWBBBBBWWWWBBBBBBWWBBBBBBWWWW
WWBBWWWWWWBBBBBBBWWWBBBBBBBWWWWWWWWWWWWBBBBBBBWWWBBBBBWWWBBBBBWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWBBWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWWWWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWWWWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWWWWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWBBBBWWWWWWWWWWWWBBWWWBBWWWBBBBBWWWBBBBBWWWWW
WWBBWWWWWWBBWWWBBWWWBBWBBBBWWWWWWWWWWWWBBWWWBBWWWBBBBBWWWBBBBBWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWBBWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWBBWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWBBWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWW
WWBBBBBBWWBBBBBBBWWWBBBBBBBWWWWWWWWWWWWBBBBBBBWWWBBWWWWWWBBWWWWWWWW
WWBBBBBBWWWBBBBBWWWWWBBBBBBWWWWWWWWWWWWWBBBBBWWWWBBWWWWWWBBWWWWWWWW
)
Filedelete, stringout.txt
StringSplit, Line, String, `n, `r
Loop % StrLen(Line1)
   {
    ColTheSame=True
    Check:=A_Index
    Loop % Line0
      {
       Col:=A_Index
       NextLine := A_Index + 1
       If (A_Index = Line0)
         Break
       A:= SubStr(Line%A_Index%,Check,1)
       B:= SubStr(Line%NextLine%,Check,1)   
       ;MsgBox % Check "`na" a ":" "b" b
       If ( A <> B )
          {
          ColTheSame=False
          break
         }
      }
    If ( ColTheSame = "True" )
      RemoveCols .= Check ","
   }

Loop % Line0
   {   
   Check:=A_Index
    Loop, Parse, Line%Check%
      {
       ; If A_Index not in %RemoveCols% ; note if in var is very very slow
        If (InStr("," . RemoveCols . "," , "," . A_Index . ",") = 0) ; 0 is not found
         OutPut .= A_LoopField ; append
      }
   Output .= "`n"   
   }
FileAppend, %Output%, stringout.txt
Esc::ExitApp


Code:
SetBatchLines, -1
String= ; replace by fileread
(
WWBBWWWWWWWBBBBBWWWWWBBBBBWWWWWWWWWWWWWWBBBBBWWWWBBBBBBWWBBBBBBWWWW
WWBBWWWWWWBBBBBBBWWWBBBBBBBWWWWWWWWWWWWBBBBBBBWWWBBBBBWWWBBBBBWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWBBWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWWWWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWWWWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWWWWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWBBBBWWWWWWWWWWWWBBWWWBBWWWBBBBBWWWBBBBBWWWWW
WWBBWWWWWWBBWWWBBWWWBBWBBBBWWWWWWWWWWWWBBWWWBBWWWBBBBBWWWBBBBBWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWBBWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWBBWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWW
WWBBWWWWWWBBWWWBBWWWBBWWWBBWWWWWWWWWWWWBBWWWBBWWWBBWWWWWWBBWWWWWWWW
WWBBBBBBWWBBBBBBBWWWBBBBBBBWWWWWWWWWWWWBBBBBBBWWWBBWWWWWWBBWWWWWWWW
WWBBBBBBWWWBBBBBWWWWWBBBBBBWWWWWWWWWWWWWBBBBBWWWWBBWWWWWWBBWWWWWWWW
)
Filedelete, stringout2.txt
StringSplit, Line, String, `n, `r
Loop % StrLen(Line1)
   {
    ColTheSame=True
    Check:=A_Index
    Loop % Line0
      {
       Column .= SubStr(Line%A_Index%,Check,1)
      }
    IfNotInString, Column, B
      RemoveCols .= Check ","
    Column=   
   }

Loop % Line0
   {   
   Check:=A_Index
    Loop, Parse, Line%Check%
      {
       ; If A_Index not in %RemoveCols% ; note if in var is very very slow
        If (InStr("," . RemoveCols . "," , "," . A_Index . ",") = 0) ; 0 is not found
         OutPut .= A_LoopField ; append
      }
   Output .= "`n"   
   }
FileAppend, %Output%, stringout2.txt
Esc::ExitApp

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2009, 9:53 pm 
Offline

Joined: March 23rd, 2009, 12:27 pm
Posts: 27
Code:
BBWWWWWBBBBBWWBBBBBWWBBBBBWBBBBBBBBBBBB
BBWWWWBBBBBBBBBBBBBBBBBBBBBBBBBBWBBBBBW
BBWWWWBBWWWBBBBWWWBBBBWWWBBBBWWWWBBWWWW
BBWWWWBBWWWBBBBWWWWWBBWWWBBBBWWWWBBWWWW
BBWWWWBBWWWBBBBWWWWWBBWWWBBBBWWWWBBWWWW
BBWWWWBBWWWBBBBWWWWWBBWWWBBBBWWWWBBWWWW
BBWWWWBBWWWBBBBWBBBBBBWWWBBBBBBBWBBBBBW
BBWWWWBBWWWBBBBWBBBBBBWWWBBBBBBBWBBBBBW
BBWWWWBBWWWBBBBWWWBBBBWWWBBBBWWWWBBWWWW
BBWWWWBBWWWBBBBWWWBBBBWWWBBBBWWWWBBWWWW
BBWWWWBBWWWBBBBWWWBBBBWWWBBBBWWWWBBWWWW
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBWWWWBBWWWW
BBBBBBWBBBBBWWBBBBBBWBBBBBWBBWWWWBBWWWW


Success :) The script you wrote is a lot shorter than the one I had
previously. I'll have to look over it and see what you did.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Miguel, notsoobvious and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group