|
You last visited: Today at 10:18
Advertisement
PixelGetColor in background?
Discussion on PixelGetColor in background? within the AutoIt forum part of the Coders Den category.
04/26/2019, 21:14
|
#1
|
elite*gold: 0
Join Date: Apr 2019
Posts: 2
Received Thanks: 0
|
PixelGetColor in background?
I'm trying to make a bot that works in background (Not minimized). Someone know if its possible to make PixelGetColor works for a specific window(using getwindowhandle)? Thanks for who will help me.
|
|
|
04/26/2019, 23:29
|
#2
|
elite*gold: 138
Join Date: Apr 2012
Posts: 3,494
Received Thanks: 1,769
|
You can use FastFind for that
Although as far as I remember, the window you'd want to take snapshots from may not be minimized, otherwise the library won't get an image. A workaround for that can be to move the window out of your screen
|
|
|
04/27/2019, 03:04
|
#3
|
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
|
Quote:
Originally Posted by Napulé
I'm trying to make a bot that works in background (Not minimized). Someone know if its possible to make PixelGetColor works for a specific window(using getwindowhandle)? Thanks for who will help me.
|
You cannot get color of a window that isn't active or is hidden by another window, simply because won't be drawn if it is in background or would maintain previous state.
Example -> targetwindow.au3
Code:
#include <GDIPlus.au3>
#include <Misc.au3>
_GDIPlus_Startup()
$gui = GUICreate("test",300,300)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($gui)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics(300,300,$hGraphic)
$hBackBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
$hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)
guisetstate()
Global $colors = [0xFFFF0000,0xFF00FF00,0xFF0000FF,0xFF00FFFF]
$rotate = 0
While Sleep(15)
if GUIGetMsg() = -3 Then ExitLoop
if _IsPressed("01") Then
$rotate +=1
While _IsPressed("01")
Sleep(5)
WEnd
EndIf
_GDIPlus_GraphicsClear($hBackBuffer)
_GDIPlus_BrushSetSolidColor($hBrush,$colors[Mod($rotate,4)])
_GDIPlus_GraphicsFillRect($hBackbuffer,0,0,150,150,$hBrush)
_GDIPlus_BrushSetSolidColor($hBrush,$colors[Mod($rotate + 1,4)])
_GDIPlus_GraphicsFillRect($hBackbuffer,150,0,150,150,$hBrush)
_GDIPlus_BrushSetSolidColor($hBrush,$colors[Mod($rotate + 3,4)])
_GDIPlus_GraphicsFillRect($hBackbuffer,0,150,150,150,$hBrush)
_GDIPlus_BrushSetSolidColor($hBrush,$colors[Mod($rotate + 2,4)])
_GDIPlus_GraphicsFillRect($hBackbuffer,150,150,150,150,$hBrush)
_GDIPlus_GraphicsDrawImage($hGraphic,$hBitmap,0,0)
WEnd
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($hBackbuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_Shutdown()
getPixelfromTarget.au3
Code:
#include <GDIPlus.au3>
#include <Misc.au3>
_GDIPlus_Startup()
AutoItSetOption("PixelCoordMode",2)
$hwnd = WinGetHandle("test")
$gui = GUICreate("currentColors",300,300)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($gui)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics(300,300,$hGraphic)
$hBackBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
$hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
guisetstate()
While Sleep(5)
$color1 = PixelGetColor(0,0,$hwnd)
$color2 = PixelGetColor(150,0,$hwnd)
$color3 = PixelGetColor(0,150,$hwnd)
$color4 = PixelGetColor(150,150,$hwnd)
_GDIPlus_GraphicsClear($hBackBuffer)
_GDIPlus_BrushSetSolidColor($hBrush,"0xFF" & Hex($color1,6))
_GDIPlus_GraphicsFillRect($hBackbuffer,0,0,150,150,$hBrush)
_GDIPlus_BrushSetSolidColor($hBrush,"0xFF" & Hex($color2,6))
_GDIPlus_GraphicsFillRect($hBackbuffer,150,0,150,150,$hBrush)
_GDIPlus_BrushSetSolidColor($hBrush,"0xFF" & Hex($color3,6))
_GDIPlus_GraphicsFillRect($hBackbuffer,0,150,150,150,$hBrush)
_GDIPlus_BrushSetSolidColor($hBrush,"0xFF" & Hex($color4,6))
_GDIPlus_GraphicsFillRect($hBackbuffer,150,150,150,150,$hBrush)
_GDIPlus_GraphicsDrawImage($hGraphic,$hBitmap,0,0)
WEnd
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($hBackbuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_Shutdown()
Compile first script and run the second one, try hidding parts of the window with other windows and see the results.
One way to solve this problem is by activating target window before pixelCapture, but will pop up every time is needed to be updated, the other way is to use memory reading for events combined with control click (that would work in background). Also if the task is simple you can just solve it with control clicks without knowing state, just click target spots for buttons that may match together (rpg mobile games).
And last but not that easy, packet sniffing and sending requests to server.
|
|
|
 |
Similar Threads
|
pixelgetcolor im Hintergrund?
03/10/2009 - GW Bots - 20 Replies
wie der titel schon sagt würde ich gerne wissen ob es auch ein pixelgetcolor fürn hintergrudmode gibt(wär ja komisch da es ja die grafik an dem punkt sucht:D)
oda wie mann sowas lösen kann
also ich brache das zu folgendem:
ich lasse ich schleife so lang durch laufen bis der der nächste gegner (durch ständiges "nächstbefindlicher gegner" drücken:D) der fern kämpfer ist
also While not pixelgetcolor (......)
......
WEnd
lauf zu fehrkämpfer und beende
|
autoit prob mit pixelgetcolor
02/22/2009 - General Coding - 1 Replies
; wenn Pixel 137,133 dann
Send("{$Char down}")
sleep(500)
Send("{$Char UP}")
sleep(1000)
mouseclick("left",191,564)
;end if
wie schreibe ich des
ich will halt das wenn 137,133 den farbcode 0x1E2971 bekommt der mit
|
Pixelgetcolor frage dazu
12/26/2008 - Guild Wars - 15 Replies
das geht ja auch in anderen fenster neuerdings will ich mal nciht sagen aber hat einer erfahrung damit?
also ich meine mit erfahrung bugs oder so ob jemand mal gemerkt hat da funzt etwas nicht richtig oder der ließt eine pixel farbe falsch.
ich hatte damit jetzt noch keinerlei probleme aaber vllt hatte ja jemand schonmal probs damit nur als vorwahrnung sozusagen:p
|
AutoIt - PixelGetColor Probem auf versch. PC
06/04/2008 - AutoIt - 4 Replies
Hallo,
möglicherweise kann jemand von Euch helfen. Derzeit bin ich dabei, einen
AOE Bot für Archlord zu schreiben. Dieser funktioniert recht ordentlich und
flott. Allerdings nur auf meinem Rechner und nicht auf einem anderen. Das
ist natürlich grossartig für mich aber nicht für andere ^.o
Das merkwürdiges Problem ist, dass ich mit PixelGetColor auf PC1 z.B. den
Farbwert 73695A erhalte aber auf PC2 einen völlig anderen Farbwert.
|
All times are GMT +1. The time now is 10:18.
|
|