Jump to content

Search the Community

Showing results for tags 'Pixelchecksum'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 6 results

  1. Hello everyone, I have several signals on the screen that need to be monitored while a program is running. These signals are scattered around an image which is maximized on 4 equal resolution screens - the AutoIT Window Info does not recognize any objects on the program meaning that I'm left with the PixelSearch() and PixelCheckSum() functions to monitor the signals: The signals are as small as a 5x5 pixel area and their coordinates are known. I've been digging around for a while now in this forum about the PixelSearch() and PixelCheckSum() and found some interesting and useful ideas for the use of them. I also came across some other UDF functions like MultiMon(), FastFind(), TtColXY() and the ImageSearch2015 scripts that might be useful for the final output. I don't know if hovering the mouse by using TtColXY() and output its ToolTip() information onto the log file will be faster than using PixelSearch() and/or PixelCheckSum() in a loop for all signals' coordinates. The colours of the signals are below: red - 0x00FF00 (opaque red) green - 0x00FF00 (opaque green) yellow - 0xFFFF00 (opaque yellow) black - 0x000000 (opaque black, default colour) EDIT: The desired output is to monitor and record/log the changes and status of each inside a .txt file or a .csv with the below format: Local Machine Time Signal, Change, delta-t 14:32:07 Signal1 Green - Yellow DELTA-t1 14:34:02 Signal1 Yellow - Red DELTA-t1 14:35:14 Signal2 Yellow - Red DELTA-t2 ... Below is the code I came up with. #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <misc.au3> #include <Date.au3> #include <Array.au3> #include <File.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> #include <WinAPIHObj.au3> Global $program_name, $program_open, $Wname, $tCurrent Global $button_xy[2] = [150, 175] Global $iniColour, $ColourCheck, $NewCheck Global $Red, $Green, $Blue, $Nil Global $sFilePath = @ScriptDir & "\Signals_status.txt" Global $SignalID[10] = ["Signal_1", "Signal_2", "Signal_3", "Signal_4", "Signal_5", "Signal_6", "Signal_7", "Signal_8", "Signal_9", "Signal_10"] $program_name = "Signals.exe" $Wname = "Training Task 3" $program_open = ShellExecute($program_name, @ScriptDir) WinWait($Wname) $iniColour = "0x" & Hex(PixelGetColor($button_xy[0], $button_xy[1]), 6) ;~ $iniChecksum = "0x" & Hex(PixelChecksum($button_xy[0], $button_xy[0] - 5, $button_xy[1], $button_xy[1] + 5), 6) $ColourCheck = "0x" & Hex(PixelChecksum($button_xy[0], $button_xy[0] - 5, $button_xy[1], $button_xy[1] + 5, 1, $Wname), 6) ConsoleWrite(_ColourID($iniColour) & " // " & _ColourID($ColourCheck) & @CRLF) ;~ $ColourCheck = "0x " & Hex(PixelGetColor($button_xy[0], $button_xy[1]), 6) $iniColour = $ColourCheck ;$iniChecksum = $currentCheck Do ;~ While 1 _WindowOnTop() _Close_Notepad() $NewCheck = "0x" & Hex(PixelChecksum($button_xy[0], $button_xy[0] - 5, $button_xy[1], $button_xy[1] + 5, 1, $Wname), 6) $tCurrent = _NowCalc() $LogFile = FileOpen($sFilePath, 2) FileWriteLine($LogFile, "Local Machine Time " & "Signal, " & "Change, " & "delta-t") ;~ $ColourCheck = "0x" & Hex(PixelChecksum($button_xy[0], $button_xy[0] - 5, $button_xy[1], $button_xy[1] + 5, 1, $Wname), 6) If $ColourCheck <> $NewCheck Then ;If there's a colour change from the current colour $ColourCheck = $NewCheck Local $tChange, $NewCheckID, $ColourCheckID, $sLogMsg $tChange = _NowCalc() ConsoleWrite("Colour changed!" & @CRLF) $ColourCheckID = _ColourID($ColourCheck) $NewCheckID = _ColourID($NewCheck) $iTimeDiffh = _DateDiff('h', $tChange, $tCurrent) ; time difference in hours $iTimeDiffm = _DateDiff('n', $tChange, $tCurrent) ; time difference in minutes $iTimeDiffs = _DateDiff('s', $tChange, $tCurrent) ; time difference in seconds $durationCheckSum = $iTimeDiffh & ":" & $iTimeDiffm & ":" & $iTimeDiffs ; Timestamp of the signal until PixelCheckSum $sLogMsg = " " & $SignalID[0] & " " & $ColourCheckID & " - " & $NewCheckID & " " & $durationCheckSum _FileWriteLog($LogFile, $sLogMsg) ElseIf $ColourCheck = $NewCheck Then Local $Colour_check = _ColourID("0x" & Hex(PixelChecksum($button_xy[0], $button_xy[0] - 5, $button_xy[1], $button_xy[1] + 5, 1, $Wname), 6)) ConsoleWrite($tCurrent & " " & $Colour_check & @CRLF) EndIf FileClose($sFilePath) Until Not ProcessExists($program_name) And Not WinExists($Wname) _IsProgramOpen() Func _Close_Notepad() $notepad_open = ProcessExists("notepad.exe") ? ProcessClose("notepad.exe") : ProcessClose("notepad.exe") $notepad_open = WinActive("[CLASS:Notepad]") ? WinClose("[CLASS:Notepad]") : ProcessClose("notepad.exe") EndFunc ;==>_Close_Notepad Func _ColourID($sColour) $Red = Int("0x" & StringRegExpReplace($sColour, "(..)(..)(..)(..)", "\2")) $Green = Int("0x" & StringRegExpReplace($sColour, "(..)(..)(..)(..)", "\3")) $Blue = Int("0x" & StringRegExpReplace($sColour, "(..)(..)(..)(..)", "\4")) If $Green > $Blue And $Red > $Blue And $Green >= 0xB0 And $Red >= 0xB0 Then $sCol = "Yellow" ElseIf $Blue > 0xE0 And $Green > 0xE0 And $Red > 0xE0 Then $sCol = "White" ElseIf $Blue > 0x50 And $Blue = $Green And $Blue = $Red Then $sCol = "Grey" ElseIf $Red > $Green And $Red > $Blue And $Red > 0x70 Then $sCol = "Red" ElseIf $Green > $Red And $Green >= $Blue And $Green > 0x70 Then $sCol = "Green" ElseIf $Blue > $Red And $Blue > $Green And $Blue > 0x70 Then $sCol = "Blue" Else $sCol = "Nil" EndIf Return $sCol EndFunc ;==>_ColourID Func _WindowOnTop() WinActivate($Wname) WinSetOnTop($Wname, "", $WINDOWS_ONTOP) Opt("MouseCoordMode", 0) EndFunc ;==>_WindowOnTop Func _IsProgramOpen() If Not ProcessExists($program_name) And Not WinExists($Wname) Then Break(1) EndIf EndFunc ;==>_IsProgramOpen When the program is running, the window opens in the centre of the screen however, the PixelChecksum function is not looking at the correct area. In addition: 1 - I'm not sure about how to put the message into the log file. 2 - I tested this script but it is not recording the message into the log file. 3 - Is there other way to calculate the duration in these lines? $iTimeDiffh = _DateDiff('h', $tChange, $tCurrent) ; time difference in hours $iTimeDiffm = _DateDiff('n', $tChange, $tCurrent) ; time difference in minutes $iTimeDiffs = _DateDiff('s', $tChange, $tCurrent) ; time difference in seconds $durationCheckSum = $iTimeDiffh & ":" & $iTimeDiffm & ":" & $iTimeDiffs ; Timestamp of the signal until PixelCheckSum $sLogMsg = " " & $SignalID[0] & " " & $ColourCheckID & " - " & $NewCheckID & " " & $durationCheckSum _FileWriteLog($LogFile, $sLogMsg) Thanks in advance!
  2. Hey there! Is there a way to detect movement only for 1 specific window? HWnd is not really working, it still detects movement in all the windows within the region This is my script: ;Checksum actual HotKeySet("{f2}", 'exit_') MsgBox(0, '', '0') Beep(500, 2000) $Hwnd = WinActive('') while 1 $Checksum = PixelChecksum(211, 650, 1094, 914, 1, $Hwnd) If PixelChecksum(211, 650, 1094, 914, 1, $Hwnd) <> $Checksum Then For $i = 1 To 100 Beep(1000, 50) Next MsgBox(0, '', 'New message!', 1) EndIf WEnd Func exit_() Beep(500, 1000) Exit 0 EndFunc I just want to check whenever a message comes because the app i use doesn't give notifications properly. Any help is really appreciated!
  3. Hi there, I did a short script to simulate mouse click when pixel change is detected on a small section of the screen. I recorded the screen many times to see the accuracy of the script and it seems though response time varies widely. Here's the script $checksum = pixelchecksum (400,250, 402,252) While $checksum = pixelchecksum (400,250, 402,252) Sleep (50) Wend Sleep (300) Mouseclick("left", 450,300, 1, 0) Counting from the pixel change to the mouse click, i get response times anywhere between 370ms and 550ms. I've tried running au3 and exe, changed sleep times but never gotten an accurate response time based on the script. Any ideas why?
  4. I could use a bit of math help. What I'd like to do is sample a 5x5 pixel area with PixelChecksum. I would then sample again a few seconds later to check for a change as seems to be the normal usage. Can I do any useful maths on the PixelChecksum results? For instance, if I subtracted the two sample values would it tell me anything about pixel color content? Might I know that a color shift has happened to maybe Blue or Red for instance? Or would I have to do that on a per pixel sample? And if that is the case... what math would i use to compare an RGB value against another to detect a shift in color from neutral towards Red or Blue? From the docs: Func _testShift() ; with PixelChecksum Local $toler=5 Local $PCS1 = PixelChecksum($x + $toler, $y + $toler, $x - $toler, $y - $toler, 1, $windowHandle , 0) Sleep(200) Local $PCS2 = PixelChecksum($x + $toler, $y + $toler, $x - $toler, $y - $toler, 1, $windowHandle , 0) If $PCS1 <> $PCS2 Then ; How to compare these meaningfully for colorshift? ; or with single pixel.... Local $px1 = PixelGetColor($x, $y, $windowHandle) Local $pxRGB1 = _ColorGetRGB($px1) Sleep(200) Local $px2 = PixelGetColor($x, $y, $windowHandle) Local $pxRGB2 = _ColorGetRGB($px2) If $px1 <> $px2 Then If $pxRGB1[0] < $pxRGB2[0] Then Red? If $pxRGB1[2] < $pxRGB2[2] Then Blue? EndFunc
  5. Hello, i need help with my script here. I want to detect when my Screen is nearly or completly dark/black. I'm using PixelChecksum(0,0,1919,1079) and it's giving me random numbers (e.g. 2690216355, 2589900821, 854331631, 481460664) How can i compare that with a Black like 0xFFFFFF ?
  6. when i macro surf with IE certain pages tend to hang or my IE crashes. so im looking for a way to get things moving again if im not around. is there any commands that can refresh page if, lets say, PixelChecksum (50,50,100,100) stays the same for maybe 2 mins?
×
×
  • Create New...