|
Post by cyberchipz on Feb 13, 2020 17:24:43 GMT
OK, I think my main issue is not having used pixel or pixel range before. I've read what I could find; but, I think I need to know how to determine what I'm going to detect; but, I don't know how to sample that area to get the values for the color I'll need to code the pixel detector. How do I obtain the value of a pixel in a particular location, which I can then store as an assigned variable to be used when I run the macro and look for the change?
Would I use PIXEL COLOR or PIXEL RANGE? (I'm thinking PIXEL COLOR) as range detects changes, and it seems COLOR RANGE looks for something to change... so I'd have to look at it all the time which I can't do.
Details - May be superfluous: I have a game I'm playing that when players request some help; a change occurs (a particular icon appears on the screen). I was thinking that detecting a particular pixel color, or range would allow me to determine, if while doing some other macro activity, when the icon appears, so I can branch off the main macro... do some activities, like close a pop up window... click that icon, reopen the pop up window, and continue the macro before it branched. I think I can handle coding the activities, I just need to know how to detect a pixel color... so I know what I'm looking for... and then detect that color. Another post goes into detail on detecting after knowing what to look for... I need to know what color I'm looking for, and have no way to sample the screen to determine the color(s).
|
|
|
Post by Steve on Feb 14, 2020 23:38:22 GMT
This might help for both pixel color and pixel range conditions: www.turnssoft.com/conditions.html#pixelcolorwww.turnssoft.com/conditions.html#pixelrange1 | IF | PIXEL RANGE | At Location [X:112 Y:465]::Size [W:49 H:25] | CHANGES::1::0::0 | MESSAGE PROMPT | Pixel changed within the range!::Change::3 2 | RUN ACTION | MESSAGE PROMPT | Reset::Wait::2 3 | IF | PIXEL COLOR | Color [R=0, G=0, B=0]::At Location [X:192 Y:512] | IS THE SAME | MESSAGE PROMPT | The pixel is the same. No change!::No change::0 | ELSE | 3 | RUN ACTION | MESSAGE PROMPT | The pixel has changed!::Change detected::0 Event Time Text 02/15/2020 10:30:07.21 AM Loading settings - Values applyed to variables 02/15/2020 10:30:07.22 AM Loading settings - applying live settings to MMM 02/15/2020 10:30:07.24 AM Mini Mouse Macro Pro - 7.3.0 02/15/2020 10:30:07.26 AM Update Check - Checking connectivity: Online (pending) 02/15/2020 10:30:07.61 AM Update Check - Checking connectivity: Online (OK) 02/15/2020 10:30:07.66 AM Update Check - Comparing: 7.3.0.0 to the latest at www.turnssoft.com 02/15/2020 10:30:08.10 AM Update Check - This is the latest version 02/15/2020 10:32:24.33 AM Starting macro playback 02/15/2020 10:32:24.36 AM Macro condition: 1 | IF | PIXEL RANGE | At Location [X:112 Y:465]::Size [W:49 H:25] | CHANGES::1::0::0 | MESSAGE PROMPT | Pixel changed within the range!::Change::3 02/15/2020 10:32:27.09 AM Pixel Range Change (1/1) - First detected at pixel W:37 and H:0) 02/15/2020 10:32:27.11 AM Macro condition - Condition TRUE 02/15/2020 10:32:27.13 AM Macro action - Running ACTION: MESSAGE PROMPT - Message(Pixel changed within the range!::Change::3) 02/15/2020 10:32:29.39 AM Macro condition: 2 | RUN ACTION | MESSAGE PROMPT | Reset::Wait::2 02/15/2020 10:32:29.42 AM Macro condition - Condition TRUE 02/15/2020 10:32:29.44 AM Macro action - Running ACTION: MESSAGE PROMPT - Message(Reset::Wait::2) 02/15/2020 10:32:31.50 AM Macro condition: 3 | IF | PIXEL COLOR | Color [R=0, G=0, B=0]::At Location [X:192 Y:512] | IS THE SAME | MESSAGE PROMPT | The pixel is the same. No change!::No change::0 | ELSE | 3 | RUN ACTION | MESSAGE PROMPT | The pixel has changed!::Change detected::0 02/15/2020 10:32:31.52 AM Macro condition - Pixel color MATCH 02/15/2020 10:32:31.55 AM Macro condition - Condition TRUE 02/15/2020 10:32:31.57 AM Macro action - Running ACTION: MESSAGE PROMPT - Message(The pixel is the same. No change!::No change::0) 02/15/2020 10:32:34.18 AM Macro playback finished 02/15/2020 10:32:44.46 AM Starting macro playback 02/15/2020 10:32:44.47 AM Macro condition: 3 | IF | PIXEL COLOR | Color [R=0, G=0, B=0]::At Location [X:192 Y:512] | IS THE SAME | MESSAGE PROMPT | The pixel is the same. No change!::No change::0 | ELSE | 3 | RUN ACTION | MESSAGE PROMPT | The pixel has changed!::Change detected::0 02/15/2020 10:32:44.49 AM Macro condition - Condition FALSE 02/15/2020 10:32:44.51 AM Macro condition - Condition TRUE 02/15/2020 10:32:44.52 AM Macro action - Running ACTION: MESSAGE PROMPT - Message(The pixel has changed!::Change detected::0) 02/15/2020 10:32:46.97 AM Macro playback finished
|
|
|
Post by cyberchipz on Feb 15, 2020 9:59:34 GMT
Seems to be what I was looking for... don't know why I didn't understand that from the Conditions page. The example helped. Wish I could pause that playback. Speaking of pausing... is there a way to step through a macro, to help with debugging? I think I saw you show me a way. Use a MessageBox then run a line of code, one line at a time. I'll give that a try... as long as I don't hit stop. It's gotten to be a habit. I've froze up MMM that way a few times. Editing, while it was running.
|
|
|
Post by cyberchipz on Feb 17, 2020 0:06:35 GMT
Seems to be what I was looking for... Spoke too soon... but it's not the code, or the concept; something in the game is obfuscating the screen... probably the smoke. I'm using a workaround, apparently the game makers are wise to macros! Go figure. I was able to make it work on anything with a stationary background... but when the background is animated... how does one detect the same, when it's always changing? Or changes, when it's *always* changing. Took me a while to realize.. I didn't even know what the heck I was looking for... lol One pixel to remain the same long enough to detect it... I'm going with that. And though it might be possible... would I really ever be totally sure? In this game, the potential to do real damage to one's self with superfluous clicks is real. I'm going to have to use this in the more static areas of the game.
|
|
|
Post by zeak on Feb 17, 2020 1:15:14 GMT
I'm going to have to use this in the more static areas of the game. Just out of curiosity, what game are you playing?
|
|
|
Post by cyberchipz on Feb 17, 2020 19:44:07 GMT
I'm going to have to use this in the more static areas of the game. Just out of curiosity, what game are you playing? Where did you say you lived? ;-) Do you work for a gaming company... not that I'm violating any agreement... that I know of... lol I play under the same username that I use here... sorry if I seem paranoid. :-D You know what they say... "Just because you're paranoid doesn't mean they're NOT out to get you." As a security guy, that's why I obfuscate my mouse klicks when coding! And they're (the game company) is savvy enough to do things like... obscure clickables with billowing smoke, move their locations by 100 pixels or more in either direction (not discernible to the eye; but plays hell on my X & Y values), and who knows what I haven't found yet. My next project is a re-calibration, and store new INIT variables in a file so when the macro fails I can recalibrate their locations. I noticed that they don't move it enough that if I click the exact center of the button, I will hit all the time... but that is a dead giveaway that I'm using a macro. I'm thinking they're changing the location and appearance of the POPup boxes that are used to do activities. You could lie to me, and I would tell you what game... I like my quality time with my wife... and the game wants me to attack (repeatedly) targets that can be up to 8 or more minutes from me. 16 minutes round trip for my little icon to go to. And I have to hit it like 20 to 40 times. Or, I could waste a resource that costs me game money to relocate my town, which is what they want. I'm frugal. MMM gives me the ability to be AFK and be active within the game for the tedious stuff like what I said. I've noticed that the game obfuscates any mouse target that could be automated to save money(real), money(game) or force the use of resources that cost the player the former. I'm just trying to save a few bucks, and time (time is money). Oh wait... I didn't answer your question... are you all in Australia? I thought I picked up a word, or something that gave it away... at least with Steve... or was it you? Oh yeah.. the Ginger Beer. :-) Cheers! I'm going to have to look at your code for PIXEL RANGE... I can't get it to follow through with the MESSAGE BOX on anything I try it on... he coded them to have the same message; but, I changed mine so I could tell whether the PIXEL RANGE or the PIXEL COLOR was the responder in his demo... RANGE never responds to either same or change... not sure why. Haven't tried it on a document though, just the game. For all I know the game makers imbedded little flickering pixels everywhere. lol
|
|
|
Post by zeak on Feb 17, 2020 21:39:36 GMT
Cyber, That's why I've been hitting up Steve for a while now to have a detect picture or word. If you have any Ideas on how that could be done it would be great.
|
|
|
Post by cyberchipz on Feb 18, 2020 19:24:30 GMT
Cyber, That's why I've been hitting up Steve for a while now to have a detect picture or word. If you have any Ideas on how that could be done it would be great. Not sure specifically what you're saying. Isn't PIXEL RANGE supposed to do that?
|
|
|
Post by zeak on Feb 20, 2020 23:49:02 GMT
Cyber, That's why I've been hitting up Steve for a while now to have a detect picture or word. If you have any Ideas on how that could be done it would be great. Not sure specifically what you're saying. Isn't PIXEL RANGE supposed to do that? Pixel COLOUR only detect a single pixel meaning you can't say look for this picture and PIXEL RANGE does not discriminate what the pixels change from-to in the range, only that they have changed.
|
|
|
Post by cyberchipz on Feb 21, 2020 7:46:18 GMT
Not sure specifically what you're saying. Isn't PIXEL RANGE supposed to do that? Pixel COLOUR only detect a single pixel meaning you can't say look for this picture and PIXEL RANGE does not discriminate what the pixels change from-to in the range, only that they have changed. OK, the only way I know to detect a change in the image is to compare the two images. Ideally, and possibly the only way, is to use a non compressed image, and then sample that same image later. It could ideally be any area you've selected to capture, like Steve does in PIXEL RANGE. So, let's say the image is x by y pixels across and down. You would read that screen memory location (or store the image in a file, and know the formatting used to save it... Here where to find the file format info for .png Link to info about png formatting) to obtain the value contained in the pixel 'byte(s)'. Then, depending upon the specific information you wanted, you would Mask that 'byte' to either obtain or mask out the bit(s) you wanted to examine, but this method might be a bit old fashioned when everything was only an 8bit byte. Depending upon formatting, this might be for transparency (Alpha) or intensity, or specific color value (RGB). But nowadays, I think every pixel has one or more bytes associated with it. (I didn't read the .png info in detail) The easiest way to do a simple compare for the entire byte, say 1 of the 32 or 64 bits of information that represent a single pixel is you would simply use an XOR of the original and duplicate's image pixel byte instead of bit by bit, if the pixel had changed, for XOR you'd return a TRUE (1) if the byte, or bit, had changed, and a FALSE (0) if it was the same. So, I'd look up where the screen memory is located, and do a system call in a higher level language, like C or C++, and either gain access to the screen memory, or get a copy of it. Grab a piece of it, like steve does, and do an XOR of the old and new information to see if it changed or not. If you *only* wanted to detect a change each pixel (Color, Alpha, the whole thing) and presuming you've captured a piece of the screen... that is 10 x 30 pixels... you'd store that in memory (or a file in a format you choose, or if comparing two image files (from someone else, I'd learn that format and grab a piece of it based on that), call it A10x30 Then you'd capture that same area of the screen again call it B10x30, that should be 300 bytes (32bit or 64bit) X=30 Y=10, Left to Right, Top to Bottom, you'd need Two nested FOR LOOPS 1: x = 0 to 29, y = 0 to 9, then in the third memory area or table, you'd store the results. C(x,y)=A(x,y) XOR B(x,y) next y, next x and in table C (300 bytes) you'd have a 0 or FALSE in each location for every byte that DID NOT change, and a 1 or TRUE in every byte that DID CHANGE. Technically you'd have to have a function that could index into the image, know the size, and return the value of the X,Y location of that pixel if it already did the XOR. So basically a table of pixel values... or a string that you'd know the format and how it was stored... that you decided on. A bitwise check is just a deeper examination of each byte, using an AND mask to eliminate info you didn't want, or rotate the processor registers at machine level to rotate each bit and check it that way in loops. Everything depends on the format, how you got it, how it and you stored it, etc. Steve probably does a lot of this in pixel range; but, he doesn't ask or specific which pixels have changed because normally you'd just want to know if any part of it changed in something completely static. But, watermarks are often used in security to imbed either Alpha or Intensity changes to create a security code either embedded in a specific location or over the entire picture. You'd just have to know where it is to pull it out... otherwise it could be hidden and with a single bit change in color, it wouldn't appear to the naked eye with 32 Million colours. Plus if the image was re-compressed, it would mux it up. Does this in any way answer your question? lol I thought this was what Steve was doing with Pixel Range, just detecting change... but, I can't format it right to get it to work and give me a logical return value like he shows... I think I once did, but only on a static image from a document or web page... but not in the game. It's been a long time since I've done any of this... and the OS has changed so much, I'm not sure how long it would take to learn what I needed, again!... I've again, forgotten more than I know or knew.) I do a lot of analysis with images... debunking ghost captures, alien videos... Don't get me wrong... I think that stuff is real... it's just that not all people can be trusted. lol Some people just like to create fakes. With the new AI stuff, and everything out there now... it's getting harder... but, yeah... I've done a lot of stuff at machine level programming... some digital breadboarding. I'm hoping if I can get over my health issues, and have some money coming in, I can play with Arduino and little toy stuff... and work on some concepts with Tesla and try to do some weird Quantum stuff I have in mind... using resonance, and my theory of how the universe works at the Quantum level. So, on another subject... ;-) I think the secret to free energy is to resonate a circuit at the right frequency (quantum level binding particle energy small wavelengths), with the right type of core in a itty bitty "reactive" generator, and create what I call a resonant tickle.. that will cancel out the binding energy in a very... very controlled way... to well, rotate some higher dimensionally available muons and turn them into electrons and make them available. IOW, convert what science calls "reactive" power into "real" power. Basically cancel out one of the imaginary(sic) eigenvectors of the muon, and rotate it into real 3d space. I only mention this to get the concept out into the internet ether... so someone looking for a guy who talks that kind of gibberish will realize I know more than I'm saying. ;-) but, if I missed a point, or something specific you have as a question; please don't hesitate to ask. Hope I helped. Or it just dawned on me I missed the point completely... So, what you're trying to do maybe... is you have an image, or part of something that would be in the image, and you want to find that area that matches the part you've picked for it to look for? I would have to be exact... or at least have a percentage of it match. You could do as I say above... it's still would have to be byte by byte, at the machine level, where code is quick... and it would have to ultimately scan the entire image... depending on the size of the part you're looking for... and the size of the image it could be in... and whether it's an exact match or not, it could take some time. If you knew if was the same and looked the same as your sample to find, it could do it... the problem is if it's not an exact match. This is where the AI being used nowadays comes in. I think something could be done perhaps with 3D holographic comparison analogies... but all of this is math and time extensive. You would have to give me an example for me to understand completely. I mean, if you gave me a picture... and then gave me a piece of that picture... I could find it fast with my own eyes, if it was big enough... and as long as the sample came from the same picture, I could code something to find it... as long as nothing was changing. So, yeah the same technique... but, if any of it changed... since it doesn't match exactly anymore.. you'd want to compare every pixel, and then determine what % of change is acceptable for it to be a match and say you found it. So, if it's a face, facing you.. and you're looking for the face... if it turned, even a little bit... then even percent right wouldn't work.. you'd have to code something that would determine similarity based on something like a compressed image... I mean... a side profile of a face, could look similar to another side profile of a face... that's hard... but, if you're looking for a button, and you know what it looks like, you should be able to find it. But, if that button was a clear image, and there was a haze of smoke over it. The smoke effect could just be an intensity and Alpha effect, and filtering that out would be tougher. If it was an intensity, alpha and color effect, then it's even harder. Now, you could watch it over time, and then for each pixel, obtain a range of change for each pixel, the extremes of each factor changing... How much does intensity change over time, how much does Alpha change... (but that's either a transparent, or not transparent thing.. so perhaps not a thing) And then color change range... red green to blue green range... and if each pixel had changed, and it still fell within a range of values... then either call it a match or not. Hmm, starting to sound like what Steve IS doing... maybe. But for every pixel... well... we can do a lot at machine level speeds. So, yeah... but it would help if it was in the same place all the time.. but, it sounds like you're trying to find something... and I don't know if it's the same, or only looks similar.
|
|
|
Post by Steve on Feb 21, 2020 21:32:36 GMT
TL;DR what does the code for the pixel conditions look like? Calling Pixel Color and Range Function:' Pixel Color or Pixel Range If boolPixelColor = True Or boolPixelRange = True Then Try If boolIsTheSame = True Then If Condition_RUN_PixelColor(strPixelColor, True, False, 0, 1, 0, boolPixelRange) = True Then EventArrayAdd("43|evt|Macro condition - Pixel color MATCH|evt|2", "macro") boolConditionTrue = True Else boolConditionTrue = False End If ElseIf boolIsNotTheSame = True Then If Condition_RUN_PixelColor(strPixelColor, False, True, 0, 1, 0, boolPixelRange) = True Then EventArrayAdd("43|evt|Macro condition - Pixel color NOT MATCH|evt|2", "macro") boolConditionTrue = True Else boolConditionTrue = False End If ElseIf boolChanges = True Then Dim intChange As Integer Dim intTimeout As Integer Dim intDelay As Integer = 0
If intChangeNum = Nothing Then If strChanges.Contains("::") Then Dim strSub() As String = Split(strChanges, "::")
If strSub.Count = 4 Then If IsNumeric(strSub(1)) Then intChange = strSub(1) Else EventArrayAdd("2|evt|Pixel Color - value for change number '" & strSub(1) & "' is not numeric. Auto correcting to '1'|evt|2", "war") intChange = 1 End If
If IsNumeric(strSub(2)) Then intTimeout = strSub(2) Else EventArrayAdd("2|evt|Pixel Color - value for timeout '" & strSub(2) & "' is not numeric. Auto correcting to '0'|evt|2", "war") intTimeout = 0 End If
If IsNumeric(strSub(3)) Then intDelay = strSub(3) Else EventArrayAdd("2|evt|Pixel Color - value for delay '" & strSub(3) & "' is not numeric. Auto correcting to '0'|evt|2", "war") intTimeout = 0 End If
ElseIf strSub.Count = 3 Then If IsNumeric(strSub(1)) Then intChange = strSub(1) Else EventArrayAdd("2|evt|Pixel Color - value for change number '" & strSub(1) & "' is not numeric. Auto correcting to '1'|evt|2", "war") intChange = 1 End If
If IsNumeric(strSub(2)) Then intTimeout = strSub(2) Else EventArrayAdd("2|evt|Pixel Color - value for timeout '" & strSub(2) & "' is not numeric. Auto correcting to '0'|evt|2", "war") intTimeout = 0 End If
Else intChange = 1 intTimeout = 0 intDelay = 0 End If Else intChange = 1 intTimeout = 0 intDelay = 0 End If
intChangeNum = intChange intChangeTimout = intTimeout
End If
' EDIT 30 / 10 / 18 - Pixel Range Dim strPixelString As String
If boolPixelColor = True Then strPixelString = strPixelColor Else strPixelString = strPixelRange End If
If Condition_RUN_PixelColor(strPixelString, False, False, True, intChangeTimout, intChangeNum, intDelay, boolPixelRange) = True Then boolConditionTrue = True intChangeNum = Nothing intTimeout = Nothing Else If boolContinue = True Then If boolRunErrors = True Then Exit Sub End If End If
boolConditionTrue = False End If
End If Catch ex As OverflowException If boolChanges = True Then If boolPixelColor = True Then strErrorBack = " - " & "Overflow - Check your values for (At Location [X:X Y:X] | CHANGES::X::X)" Else strErrorBack = " - " & "Overflow - Check your values for (At Location [X:X Y:X]::Size [W:X H:X] | CHANGES::X::X)" End If
Else strErrorBack = " - " & "Overflow Error - Check your values for (Color [R=X , G=X B=X])::At Location [X:X Y:X])" End If
boolRunErrors = True Catch ex As Exception If boolChanges = True Then If boolPixelColor = True Then strErrorBack = " - " & "Unhandled Format Error - Check your format is (At Location [X:X Y:X] | CHANGES::X::X)" Else strErrorBack = " - " & "Unhandled Format Error - Check your format is (At Location [X:X Y:X]::Size [W:X H:X] | CHANGES::X::X)" End If
Else strErrorBack = " - " & "Unhandled Format Error - Check your format is (Color [R=X , G=X B=X])::At Location [X:X Y:X])" End If
boolRunErrors = True End Try End If The Function:Private Function Condition_RUN_PixelColor(ByVal strPixelColor As String, Optional ByVal boolISthesame As Boolean = False, Optional ByVal boolISNotthesame As Boolean = False, Optional ByVal boolChanged As Boolean = False, Optional ByVal intWaitTime As Integer = 0, Optional ByVal intChangeTimes As Integer = 1, Optional ByVal intDelay As Integer = 0, Optional ByVal boolPixelRange As Boolean = False) As Boolean
' Color [A=255, R=166, G=202, B=219]::At Location [X:1441 Y:297]::Size [W:10 H:10] | IS THE SAME | MESSAGE PROMPT | same::title Dim strsub() As String Dim strPixCol As String Dim strLocation As String Dim intWidth As Integer Dim intHeight As Integer Dim boolChangeWatch As Boolean = False Dim intChangeTimeCounter As Integer = 0
If Not boolChanged = True Then strsub = Split(strPixelColor, "::") strPixCol = strsub(0) strLocation = strsub(1).Remove(0, 12) Else strsub = Split(strPixelColor, "::")
If boolPixelRange = True Then strLocation = strsub(0).Remove(0, 12) Else strLocation = strPixelColor.Remove(0, 12) End If
End If
If boolPixelRange = True Then boolChanged = False
strsub = Split(strPixelColor, "::") Dim strW As String Dim strH As String
If Not strsub.Count = 2 Then EventArrayAdd("3|evt|Pixel Range (" & strPixelColor & ") is incorrectly formatted. It should look something like this '(At Location [X:1441 Y:297]::Size [W:10 H:10]'). Skipping...)|evt|1", "err") boolRunErrors = True strErrorBack = " - " & "Format Error - Check your format is (At Location [X:X Y:X]::Size [W:X H:X] | CHANGES::X::X)" Return False Else For Each item In strsub If item.ToLower.StartsWith("size") Then item = item.Remove(0, 8) Dim strsub2() As String = Split(item, " H:") strW = strsub2(0) strH = strsub2(1).Replace("]", "") End If Next End If
If Not IsNumeric(strW) Then intWidth = 1 Else intWidth = strW End If
If Not IsNumeric(strH) Then intHeight = 1 Else intHeight = strH End If
End If
Dim strLocSub() As String Dim PntLoc As Point Dim strPixCol_NOW As String
Dim chars() As Char = {"[", "X", "Y", "]"} strLocSub = Split(strLocation, ":") Dim i As Integer = 0 For Each pnt In strLocSub Dim strCol As String = pnt strCol = strCol.Trim() strCol = strCol.TrimStart(chars) strCol = strCol.TrimEnd(chars)
If i = 1 Then PntLoc.X = CInt(strCol) ElseIf i = 2 Then PntLoc.Y = CInt(strCol) End If i += 1 Next
Dim bmp As New Bitmap(1, 1) Dim pixel As Drawing.Color
If boolPixelRange = False Then Using gr As Graphics = Graphics.FromImage(bmp) gr.CopyFromScreen(PntLoc, New Point(0, 0), New Size(1, 1)) End Using pixel = bmp.GetPixel(0, 0)
strPixCol_NOW = "Color [R=" & pixel.R & ", G=" & pixel.G & ", B=" & pixel.B & "]"
If boolChanged = True Then strPixCol = strPixCol_NOW End If
Else 'Pixel Range boolChanged = False End If
If boolISthesame = True Then If strPixCol.ToUpper = strPixCol_NOW.ToUpper Then Return True Else Return False End If ElseIf boolISNotthesame = True Then If Not strPixCol.ToUpper = strPixCol_NOW.ToUpper Then Return True Else Return False End If ElseIf boolChanged = True Then Dim boolChange As Boolean Dim ii As Integer = 0
If intWaitTime = 0 Then Do While boolChange = False
If boolStop = True Then Exit Function End If
Dim bmpp As New Bitmap(1, 1) Using gr As Graphics = Graphics.FromImage(bmpp) gr.CopyFromScreen(PntLoc, New Point(0, 0), New Size(1, 1)) End Using
pixel = bmpp.GetPixel(0, 0)
strPixCol_NOW = "Color [R=" & pixel.R & ", G=" & pixel.G & ", B=" & pixel.B & "]"
If Not strPixCol.ToUpper = strPixCol_NOW.ToUpper Then ' the pixel has changed at least one time
intChangeTimeCounter += 1 EventArrayAdd("42|evt|Pixel Color Change (" & intChangeTimeCounter & "/" & intChangeTimes & ") - From " & strPixCol & " to " & strPixCol_NOW & ")|evt|2", "macro") strPixCol = strPixCol_NOW
If intChangeTimes <= 1 Then boolChange = True ElseIf intChangeTimes > 1 Then If intChangeTimeCounter >= intChangeTimes Then boolChange = True End If End If
End If
If intDelay > 0 Then Thread.Sleep(intDelay) End If Loop Else Dim start_time As DateTime = Now Dim stop_time As DateTime Dim elapsed_time As TimeSpan Dim intElapsed As Integer Do Until intElapsed >= intWaitTime
If boolStop = True Then Exit Function End If
Dim bmpp As New Bitmap(1, 1) Using gr As Graphics = Graphics.FromImage(bmpp) gr.CopyFromScreen(PntLoc, New Point(0, 0), New Size(1, 1)) End Using
pixel = bmpp.GetPixel(0, 0)
strPixCol_NOW = "Color [R=" & pixel.R & ", G=" & pixel.G & ", B=" & pixel.B & "]" If Not strPixCol.ToUpper = strPixCol_NOW.ToUpper Then ' the pixel has changed at least one time
intChangeTimeCounter += 1 EventArrayAdd("42|evt|Pixel Color Change (" & intChangeTimeCounter & "/" & intChangeTimes & ") - From " & strPixCol & " to " & strPixCol_NOW & ")|evt|2", "macro") strPixCol = strPixCol_NOW
If intChangeTimes <= 1 Then boolChange = True Exit Do ElseIf intChangeTimes > 1 Then If intChangeTimeCounter >= intChangeTimes Then boolChange = True Exit Do End If End If
End If stop_time = Now elapsed_time = stop_time.Subtract(start_time) intElapsed = elapsed_time.TotalSeconds.ToString("0")
If intDelay > 0 Then Thread.Sleep(intDelay) End If
Loop
If intElapsed >= intWaitTime Then EventArrayAdd("42|evt|Pixel Color Change - No change detected during the wait time (" & intWaitTime & ") |evt|2", "macro") boolChange = False End If
End If
If boolChange = True Then Return True Else Return False End If ElseIf boolPixelRange = True Then Dim boolChange As Boolean
Dim bmporig As New Bitmap(intWidth, intHeight) Using grorig As Graphics = Graphics.FromImage(bmporig) grorig.CopyFromScreen(PntLoc, New Point(0, 0), New Size(intWidth, intHeight)) End Using
If intWaitTime = 0 Then Do While boolChange = False Dim intXP As Integer = 1 Dim intYP As Integer = 1
If boolStop = True Then Exit Function End If
Dim bmpp As New Bitmap(intWidth, intHeight) Using gr As Graphics = Graphics.FromImage(bmpp) gr.CopyFromScreen(PntLoc, New Point(0, 0), New Size(intWidth, intHeight)) End Using
Dim boolNoChange As Boolean = True For x = 0 To bmporig.Width - 1 intYP = 0 For y = 0 To bmporig.Height - 1 ' For y = 0 To bmpp.Height - 1 ' This code can be edited to allow for an if pixel color detected style option (development) If bmporig.GetPixel(x, y) <> bmpp.GetPixel(x, y) Then boolNoChange = False Exit For End If intYP = y Next intXP = x
If boolNoChange = False Then Exit For End If Next
If boolNoChange = False Then
Using grorig As Graphics = Graphics.FromImage(bmporig) grorig.CopyFromScreen(PntLoc, New Point(0, 0), New Size(intWidth, intHeight)) End Using
intChangeTimeCounter += 1 EventArrayAdd("42|evt|Pixel Range Change (" & intChangeTimeCounter & "/" & intChangeTimes & ") - First detected at pixel W:" & intXP & " and H:" & intYP & ")|evt|2", "macro") If intChangeTimes <= 1 Then boolChange = True ElseIf intChangeTimes > 1 Then If intChangeTimeCounter >= intChangeTimes Then boolChange = True End If End If End If
If intDelay > 0 Then Thread.Sleep(intDelay) End If Loop Else Dim start_time As DateTime = Now Dim stop_time As DateTime Dim elapsed_time As TimeSpan Dim intElapsed As Integer Do Until intElapsed >= intWaitTime
Dim intXP As Integer = 1 Dim intYP As Integer = 1
If boolStop = True Then Exit Function End If
Dim bmpp As New Bitmap(intWidth, intHeight) Using gr As Graphics = Graphics.FromImage(bmpp) gr.CopyFromScreen(PntLoc, New Point(0, 0), New Size(intWidth, intHeight)) End Using
Dim boolNoChange As Boolean = True For x = 0 To bmporig.Width - 1 intYP = 0 For y = 0 To bmporig.Height - 1 ' For y = 0 To bmpp.Height - 1 If bmporig.GetPixel(x, y) <> bmpp.GetPixel(x, y) Then boolNoChange = False Exit For End If intYP = y Next intXP = x
If boolNoChange = False Then Exit For End If Next
If boolNoChange = False Then
Using grorig As Graphics = Graphics.FromImage(bmporig) grorig.CopyFromScreen(PntLoc, New Point(0, 0), New Size(intWidth, intHeight)) End Using
intChangeTimeCounter += 1 EventArrayAdd("42|evt|Pixel Range Change (" & intChangeTimeCounter & "/" & intChangeTimes & ") - First detected at pixel W:" & intXP & " and H:" & intYP & ")|evt|2", "macro") If intChangeTimes <= 1 Then boolChange = True Exit Do ElseIf intChangeTimes > 1 Then If intChangeTimeCounter >= intChangeTimes Then boolChange = True Exit Do End If End If End If
stop_time = Now elapsed_time = stop_time.Subtract(start_time) intElapsed = elapsed_time.TotalSeconds.ToString("0")
If intDelay > 0 Then Thread.Sleep(intDelay) End If
Loop
If intElapsed >= intWaitTime Then EventArrayAdd("42|evt|Pixel Range Change - No change detected during the wait time (" & intWaitTime & ") |evt|2", "macro") boolChange = False End If
End If
If boolChange = True Then Return True Else Return False End If
End If
End Function
|
|
|
Post by cyberchipz on Feb 22, 2020 7:45:23 GMT
Wow! Did I ask for that! lol While I can say the language is very familiar. I'm sure I don't recognize all the function calls. But, I'll look at it. Tomorrow... (if I can pee in the morning... having issues again... damned operation causing problems.) so.. thought I was talking to zeak... and yeah... my wall of text... but I have to say yours is a little more logical than mine... but I can already see we're saying some of the same things.
.bmp is lossless, so that's good. And I skimmed the rest.. lol Sorry I was TL:DR. L8r|
|
|