Jump to content

Search the Community

Showing results for tags 'pixelgetcolor'.



More search options

  • 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
  • AutoIt

Calendars

  • Community Calendar

Found 11 results

  1. Hello Autoit! Today i discovered that pixelgetcolor doesn't adapt to the DPI of the system, and i want to fix this somehow as my laptop uses 120 DPI. This is what i have came up with so far: AutoItSetOption ( "CaretCoordMode" , 0) AutoItSetOption ( "MouseCoordMode" , 0) AutoItSetOption ( "PixelCoordMode" , 0) AutoItSetOption ( "GUICoordMode" , 0) #include <MsgBoxConstants.au3> #include <Misc.au3> #include <WinAPIGdi.au3> ; enum _PROCESS_DPI_AWARENESS Global Const $PROCESS_DPI_UNAWARE = 0 Global Const $PROCESS_SYSTEM_DPI_AWARE = 1 Global Const $PROCESS_PER_MONITOR_DPI_AWARE = 2 ; enum _MONITOR_DPI_TYPE Global Const $MDT_EFFECTIVE_DPI = 0 Global Const $MDT_ANGULAR_DPI = 1 Global Const $MDT_RAW_DPI = 2 Global Const $MDT_DEFAULT = $MDT_EFFECTIVE_DPI HotKeySet('{ESC}','Terminate') Func Terminate() Exit EndFunc $iPD = 1 while 1 $aPos = WinGetPos("[ACTIVE]") ToolTip (PixelGetColor( MouseGetPos()[0]*(96/_DPI(0)), MouseGetPos()[1]*(96/_DPI(1))) & ', ' & MouseGetPos()[0] & ', ' & MouseGetPos()[1] ) if $iPD = 1 and Not _IsPressed(22) Then $iPD = 0 Sleep(100) EndIf if $iPD = 0 And _IsPressed(22) Then ;Page down is pressed ClipPut( 'PixelGetColor($aPos[2]' & '*' & MouseGetPos(0)/$aPos[2] & ',' & '$aPos[3]' & '*' & MouseGetPos(1)/$aPos[3] & ')' & '=' & PixelGetColor( MouseGetPos()[0], MouseGetPos()[1])) $iPD = 1 EndIf WEnd ;Functions Func _DPI($iCordinate) ;0 for x and 1 for y _WinAPI_SetProcessDpiAwareness($PROCESS_SYSTEM_DPI_AWARE) $aMonitors = _WinAPI_EnumDisplayMonitors() $aDPI = _WinAPI_GetDpiForMonitor($aMonitors[1][0], $MDT_DEFAULT) Return $aDPI[$iCordinate] EndFunc Func _WinAPI_SetProcessDpiAwareness($DPIAware) DllCall("Shcore.dll", "long", "SetProcessDpiAwareness", "int", $DPIAware) If @error Then Return SetError(1, 0, 0) EndFunc Func _WinAPI_GetDpiForMonitor($hMonitor, $dpiType) Local $X, $Y $aRet = DllCall("Shcore.dll", "long", "GetDpiForMonitor", "long", $hMonitor, "int", $dpiType, "uint*", $X, "uint*", $Y) If @error Or Not IsArray($aRet) Then Return SetError(1, 0, 0) Local $aDPI[2] = [$aRet[3],$aRet[4]] Return $aDPI EndFunc I'm pretty sure it has to do with me using the DPI in the wrong way as i dont really understand it (even after searching around on the internet for like an hour) It would really help if anyone could help me on the right track
  2. I have a program that has a control that changes color a few seconds into running. So ideally, I would poll this to tell when an event has occurred. I can't seem to retrieve the correct color value for a control. It always seems to return white indicating that its selecting somewhere else in the window. In the PixelGetColor call I'm adding half the width to the x value and subtracting half the height to the y value in order to get the center of the control. (assuming the coords returned by ControlGetPos are top left - which i can't be sure of) But I've also tried without modifying the x/y and with changing the PixelCoordMode option to 2. Maybe I'm making a silly mistake and can't see it? Any help would be appreciated. Code is below: Opt("PixelCoordMode", 0) FileChangeDir( "C:\Where\My\File\Is" ); Run( "MyProgram.exe" ) Local $hClient = WinWaitActive( $CLIENT_TITLE, "", 10 ) Local $systemIndicatorClassNN= "[CLASS:Qt5QWindowIcon; INSTANCE:99]" Local $hSystemIndicator = ControlGetHandle ( $hClient, "", $systemIndicatorClassNN) Local $xywh = ControlGetPos ( $hClient, "", $hSystemIndicator ) For $i = 10 To 1 Step -1 $color = PixelGetColor ( $xywh[0] + ($xywh[2]/2), $xywh[1] - ($xywh[3]/2), $hClient ) LogToFile( $color ) Sleep( 2000 ) Next
  3. HotKeySet("^{SPACE}", "get_color") $colorCodeHere = ;<---------------- func get_color() Global $point = MouseGetPos() Global $color = PixelGetColor($point[0], $point[1]) MsgBox(0, "debug", "result: " & $color) EndFunc While 1 Sleep(100) WEnd Hello guys my problem is, how can i store the value that i get in that PixelGetColor($point[0], $point[0]) i know that when i msgbox the color i will show the = of $color but i wanted it to be the value like $colorCodeHere = 13456254. but not hardcoding the value. or how could i say if $color is = to $color then do this and if $color is not equal to $color then do that.
  4. I had this problem with PixelGetColor not giving me the same HEX Color as the AU3Info Tool and searched every were with no luck then had a OH DA moment LoL. The problem is that the "PixelGetColor ($mouseX[0], $mouseY[1])" is looking rite at the very tip of the mouse pointer not under it. So you have to set a -3 after the [0] and [1]. "PixelGetColor ($mouseX[0] -3, $mouseY[1] -3)" to make it search next to the pointer not on the pointer. You may have to adjust this a bit for your display but you should not have to go more then -5. -3 seems to work best for me. Example.au3 #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 141, 127, 276, 231) $Input1 = GUICtrlCreateInput("", 8, 8, 121, 21) $Label1 = GUICtrlCreateLabel("Press or Hold F1 to get Hex color at Mouse X -3, Y-3 Pos,", 8, 40, 124, 73) GUISetState(@SW_SHOW) HotKeySet("{f1}","MousePos") Func MousePos() $aPos = MouseGetPos() $PGC = PixelGetColor($aPos[0] -3, $aPos[1] -3) GUICtrlSetData($Input1, "0x" & Hex($PGC, 6)) EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
  5. Hello i have problem with function PixelGetColor. On my computer it working fine but in some cases it not working. And Im clicking on the active window on red color and it give me the same color still. But in other computers when clicking on the same color red it gives other values and returned color in MsgBox is not red. Dont know is it a real main thing what causing problem but, I noticed that problem was on one windows 10. I have windows 8 and working well. On other windows 10 works well to Maybe it is caused by windows aero or something like that How to deal with it? There is a code HotKeySet("{PAUSE}", "MouseCord") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func MouseCord() Global $MousePos = MouseGetPos() $clickedColor = PixelGetColor($MousePos[0], $MousePos[1]) MsgBox(0, "Done", $clickedColor) EndFunc
  6. Hello i Have HP Bar in my game and it has 170px of width and then im gonna find start of this by mouse pos then i got $hpStart[0] = 661 $hpStart[1] = 230 , $hpEnd[0] = 839 And there is from $hpStart[0] = 661 the same color - 0xCB423B but depends of my points of hp for example on pixel $hpStart[0] = 745 would be another color not 0xCB423B and then i will know my my character got 50% of health points. I encountered problem here - for loop still looping to 839 and not founding this change in color for example on pixel $hpStart[0] = 745 I would know actual $i counter and $hpEnd[0] then only i can calculate current health percent value Please help me how to achieve that! Thanks for any help Func MouseCord() $MousePos = MouseGetPos() global $hpStart = $MousePos global $hpEnd = $hpStart $hpEnd[0] = $hpEnd[0] + 170 For $i = $hpStart[0] To $hpEnd[0] ; Looping from 661 to 839 $pixel = PixelGetColor($i,$hpStart[1]) If $pixel <> 0xCB423B Then $hpNowPer = ( $hpEnd[0] - $i ) / 170 $hpPoOdjeciu = 1 - $hpNowPer $hpNowPercent = Round($hpPoOdjeciu,2) ExitLoop ; - that not working EndIf Next EndFunc
  7. I have a need to make the mouse push down the the left button and trace a shape that goes in all directions . If it can follow the line in a full circle I'd be set. I'm not concerned with the left mouse down, I have that figured out for later. My problem is having the cursor follow a circle in paint. It'll follow some but I think it's going toward 0,0 I'm guessing but falls off once it gets to a certain point. I've searched, I've tried several methods. This code below has been the simplest that works close but won't follow a full, or half circle. It just falls off. More detail that you need but if you've ever seen contour lines on a map, that's what I'm ultimately wanting to follow. I'll be doing it on my own images that I create by scanning the water with sonar and making lake maps. I want to put my image on google earth and turn the contour lines into paths so they have latitude longitude data. Tracing them manually is very time consuming and accuracy suffers. Thank you for any time you spend on this. It would be very helpful. HotKeySet("{ESC}", "Terminate") Const $color = 0x000000 Local $start = MouseGetPos() While 1 $pos = MouseGetPos() If $pos = $start Then ContinueLoop $pix = PixelSearch($pos[0] - 5, $pos[1] - 5, $pos[0] + 5, $pos[1] + 5, $color, 5) If @error = 1 Then ContinueLoop $start = $pos MouseMove($pix[0], $pix[1]) Wend Func Terminate() Exit EndFunc
  8. Hi all expert autoit. I got a problem with imagesearch and pixelgetcolor. It not work for all pc. My autoit program work fine on my pc with nvidia graphic card. when i test it will another pc, which use onboard card, it not working. i think my problem is difference of graphic card. How can i fix it? how can i use pixelgetcolor with all pc?? Here my example code $color=PixelGetColor($X , $Y ) if $color="XXXXXX" then msgbox(0,"wn"," found it") else msgbox(0,"wn"," not found") EndIF
  9. I'm experimenting with GetPixel functions (in order to find the fastest) and have this simple part in my script: Local $iWidth = 150 Local $iHeight = 300 Local $array[$iHeight][$iWidth] For $i = 1 To $iHeight Step 1 For $j = 1 To $iWidth Step 1 $array[$i-1][$j-1] = PixelGetColor($iHeight-1, $iWidth-1, $Handle) Next Next Trying to get the equivalent using the GDI+ library (more specifically, using the _GDIPlus_BitmapLockBits function) I've got this code: Global $Handle = WinGetHandle("Paint") Local $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" ; X64 running support ; Initialize GDI+ library _GDIPlus_Startup() ; Capture 32 bit bitmap to a HBITMAP WinActivate($Handle) Local $hBMP = _ScreenCapture_CaptureWnd("", $Handle) ; _ScreenCapture_CaptureWnd returns a handle to an HBITMAP if $sFileName is empty Local $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) Local $iWidth = 150 Local $iHeight = 300 Local $array[$iHeight][$iWidth] Local $BitmapData = _GDIPlus_BitmapLockBits($pBitmap, 0, 0, $iWidth, $iHeight, $GDIP_ILMREAD, $GDIP_PXF32RGB) Local $Scan0 = DllStructGetData($BitmapData, "Scan0") Local $Stride = DllStructGetData($BitmapData, "Stride") Local $pixel = $Scan0 + $Stride + 4 Local $dPixel = DllStructCreate("dword", $pixel) MsgBox(0, "mBox", "$Scan0=" & $Scan0 & " $Stride=" & $Stride & " pixel=" & $pixel) For $i = 1 To $iHeight Step 1 For $j = 1 To $iWidth Step 1 ; <?> Next Next ; Clean up resources _GDIPlus_BitmapUnlockBits($pBitmap, $BitmapData) _GDIPlus_BitmapDispose($pBitmap) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown() And yeah, there's where I'm struggling at the moment (see ; <?> line). I don't get any return value from the DllStructCreate() call (to the $dPixel variable) The $pixel variable contains at this point 0x026D7A84. I need help to proceed, and I don't fully understand the $Scan0 and $Stride usage. And how to convert pixel data to x and y coordinates for use in the loop (i and j). My goal is to get the decimal value of each pixel into the array (exactly the same way as when using the PixelGetColor() method, see above) hAlp
  10. This script takes a total of ~6 seconds for me, each test taking ~1 sec: Global $wnd=WinGetHandle("[ACTIVE]") Global $total_time Global $result $n1 = 60000 $start_time = TimerInit() For $i = 1 To $n1 PixelGetColor(1, 1) Next $time1=int(TimerDiff($start_time)) $total_time += $time1 $result &= "1. PixelGetColor: same screen pixel, omitting handle parameter: " & $time1 & " ms" & @LF Sleep(30) $start_time = TimerInit() For $x = 0 To 299 For $y = 0 To 199 PixelGetColor($x, $y) Next Next $time1=int(TimerDiff($start_time)) $total_time += $time1 $result &= "2. PixelGetColor: screen rectangle 300x200 pixels, omitting handle parameter: " & $time1 & " ms" & @LF Sleep(30) $n1 = 60000 $start_time = TimerInit() For $i = 1 To $n1 PixelGetColor(1, 1, "") Next $time1=int(TimerDiff($start_time)) $total_time += $time1 $result &= "3. PixelGetColor: same screen pixel, using parameter "": " & $time1 & " ms" & @LF Sleep(30) $start_time = TimerInit() For $x = 0 To 299 For $y = 0 To 199 PixelGetColor($x, $y) Next Next $time1=int(TimerDiff($start_time)) $total_time += $time1 $result &= "4. PixelGetColor: screen rectangle 300x200 pixels, using parameter "": " & $time1 & " ms" & @LF Sleep(30) $n1 = 60000 $start_time = TimerInit() For $i = 1 To $n1 PixelGetColor(1, 1, $wnd) Next $time1=int(TimerDiff($start_time)) $total_time += $time1 $result &= "5. PixelGetColor: same screen pixel, using parameter [Active]: " & $time1 & " ms" & @LF Sleep(30) $start_time = TimerInit() For $x = 0 To 299 For $y = 0 To 199 PixelGetColor($x, $y, $wnd) Next Next $time1=int(TimerDiff($start_time)) $total_time += $time1 $result &= "6. PixelGetColor: screen rectangle 300x200 pixels, using parameter [Active]: " & $time1 & " ms" & @LF $result &= @LF $result &= "Total time: " & $total_time & " ms" ; exluding sleep's MsgBox(0, "mBox", $result) What results do you get? (XP users particulary of interest) Is my numbers normal/expected? Is there any way to speed this up (staying with default functions)? I've been looking for alternatives and one seems to be _GDIPlus_BitmapLockBits with a simple example available >here. That example makes my AutoIt crash completely though (even with handle "" specified). >Another example also crashes for me, so I'm a bit lost. Does the GDIPlus example(s) work for you? I'd love to stay with PixelGetColor for now, if possible. Any help greatly appreciated. Machine: WinXP Pro SP3 GPU 1GB GeForce 3 GB RAM 1600x1200x32 Window Classic theme AutoIt v3.3.10.2
  11. In my script i check a small area (say 20x20 pixels) with looped PixelGetColor. This has worked without any real problems for months and has taken about 20ms to complete. To test my script, I'm running Photoshop and activate different layers to show different photos. This has also worked great. After a GPU replace (to the better) a week ago it worked great the first few days, but now I've come to a dead end. This is the deal: I open my .psd file and runs my script - performance is ok I switch to layer 2 and runs my script - performance is ok I switch back to layer 1 and runs my script - performance is horrible, almost 50ms. At this point it doesn't matter what I do, every use of PixelGetColor() is slow. Now, if I close Photoshop completely, reopens my .psd file and run the script again - performance is ok What could possible be the problem!? Could it be anything with the new Nvidia drivers - PhysX/hyperthreading and all that new shit (which I didnt use earlier)? After a search through the forums I've found some interesting stuff making me far from the only one having general performance issues using the PixelGetColor() function. I'm gonna take a shot using _GDIPlus_BitmapLockBits instead and see if that helps. But I wonder if there might be something more at work in my case? As mentioned, I'm using the same script as I have for months. I've tested with Photoshop again and again - same result. Also tried using Paint but then its horrible speed constantly. It's just now the problems started. Related links on the matter Setup WinXP GPU 1GB GeForce 3 GB RAM 1600x1200x32 Window Classic theme with all Performance Visual Effects turned off. AutoIt v3.3.8.1
×