Jump to content

DigitalLocksmith

Active Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by DigitalLocksmith

  1. How do I find the total and the average of all values in an array? *edit* Nevermind...Figured it out. CODE#include <Array.au3> Dim $avArray[11], $I = 1 $total = 0 ; Populate test array. For $I = 1 to UBound( $avArray ) - 1 $avArray[$I] = Int( Random( 1, 2 ) ) $total = $total + $avArray[$I] Next _ArrayDisplay( $avArray, "_ArrayToString() Test" ) MsgBox( 4096, "Test", $total) Exit
  2. Smoke, how can I add all of the values of the 2 columns seperately and divide (average) by the number of elements in each column? Also, Filewrite from array isn't working...I'm researching, I'm just turning up nothing. Like: add all column0 = Whatever/number of elements add all column1 = Whatever/number of elements With this code: CODE#include<Array.au3> #include <File.au3> Sleep(3000) $poop = 0 While $poop <10 $array = _PixelSearchEx(0, 0, 320, 240, 0xFFFF00) If @error Then Exit EndIf $poop = $poop + 1 WEnd _FileWriteFromArray("fan club.txt", $array, 1) _ArrayDisplay($array) Func _PixelSearchEx($xTop, $yTop, $xBottom, $yBottom, $nColor, $iShade = 0, $iStep = 1) Local $aPix, $aCoords, $nYAdd, $iAdd For $xCC = $xTop To $xBottom $nYAdd = 0 While $nYAdd <= $yBottom $aPix = PixelSearch($xCC, $yTop + $nYAdd, $xCC, $yBottom, $nColor, $iShade, $iStep) If Not IsArray($aPix) Then ExitLoop If Not IsArray($aCoords) Then Local $aCoords[1][2] $nYAdd += ($aPix[1] - $yTop) + 1 $iAdd += 1 ReDim $aCoords[$iAdd + 1][2] $aCoords[$iAdd][0] = $aPix[0] $aCoords[$iAdd][1] = $aPix[1] WEnd Next If IsArray($aCoords) Then Return $aCoords Return SetError(1, 0, 0) EndFunc Func _ArrayDisplay2D($aArray, $sTitle = 'Array Display 2Dim', $iBase = 1, $sToConsole = 0) If Not IsArray($aArray) Then Return SetError(1, 0, 0) Local $sHold = 'Dimension 1 Has: ' & UBound($aArray, 1) -1 & ' Element(s)' & @LF & _ 'Dimension 2 Has: ' & UBound($aArray, 2) - 1 & ' Element(s)' & @LF & @LF For $iCC = $iBase To UBound($aArray, 1) - 1 For $xCC = 0 To UBound($aArray, 2) - 1 $sHold &= '[' & $iCC & '][' & $xCC & '] = ' & $aArray[$iCC][$xCC] & @LF Next Next If $sToConsole Then Return ConsoleWrite(@LF & $sHold) Return MsgBox(262144, $sTitle, StringTrimRight($sHold, 1)) EndFunc
  3. Ok, I think I understand where you're going with that. I guess I could start with the array signature for the largest "hand" and subtract 1 from every value per array...? Then see if it falls into a relative size of one of those arrays? This is going to be complicated and speed will be an issue. I guess it doesn't have to be real time as long as it works. You could still use captured video, I guess. Maybe a combo pixelgetcolor and pixelchecksum will work. This may be too much for it to handle.
  4. Pixel checksum isn't going to work well enough for this because it always changes. I have the exact color dialed in, I just need to figure out a way to compare the arrays on different scales if that makes any sense. I can already get it to recognize movement and take what ever action, but I want to take it further by having the ability to make a decision based on the shape, or what it sees. Not just that it sees movement. This is going to be amazing if I can ever get it to work. I have a few other things in mind already like a completely automated paintball turret. When you walk by, you get unloaded on!
  5. Let me get deeper into what I'm trying to do. If you look at the picture of the hand on my last post, you'll notice the yellow outline. What I hope to accomplish is to recognize the hand even if you move the hand farther from the camera, causing it to be smaller in the captured image. Technically, even though the hand is smaller, it retains the same relative shape. I'd like to figure out a way to use a ratio, -/+ a certain % threshold by comparing (array values * ratio) to determine that it is still a hand even though the size has changed. This has to be mathematically possible. Any suggestions?
  6. Awesome, SmOke_N....Got it working...Can these arrays be compared, though...Let me get deeper into what I'm trying to do. If you look at the picture of the hand on my last post, you'll notice the yellow outline. What I hope to accomplish is to recognize the hand even if you move the hand farther from the camera, causing it to be smaller in the captured image. Technically, even though the hand is smaller, it retains the same relative shape. I'd like to figure out a way to use a ratio, -/+ a certain % threshold by comparing (array values * ratio) to determine that it is still a hand even though the size has changed. This has to be possible. Any suggestions?
  7. Oh, wow...So you're saying that there is no way to return all pixels found of a given color? I hope not. This was going to be sweet. I'm working on a motion sensor script for webcams that can identify a specific signature. It's almost a crude facial recognition breakthrough. This is why I want to plot and compare the #FFFF00 yellow array coordinates signatures. Now I'm sure you understand why. Is there any way to make this happen with autoit?
  8. Ok, I can get the coordinates to write to the same column, but for some reason I'm having trouble getting x in column0 and y in column1 and so on like this... [col0],[col1] 149, 248 164, 326 112, 543 This is where I started but it's returning a blank array. CODE#include<Array.au3> Dim $avArray[10][2] While 1 $coord = PixelSearch(0, 0, 320, 240, 0xFFFF00, 10) If @error Then Sleep(1000) Else MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1], 3) _ArrayAdd($avArray[0][0], $coord[0]) _ArrayAdd($avArray[0][1], $coord[1]) _ArrayDisplay( $avArray, "Whole array" ) EndIf WEnd
  9. Awesome...Thanks, lokster. That solved it.
  10. No, I can reach it from other machines on the lan when it's running. It just doesn't display the picture. Has the red X like it doesn't exist and the timestamp. The pic is in the working directory, though. What the heck?
  11. Is anyone else not getting the pic displayed on the html page? It's taking the scrshot.bmp and the page can be reached anywhere on the lan, but it won't show the pic that gets taken on the page. Any ideas?
  12. Anybody there on the stuck shift key question above?
  13. Awesome...Both of these solutions are working. I do still have one question though. If one of the words is capitalized, the shift key sticks. I've tried to release it by Send("{SHIFTDOWN}{SHIFTUP}") and variants of up and down to no avail. How do you get around this? Also in chris95219's example, if you hold the key for more than a milisecond or so it registers multiple times and doesn't recognize the word. I think the send delay needs to be adjusted, but I haven't figured out how to make it work yet. Advice?
  14. Is it possible with _IsPressed to redirect or run a file when a group of words or a specific string is typed in succession, kind of like a realtime bad word filter? The redirect part is easy, but I'm not sure how to get it to recognize that an exact specific string was entered. Any ideas? When "cat" is typed I want to MsgBox...not "tac" or "act" CODE#include <Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep ( 250 ) If _IsPressed("43", $dll) + _IsPressed("41", $dll) + _IsPressed("54", $dll) Then MsgBox(0,"_IsPressed", "End Key Pressed") ExitLoop EndIf WEnd DllClose($dll)
  15. No, that's not it either because I think the _IELinkGetCollection isn't working when I do this so it ends up being a completely empty array....I'm stumped, but I'll keep trying...Is _ArrayAdd overwriting $array, or does it always append to the end?
  16. I bet he has a different character set installed...Probably Cyrillic or Arabic...lol
  17. Ok, here's the deal....I've successfully gotten this to load up the first page of friends, extract the links, search the source of every profile on the first page for my friendID, and populate the matching data into array2...Here's the issue. When it switches to page 2 after populating array2, it doesn't perform the link extraction and source search on any page after the first. It just keeps cycling through the pages and displays the incomplete arrays. What am I doing wrong with the loop? CODE#include <IE.au3> #include<Array.au3> #include<File.au3> #include<String.au3> #include <INet.au3> Dim $avArray[1] Dim $avArray2[1] $i = 2 Global $friendID = "32406107" Global $oIE = _IECreate("http://friends.myspace.com/index.cfm?fuseaction=user.viewfriends&friendID=" & $friendID) $oLinks = _IELinkGetCollection($oIE) Global $sHref = "profile" While $i <= 5;;;;;;;;;;;;;;;;;;;;;;;;;;;; For $oLink In $oLinks _ArrayAdd($avArray, $oLink.href) If StringInStr(String($oLink.href), $sHref) Then EndIf If StringInStr(_INetGetSource($oLink.href), '32406107') > 0 Then _ArraySearch($avArray2, $oLink.href, 0, 0, 0, True) If @error Then _ArrayAdd($avArray2, $oLink.href) EndIf Next $oLinks = _IELinkGetCollection($oIE) $oSubmit = "java script:__doPostBack('ctl00$cpMain$pagerTop','" & $i & "')" _IENavigate($oIE, $oSubmit) $i = $i + 1 WEnd _ArrayDisplay($avArray, "Whole array") _ArrayDisplay($avArray2, "Whole array")
  18. Ok, I know that you can pull html source with _INetGetSource but how do you pull the source of multiple links on a page and extract a specific string (friendID) from each page? What I'm trying to do is find who on my friends list have me on their top friends. (which if you use myspace, you'll know that would be awesome) I have a feeling that this is going to be pretty difficult to achieve because the view all friends page that you would get the links+source from is multiple pages and if you have a lot of friends I don't know if autoit can return all of your friends links and source without actually creating and opening the page. First I think I need to figure out how to search everyone on my friends lists page source for my friend id, then it would be easy from there. Any suggestions?
  19. Any ideas why this returns blank? Is it because of the quotes in the friend id line? CODE#include <INet.au3> #include<String.au3> $userid = "tom" $profile = 'www.myspace.com/' & $userid $values = _StringBetween(_INetGetSource($profile), 'friendid=', '" id=') MsgBox(0, "User ID:", "User ID is " & $values)
  20. Ok, forgive me and I promise that this will be the last question about this but I'm really trying to wrap my head around autoit3. (used to use v2 a lot waaaay back in the day) What do I need to do to display the value to a msgbox like this? Is $values blank unless you use _ArrayDisplay? CODE#include <INet.au3> #include<Array.au3> #include<String.au3> $profile = 'www.myspace.com/tom' $source = _INetGetSource ($profile) $values = _StringBetween($source, 'class="redtext">', '</span>' ) MsgBox(0, "Comment count is:", $values)
  21. Yeah, my bad....forgot the #include....It's 5:39am here...Thanks a ton mega...I was making it waaaaay harder than it is. You're the man.
  22. Jeez that would be a heck of a lot easier than what I'm doing, but I'm getting an unknown function name error at _InetGetSource for some reason....syntax?
  23. Here's the whole source. Haven't got it working without writing to a file, but I'll figure it out eventually. I'm stumped for now. My goal once I can get it working is to monitor and notify me everytime anyone on my friends list has new comments on their myspace, or something changes on their profile like the headline. I'd just compare the whole page source to the last one logged, but because of the ads and timestamp crap the source changes everytime you pull it. The line that displays how many comments you have is perfect because it's always in the same line in the page source, but the number changes so you can check it for changes. CODE #include <INet.au3> $comments = "Displaying" $file = FileOpen("test.txt", 1) $linetext = "line.txt" $lineread = FileOpen("line.txt", 0) $profile = "www.myspace.com/tom" $source = _INetGetSource ($profile) FileWrite($file , $source) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileClose($file) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $file = FileOpen("test.txt", 0) While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop if StringInStr(" "&$line,$comments)>0 then FileWrite($linetext, $line) WEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Output to msgbox returning blank FileClose($file) $var = StringMid($linetext, 100, 4) MsgBox(0, "comment count is:", $var) It only works when manually entered instead of using a variable like this, so I guess it can't parse the quotes from a variable. CODE$linetext = (" <b>Displaying<span class=""redtext""> 49 </span>of<span class=""redtext""> 429 </span>comments&nbsp;") $var = StringMid($linetext, 100, 4) MsgBox(0, "2 chars extracted from position 3 are:", $var)
×
×
  • Create New...