abdulrahmanok Posted September 21, 2021 Share Posted September 21, 2021 (edited) Hi All, I'm using pixel search to get specific color from screen, and i'm using (GUICreate) to genrate Rectangle shape that recover founded pixel so it can find another one. The issue that when using : GUIDelete($GUI) It doesn't close all created Gui. Here is my full script: expandcollapse popupinActivate('ArcMap') Sleep(1000) Global $S_Coords = [359, 105, 1434,703] Global $FoundPixs[0] While 1 If CheckArea($S_Coords[0], $S_Coords[1], $S_Coords[2],$S_Coords[3], 'ARCMAP Window') Then _ArrayAdd($FoundPixs, $Pix[0] & ',' & $Pix[1]) DrawRect() Sleep(200) Else For $i = 0 to UBound($FoundPixs) -1;Clean Detected Gui ; WinClose("Dummy_Color") GUIDelete($GUI) Next _ArrayDisplay( $FoundPixs, '$FoundPixs') ExitLoop EndIf WEnd While 1 Sleep(4000) Wend Func DrawRect() Local $startX = $Pix[0] - 20; Local $startY = $Pix[1] - 20; Local $endX = $startX + 40; Local $endY = $startY+ 40; Global $GUI = GUICreate("Dummy_Color",40,40,$startX, $startY,$WS_POPUP,-1) GUISetBkColor(0x008000,$GUI) ;GUISetBkColor(0x008000) GUISetState(@SW_SHOW) EndFunc ;0x0000FF ;Sleep(2000) Func CheckArea($X1, $y1, $x2, $y2, $Direction) Local $Coords = [$X1, $y1, $x2, $y2] Global $Pix=PixelSearch( $Coords[0],$Coords[1],$Coords[2],$Coords[03],0xFF00C5,0) If IsArray($Pix) Then ToolTip("Found Pix 1 At:" & $Direction ,0, 0) MouseMove($Pix[0], $Pix[1], 1) ;STP() ;print('Found Pix 1 At', $Direction) Return True EndIf Edited September 22, 2021 by abdulrahmanok Link to comment Share on other sites More sharing options...
Developers Jos Posted September 21, 2021 Developers Share Posted September 21, 2021 (edited) 6 minutes ago, abdulrahmanok said: Here is my full script: Don't think so.... it for sure won't run! Edited September 21, 2021 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nine Posted September 21, 2021 Share Posted September 21, 2021 @Jos Your CB has returned to repair shop again. Dam, those things are so fragile... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
abdulrahmanok Posted September 21, 2021 Author Share Posted September 21, 2021 1 hour ago, Jos said: Don't think so.... it for sure won't run! I really dont understand what you want to say... Link to comment Share on other sites More sharing options...
spudw2k Posted September 21, 2021 Share Posted September 21, 2021 (edited) Jos was pointing out that your example doesn't run on its own. This is contrary to your statement, "Here is my full script:" GUIDelete() must be used for each GUI handle created by GUICreate(), so if you have multiple GUIs, it makes sense that a single GUIDelete function only deletes the one whose handle you provide to the script. If you can provide a working script--because what you posted doesn't execute / it is incomplete--or a script the reproduces the problem, we can better assist. edit: from what I gather from the portion of code you posted, you are creating multiple guis and assigning the GUICreate() result (handle) to the global variable $GUI. $GUI can only hold one "thing" (handle) at a time. If you need to track multiple handles, you might be better suited using an array. Edited September 21, 2021 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
abdulrahmanok Posted September 21, 2021 Author Share Posted September 21, 2021 (edited) @spudw2k Thanks for explaining Here is my Updated Ex: expandcollapse popup#include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <array.au3> #include <WindowsConstants.au3> Sleep(2000) Global $S_Coords = [0, 0, @DesktopWidth,@DesktopHeight] Global $FoundPixs[0] While 1 If CheckArea($S_Coords[0], $S_Coords[1], $S_Coords[2],$S_Coords[3], 'ARCMAP Window') Then _ArrayAdd($FoundPixs, $Pix[0] & ',' & $Pix[1]) DrawRect() Sleep(200) Else For $i = 0 to UBound($FoundPixs) -1;Clean Gui Detected ; WinClose("Dummy_Color") GUIDelete($GUI) Next _ArrayDisplay( $FoundPixs, '$FoundPixs') ExitLoop EndIf WEnd While 1 Sleep(4000) Wend Func DrawRect() Local $startX = $Pix[0] - 20; Local $startY = $Pix[1] - 20; Local $endX = $startX + 40; Local $endY = $startY+ 40; Global $GUI = GUICreate("Dummy_Color",40,40,$startX, $startY,$WS_POPUP,-1) GUISetBkColor(0x008000,$GUI) ;GUISetBkColor(0x008000) GUISetState(@SW_SHOW) EndFunc ;0x0000FF ;Sleep(2000) Func CheckArea($X1, $y1, $x2, $y2, $Direction) Local $Coords = [$X1, $y1, $x2, $y2] Global $Pix=PixelSearch( $Coords[0],$Coords[1],$Coords[2],$Coords[03],0xED1C24,0) If IsArray($Pix) Then ToolTip("Found Pix 1 At:" & $Direction ,0, 0) MouseMove($Pix[0], $Pix[1], 1) ;STP() ;print('Found Pix 1 At', $Direction) Return True EndIf EndFunc Func STP() MsgBox(0, 0, 0, 1) EndFunc ;~ Raw(-165,0 );Raw 1 ;~ Func Raw($X_Change,$Y_Change ) ;~ $MainChangeX = $X_Change ;~ $MainChangeY = $Y_Change ;~ For $i = 1 To 3 ;~ _WinAPI_DrawRect($StartCoords[0] + $X_Change, $StartCoords[1]+$Y_Change, _ ;~ $StartCoords[2]+$X_Change, $StartCoords[3] +$Y_Change ,0xFC5A43 ) ;~ Sleep(500) ;~ $X_Change = $X_Change + $X_Change ;~ $Y_Change = $Y_Change + $Y_Change ;~ print('$X_Change', $MainChangeX) ;~ print('$Y_Change', $MainChangeY) ;~ Next ;~ EndFunc Func Calc_Distance($x1, $y1, $x2, $y2) ;Pythagoras theorem for 2D Local $a, $b, $c If $x2 = $x1 And $y2 = $y1 Then Return 0 Else $a = $y2 - $y1 $b = $x2 - $x1 Global $P_Found = Sqrt($a * $a + $b * $b) ;print($P_Found) Return $P_Found EndIf EndFunc ;==>Calc_Distance Func _WinAPI_DrawRect($start_x, $start_y, $iWidth, $iHeight, $iColor) Global $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) Local $tRect = DllStructCreate($tagRECT) DllStructSetData($tRect, 1, $start_x) DllStructSetData($tRect, 2, $start_y) DllStructSetData($tRect, 3, $iWidth) DllStructSetData($tRect, 4, $iHeight) Global $hBrush = _WinAPI_CreateSolidBrush($iColor) _WinAPI_FrameRect($hDC, DllStructGetPtr($tRect), $hBrush) ; clear resources Sleep(500) _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC(0, $hDC) EndFunc ;==>_WinAPI_DrawRect After start script while below image shown it must work. Edited September 21, 2021 by abdulrahmanok some includes Added Link to comment Share on other sites More sharing options...
spudw2k Posted September 21, 2021 Share Posted September 21, 2021 (edited) Better, but its still not something we can run as-is. We don't have your <myfuncs.au3> include. I assume all that is needed in it for this example if the print() function? Also, it fails to run because <Array.au3> and <WindowsConstants.au3> are missing. Perhaps they are inside <myfuncs> too? Anyways, like I mentioned. GUIDelete($GUI) is only deleting the most recently created GUI. Perhaps you can do something like this? 1) Add an extra dimension to your FoundPixs array to hold the GUI Handles returned by GUICreate() 2) Reference the array (dimension) when calling GUIDelete() Spoiler expandcollapse popup#include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> Sleep(4000) Global $S_Coords = [0, 0, @DesktopWidth, @DesktopHeight] Global $FoundPixs[0][2] Const Enum $ePIXELLOCATION, $eGUIHANDLE Global $Pix Global $GUI While 1 If CheckArea($S_Coords[0], $S_Coords[1], $S_Coords[2], $S_Coords[3], 'ARCMAP Window') Then $sPixelLocation = $Pix[0] & ',' & $Pix[1] $hGUIHandle = DrawRect() _ArrayAdd($FoundPixs, $sPixelLocation & "|" & $hGUIHandle) Sleep(200) Else For $i = 0 To UBound($FoundPixs) - 1;Clean Gui Detected GUIDelete($FoundPixs[$i][$eGUIHANDLE]) Next _ArrayDisplay($FoundPixs, '$FoundPixs') ExitLoop EndIf WEnd While 1 Sleep(4000) WEnd Func DrawRect() Local $startX = $Pix[0] - 20; Local $startY = $Pix[1] - 20; Local $endX = $startX + 40; Local $endY = $startY + 40; $GUI = GUICreate("Dummy_Color", 40, 40, $startX, $startY, $WS_POPUP, -1) GUISetBkColor(0x008000, $GUI) GUISetState(@SW_SHOW) Return $GUI EndFunc ;==>DrawRect Func CheckArea($X1, $y1, $x2, $y2, $Direction) Local $Coords = [$X1, $y1, $x2, $y2] $Pix = PixelSearch($Coords[0], $Coords[1], $Coords[2], $Coords[03], 0xED1C24, 0) If IsArray($Pix) Then ToolTip("Found Pix 1 At:" & $Direction, 0, 0) MouseMove($Pix[0], $Pix[1], 1) Return True EndIf EndFunc ;==>CheckArea Edited September 21, 2021 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
abdulrahmanok Posted September 21, 2021 Author Share Posted September 21, 2021 (edited) :: Edited September 21, 2021 by abdulrahmanok Link to comment Share on other sites More sharing options...
abdulrahmanok Posted September 21, 2021 Author Share Posted September 21, 2021 (edited) 25 minutes ago, spudw2k said: Better, but its still not something we can run as-is. Reveal hidden contents expandcollapse popup#include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> Sleep(4000) Global $S_Coords = [0, 0, @DesktopWidth, @DesktopHeight] Global $FoundPixs[0][2] Const Enum $ePIXELLOCATION, $eGUIHANDLE Global $Pix Global $GUI While 1 If CheckArea($S_Coords[0], $S_Coords[1], $S_Coords[2], $S_Coords[3], 'ARCMAP Window') Then $sPixelLocation = $Pix[0] & ',' & $Pix[1] $hGUIHandle = DrawRect() _ArrayAdd($FoundPixs, $sPixelLocation & "|" & $hGUIHandle) Sleep(200) Else For $i = 0 To UBound($FoundPixs) - 1;Clean Gui Detected GUIDelete($FoundPixs[$i][$eGUIHANDLE]) Next _ArrayDisplay($FoundPixs, '$FoundPixs') ExitLoop EndIf WEnd While 1 Sleep(4000) WEnd Func DrawRect() Local $startX = $Pix[0] - 20; Local $startY = $Pix[1] - 20; Local $endX = $startX + 40; Local $endY = $startY + 40; $GUI = GUICreate("Dummy_Color", 40, 40, $startX, $startY, $WS_POPUP, -1) GUISetBkColor(0x008000, $GUI) GUISetState(@SW_SHOW) Return $GUI EndFunc ;==>DrawRect Func CheckArea($X1, $y1, $x2, $y2, $Direction) Local $Coords = [$X1, $y1, $x2, $y2] $Pix = PixelSearch($Coords[0], $Coords[1], $Coords[2], $Coords[03], 0xED1C24, 0) If IsArray($Pix) Then ToolTip("Found Pix 1 At:" & $Direction, 0, 0) MouseMove($Pix[0], $Pix[1], 1) Return True EndIf EndFunc ;==>CheckArea I reliszed that later and edited it later : some includes Added And about your suggestions sorry but i dont know how to do that is there is any reference or guides for this? Edited September 21, 2021 by abdulrahmanok Link to comment Share on other sites More sharing options...
abdulrahmanok Posted September 21, 2021 Author Share Posted September 21, 2021 how to remove this dummy replies? Link to comment Share on other sites More sharing options...
spudw2k Posted September 21, 2021 Share Posted September 21, 2021 I don't think you can. Did my response and example make sense? Any questions? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
abdulrahmanok Posted September 22, 2021 Author Share Posted September 22, 2021 3 minutes ago, spudw2k said: I don't think you can. Did my response and example make sense? Any questions? Thank you very much that totally solve the problem, but I didn't understand how these variables handle my GUi Const Enum $ePIXELLOCATION, $eGUIHANDLE Link to comment Share on other sites More sharing options...
spudw2k Posted September 22, 2021 Share Posted September 22, 2021 I used those just to make it more human readable friendly when accessing the sub-indexes of the $FoundPixs array. $FoundPixs[index#][$ePIXELLOCATION] = the pixel coordinates $FoundPixs[index#][$eGUIHANDLE] = the handle returned by the GUICreate() function I never used the $ePIXELLOCATION constant later in the script, but I did use the $eGUIHANDLE constant in the GUIDelete() function. abdulrahmanok 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
abdulrahmanok Posted September 22, 2021 Author Share Posted September 22, 2021 (edited) 3 minutes ago, spudw2k said: I used those just to make it more human readable friendly when accessing the sub-indexes of the $FoundPixs array. $FoundPixs[index#][$ePIXELLOCATION] = the pixel coordinates $FoundPixs[index#][$eGUIHANDLE] = the handle returned by the GUICreate() function I never used the $ePIXELLOCATION constant later in the script, but I did use the $eGUIHANDLE constant in the GUIDelete() function. Everything is clear now, I appreciate your help❤️ I'm Googling now for Enum and how it works because I think I will use it too much in future Edited September 22, 2021 by abdulrahmanok Link to comment Share on other sites More sharing options...
spudw2k Posted September 22, 2021 Share Posted September 22, 2021 The AutoIt help file has a very helpful article for using it. Enum I use it particularly when working with arrays to help myself keep the indexes straight in my mind. abdulrahmanok and JockoDundee 2 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now