Jump to content

PixelChecksum returns 80000000


RichardL
 Share

Recommended Posts

The last few times I've used PixelChecksum it often returns 80000000.  The last time I used it to watch a progress indicator it gave me this list:

  • 22d25984
  • 12a74f7e
  • 80000000
  • 80000000
  • 80000000
  • 80000000
  • 55375982
  • 80000000
  • 0259f4da
  • 014c2e0d

The screen area was about 100*100, using default mode (=ADLER).  Windows-7 64.  I don't believe one number should occur that often, and seems to me that the calculations have hit most neg 32 bit value and given up?

Link to comment
Share on other sites

Can you pleae post the full statement you use? What is the value for "Step"?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Opt("MouseCoordMode", 2)
Opt("PixelCoordMode", 2)

$sTitle = <window_title>
WinActivate($sTitle)
Sleep(100)
$Pos = WinGetPos("")

...

; Wait for the area to become static.
For $iIx = 1 to 10
    $lCSum1 = PixelChecksum($Pos[2] * 89/100, $Pos[3] * 86 / 100, $Pos[2] * 99/100, $Pos[3] * 98 / 100)
    ConFmtWr("CS %8x\n", $lCSum1)
    Sleep(200)
Next

The Pos calculations select the bot-right about 100 pix square of a window.  I checked the calcs using MouseMove. (I've inserted code don't understand colour scheme.)

Edited by RichardL
oops, deleted the sleep from the loop
Link to comment
Share on other sites

You're calling PixelCheckSum() without a window handle, which means the function always scans the currently active client area. If another window becomes active during your loop, where no pixels are changing, you'll see repeated values like 80000000 even though the $sTitle window is still visible.

You can do this:

Opt("MouseCoordMode", 2)
Opt("PixelCoordMode", 2)

$sTitle = <window_title>
WinActivate($sTitle)
$hWin = WinGetHandle($sTitle)
Sleep(100)
$Pos = WinGetPos("")

...

; Wait for the area to become static.
For $iIx = 1 to 10
    $lCSum1 = PixelChecksum($Pos[2] * 89/100, $Pos[3] * 86 / 100, $Pos[2] * 99/100, $Pos[3] * 98 / 100, 1, $hWin)
    ConFmtWr("CS %8x\n", $lCSum1)
    Sleep(200)
Next

 

Link to comment
Share on other sites

I've added in the $hWin, doesn't fix the problem, and I've added a reading and printing the Active window title - it's not changing.  I'm going to try to make an independent demo, using notepad.

Edited by RichardL
shameful spelling
Link to comment
Share on other sites

have to chime in here - I see you used the word "bot" in your post and what you describe can easily be used in a game. Can you tell us please what application this script is being used in please? If a game, understand it is against forum rules to discuss game automation. Thanks.

Link to comment
Share on other sites

The code starts Notepad, repeatedly PixelChecksums the top right, while typing in letters. 

Now I see that the result from PixelChecksum is alright, but is often too big for the conversion to decimal or hex, so print the value as a string.  The equating with previous values seems to work with either = or ==, and in the end the actual value doesn't matter, just whether it matches the previous, or the reference.

 

Opt("MouseCoordMode", 2)
Opt("PixelCoordMode", 2)
Opt("MustDeclareVars", 1)

Func ConFmtWr($sCntrl, $a = "", $b = "", $c = "", $d = "", $e = "", $f = "", $g = "", $h = "", $i = "", $j = "", $k = "", $l = "")
    ConsoleWrite(StringFormat($sCntrl, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l))
EndFunc   ;==>ConFmtWr

Local $sTitle
Local $Pos
Local $lCSum0
Local $lCSum1
Local $iMMode
Local $iPMode
Local $iIx
Local $hWin
Local $bDiffN
Local $bDiffS

ShellExecute("Notepad")
$sTitle = "Untitled - Notepad"
WinMove($sTitle, "", 600, 100, 400, 400)
WinActivate($sTitle)
WinWaitActive($sTitle)
$hWin = WinGetHandle($sTitle)
Sleep(200)

MouseMove(0,0, 9)
MouseMove(200,100, 9)

$lCSum0 = 0
For $iIx = 1 to 20
    $lCSum1 = PixelChecksum(0, 0, 200, 100, 1, $hWin)
    $bDiffN = ($lCSum1 =  $lCSum0)
    $bDiffS = ($lCSum1 == $lCSum0)
    ConFmtWr("CS %08x %12d %12s %d %d\n", $lCSum1, $lCSum1, $lCSum1, $bDiffN, $bDiffS)
    $lCSum0 = $lCSum1
    If $iIx <> 5 Then Send("A")
    Sleep(200)
Next

Send("! Cn") ; close Notepad

 

Link to comment
Share on other sites

Hi,

did you read the helpfile about stringformat?

Return-type of PixelChecksum() is "double" (have a look into helpfile at VarGetType()-function)  , your "type-conversion" via %08x into integer can not work! The same with %12d, which is SIGNED integer also...you need an integer unsigned...

$lCSum1 = PixelChecksum(0, 0, 200, 100, 1, $hWin)
    $lCSum1 = Int($lCSum1)
    ConFmtWr("CS %08x %12u %12s %d %d\n", $lCSum1, $lCSum1, $lCSum1, $bDiffN, $bDiffS)

converts the double to integer, shows the Checksum in hex-view, unsigned integer and string....works now :o)

Link to comment
Share on other sites

Yes, I looked at the help on datatypes, StringFormat and I tried %u.  It will give better pos range, less neg, and didn't fix it for the values I was getting.  Double is I think 64 bit float with 52 bits of fraction and it looks like the limit of integer conversion in StringFormat is 32.  Anyway, detecting change works well, I should take care not to lose data by converting.

Link to comment
Share on other sites

with your skill and the fact your using notepad - I'm stunned at why you are not reading the control - which is really what notepad really is. So, is there some reason why you are not reading notepad in by reading the control and getting the text entered? Also - why move the mouse?

I'm reporting this thread to a moderator and have them chime in.

Edited by Bert
Link to comment
Share on other sites

8 hours ago, Bert said:

have to chime in here - I see you used the word "bot" in your post and what you describe can easily be used in a game. Can you tell us please what application this script is being used in please? If a game, understand it is against forum rules to discuss game automation. Thanks.

Perhaps bot-right refers to bottom-right, but wrote short handed. 

Link to comment
Share on other sites

  • Moderators

Hi,

Quote

I see you used the word "bot" in your post and what you describe can easily be used in a game

I see no prima facie evidence from the OP's posts in this thread to indicate that the code is destined for a game-bot - and as mere suspicion will never be a valid reason to act, I am leaving it open.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

41 minutes ago, RichardL said:

just to repeat the issue without the industrial software that I'm automating.

Automating "Industrial Software" is usually an adventure...

Even if the Window-Info-Tool detect a "Handle/Control" it must not be, that this "Control" can/could be "controlled" by the AutoIt-Control-Commands.

For example, i got some controls which included date/time. There was no possibility to "send" some data to those controls, the only way to automate the Software was to "click" into the control to activate the cursor, "step" to the end via sending an "end", delete the content with some "backspace"s and send the required numbers and a colon to "write" the needed time/date. :huh:

Not to mention those Windows which have not the focus after they appear, and/or at the worst, not to catch with the Window-control-functions....>_<

Usually, several routes lead to rome:D

Link to comment
Share on other sites

16 hours ago, RichardL said:

Notepad was just to repeat the issue without the industrial software that I'm automating.  I have looked at it with Window-Info, there's nothing available.  Sorry for abbreviation causing rule-breach false alarm.

Sorry for my earlier post.

I do have something that may help. Take a look at this: https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/

It should allow for you to hook into those controls that are giving you trouble and make your script much more stable.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...