ilqar200 Posted March 15, 2023 Share Posted March 15, 2023 Hello. I am programming some automation on Metatrader 4 (trading software in financial markets).I have attached screenshot to explain. I need to determine the pixel color of one of items(the item with Balance text , see screenshot) in virtual listview control for the reason to not click on that item using ControlClick function. In automation i need to click on above and below items of that item with Balance text. I am able to click on items with ControlClick function. But i dont need to click item with Balance text. I need to skip this item while clicking on items.To be able to skip clicking on item with Balance text i want to use PixelGetColor function to get color of gray area of that item and skip clicking on it. AutoIt window info tool shows me the color of gray area of that item is 0xC8C8C8.In screenshot AutoIt window info tool is set to Coord Mode to window.I used this code to able to determine pixel color of gray area of item with Balance text AutoItSetOption("PixelCoordMode",0) ConsoleWrite(PixelGetColor(809,864,0x000420B4)) But this code showed me in console output 16777215 which is wrong color. 809 and 864 is x and y coordinates of mouse pointer while mouse on the grey area of needed item with Balance text and 0x000420B4 is virtual listview control handle . These parameters is from AutoIt window info tool.I have tested above code with PixelCoordMode setting to 1 and 2 too. But all unsuccessfully. I was not able to identify item with Balance text using PixelGetColor function. So how to identify correctly item with Balance text ? Thanks for answers. Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted March 15, 2023 Share Posted March 15, 2023 (edited) Hi @ilqar200, just as a quick guess: You're using a static value as handle parameter of PixelGetColor() which might be wrong. Please have a look into the help file and try the function without the third parameter or by getting the handle at runtime (no static value because the handle value might change). Update: Please also notice, if you want to get the hex color, you have to use the Hex() function, like in the example of the help file described: Quote MsgBox($MB_SYSTEMMODAL, "", "The hex color is: " & Hex($iColor, 6)) Best regards Sven Edited March 15, 2023 by SOLVE-SMART Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
ilqar200 Posted March 15, 2023 Author Share Posted March 15, 2023 10 minutes ago, SOLVE-SMART said: Hi @ilqar200, just as a quick guess: You're using a static value as handle parameter of PixelGetColor() which might be wrong. Please have a look into the help file and try the function without the third parameter or by getting the handle at runtime (no static value because the handle value might change). Best regards Sven Not solution. I have used function while application is running . The handle not changes while application is running because it is already loaded with the main window of application and for this reason i used static handle. As for sure for you i have checked with autoit window info tool. It is not changed while application running. Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted March 15, 2023 Share Posted March 15, 2023 (edited) Second try: Please see the "Update:" in my first post. Maybe this will help you if you want to get the hex color (0xC8C8C8 / #C8C8C8). Best regards Sven Edited March 15, 2023 by SOLVE-SMART Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
ilqar200 Posted March 15, 2023 Author Share Posted March 15, 2023 1 minute ago, SOLVE-SMART said: Second try: Please see the "Update:" in my first post. Maybe this will help you if you want to get the hex color (0xC8C8C8 / #C8C8C8). Best regards Sven I know about Hex() function. I checked it's output .It shows me 16777215 which is in hex 0xFFFFFF so not correct color. Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted March 15, 2023 Share Posted March 15, 2023 (edited) Third try: Please check your display scaling (desktop resolution). In case you have 125% or 150%, the "PixelCoordMode" might work incorrectly. Set this value to 100%, adjust the coords by Au3Info tool and try again please. Best regards Sven Edited March 15, 2023 by SOLVE-SMART Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
ilqar200 Posted March 15, 2023 Author Share Posted March 15, 2023 3 minutes ago, SOLVE-SMART said: Third try: Please check your display scaling (desktop resolution). In case you have 125% or 150%, the "PixelCoordMode" might work incorrectly. Set this value to 100% and try again please. Best regards Sven Again not think is solution. Because i have 100% display scaling in display settings. Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted March 15, 2023 Share Posted March 15, 2023 Then please see more information here (it is or was a bug). Also here (and the conversation above). Try to test with MouseMove() to see if the coords are correct (please notice you have to set Opt('MouseCoordMode', 0)). Best of luck and best regards Sven Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
ilqar200 Posted March 15, 2023 Author Share Posted March 15, 2023 (edited) 18 minutes ago, SOLVE-SMART said: Then please see more information here (it is or was a bug). Also here (and the conversation above). Try to test with MouseMove() to see if the coords are correct (please notice you have to set Opt('MouseCoordMode', 0)). Best of luck and best regards Sven I am on Win7 and display resolution is 1280X1024 with album orientation and with display scaling 100% which is default on Win7. I do not think scaling is the problem for getting right color. Why test with MouseMove() ? I want to click on needed items and skip unnecessary item without mouse. So i need to use ControlClick . I am able to click on items in virtuallistview control using ControlClick but i cannot skip clicking on unnecessary item. Edited March 15, 2023 by ilqar200 Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted March 15, 2023 Share Posted March 15, 2023 If you're not fine with my answers, fine, but please do more research on your own. I was trying to help you and give you possible necessary hints and links, but my patience is at an end. Bye 😒 . Best regards Sven Musashi 1 Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
Nine Posted March 16, 2023 Share Posted March 16, 2023 (edited) To be honest the 2 lines of code you gave us does not convince me that you are doing the right thing or that you have an issue. Personally, I am using very often PixelGetColor on both Win7 and Win10 without any problem. So my guess is that you are not using correctly. Unless, you can provide a runable example that is not working we will suppose that the problem is on your side. Edited March 16, 2023 by Nine SOLVE-SMART and Musashi 1 1 “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...
ilqar200 Posted March 16, 2023 Author Share Posted March 16, 2023 10 hours ago, Nine said: To be honest the 2 lines of code you gave us does not convince me that you are doing the right thing or that you have an issue. Personally, I am using very often PixelGetColor on both Win7 and Win10 without any problem. So my guess is that you are not using correctly. Unless, you can provide a runable example that is not working we will suppose that the problem is on your side. OK. Let me explain detailly. I have attached 3 files to this message. 1 video and 2 screenshots. As i said I am programming some automation in Metatrader 4 software (mostly-known trading software in financial markets). In automation i need to click on items in Virtual ListView control of this software.I am able to click on items with the help of ControlClick function. After clicking on items there is another window appear and i continute automation on that window. But there is one item on control that needs to be skipped from clicking because it is not clickable and no window appears after clicking on that .It is just information item on control. I need to determine visually this item to skip clicking on it. For this reason i want to use PixelGetColor function. So below code is part of my automation that clicks on items : #include <WinAPI.au3> #include <Array.au3> Sleep(5000) Local $hWnd,$aArray,$pPid,$iIndex,$iItemsCount $pPid=WinGetProcess("6272") $iItemsCount=ControlListView("6272","",33217,"GetItemCount") For $i=1 To $iItemsCount ControlClick("6272","",33217,"left",2,780,30+($i-1)*20) While 1 $aArray=_WinAPI_EnumProcessWindows($pPid,True) $iIndex=_ArraySearch($aArray,"#32770",0,0,0,0,1,1) If $iIndex>0 Then $hWnd = $aArray[$iIndex][0] If IsHWnd($hWnd) = 1 And WinExists($hWnd)=1 Then ExitLoop EndIf EndIf WEnd WinWait($hWnd) $aArray=_WinAPI_EnumChildWindows($hWnd,True) ControlClick($aArray[17][0],"",1370,"left",2,Null,Null) ControlSend($aArray[17][0],"",1370,"58555") ControlCommand($aArray[17][0],$aArray[37][0],1198,"SendCommandID","1198") WinWaitClose($hWnd) Next In video i demonstrate running above code. It successfully clicks on items and do automation - setting take profit on orders(items on virtual list view control). But when clicks arrive to unnecessary item that needs to be skipped it do nothing because i cannot realize skipping that item .For this reason i cannot click below this item or I cannot stop clicking when no items below. This item with text "Баланс" on it. So to identify visually unneeded item i want to use PixelGetColor function. I want use this function to identify grey area of unnecessary item. Here is summary of AutoIt window info tool while my mouse is over on grey area of unnecessary item.(see screenshot 1) expandcollapse popup>>>> Window <<<< Title: 62728000: RoboForex-DemoPro - Демо Счет - RoboForex Ltd - [BTCUSD,H1] Class: MetaQuotes::MetaTrader::4.00 Position: -8, -8 Size: 1296, 956 Style: 0x15CF8000 ExStyle: 0x00000100 Handle: 0x0003059E >>>> Control <<<< Class: SysListView32 Instance: 1 ClassnameNN: SysListView321 Name: Advanced (Class): [CLASS:SysListView32; INSTANCE:1] ID: 33217 Text: Position: 16, 556 Size: 1260, 293 ControlClick Coords: 780, 110 Style: 0x50001405 ExStyle: 0x00000000 Handle: 0x0003055E >>>> Mouse <<<< Position: 804, 716 Cursor ID: 0 Color: 0xC8C8C8 >>>> StatusBar <<<< 1: Для вызова справки нажмите F1 2: Default 3: 4: 5: 6: 7: 8: 9: 996/8 kb >>>> ToolsBar <<<< >>>> Visible Text <<<< Для вызова справки нажмите F1 Стандартная Период графика Графические инструменты Графики Стандартная Терминал Терминал Обзор рынка: 11:40:20 Навигатор Обзор рынка: 12:45:49 BTCUSD,H1 GBPUSD,H1 GBPJPY,H1 XAGUSD,H1 .JP225Cash,H1 AUDUSD,H1 USDCAD,H1 .USTECHCash,H1 .US30Cash,H1 .US500Cash,H1 USDJPY,H1 EURUSD,H1 >>>> Hidden Text <<<< Тестер Советник Moving Average.ex4 Свойства эксперта Символ: Период: H1 Свойства символа Модель: Все тики (наиболее точный метод на основе всех наименьших доступных таймфреймов для генерации каждого тика) Спред: Текущий Открыть график Изменить эксперта Использовать дату От: 1970.01.01 Оптимизация до: 1970.01.01 Визуализация | | Пропустить до 2023.03.16 Старт Окно Данных 0.0000 In this case AutoIt window tool is set CoordMode to Window option. This tool showed me that the color of gray area of unneeded item is 0xC8C8C8. It showed me also ControlClick coordinates is 780 and 110 and Mouse coordinates was 804 and 716. So i run below code to identify unneeded item AutoItSetOption("PixelCoordMode",0) ConsoleWrite(Hex(PixelGetColor(780,110,0x0003055E))&@CRLF) AutoItSetOption("PixelCoordMode",1) ConsoleWrite(Hex(PixelGetColor(780,110,0x0003055E))&@CRLF) AutoItSetOption("PixelCoordMode",2) ConsoleWrite(Hex(PixelGetColor(780,110,0x0003055E))&@CRLF) AutoItSetOption("PixelCoordMode",0) ConsoleWrite(Hex(PixelGetColor(804,716,0x0003055E))&@CRLF) AutoItSetOption("PixelCoordMode",1) ConsoleWrite(Hex(PixelGetColor(804,716,0x0003055E))&@CRLF) AutoItSetOption("PixelCoordMode",2) ConsoleWrite(Hex(PixelGetColor(804,716,0x0003055E))&@CRLF) AutoItSetOption("PixelCoordMode",0) ConsoleWrite(Hex(PixelGetColor(804,716,0x0003059E))&@CRLF) AutoItSetOption("PixelCoordMode",1) ConsoleWrite(Hex(PixelGetColor(804,716,0x0003059E))&@CRLF) AutoItSetOption("PixelCoordMode",2) ConsoleWrite(Hex(PixelGetColor(804,716,0x0003059E))&@CRLF) This code outputted me only : 00FFFFFF (see screenshot 2 ) I run above code while running Metatrader 4. In above code i tried with static handle of virtual listview control(0x0003055E) because it not changes while running Metatrader 4.I also tried with handle of main window (0x0003059E) and mouse coodinates too . I also tried with different PixelCoordMode values. But on all cases i have got only 00FFFFFF. So my question How to correctly identify grey area of unnecessary item in this case ? video.avi Link to comment Share on other sites More sharing options...
ilqar200 Posted March 16, 2023 Author Share Posted March 16, 2023 I forgot to mentioned that In automation i need to work with non-active state of Metatrader 4 so code with PixelGetColor i tried with non-active window of Metatrader 4 . Link to comment Share on other sites More sharing options...
ilqar200 Posted March 16, 2023 Author Share Posted March 16, 2023 Excuse me but seems i have found answer of my question why i cannot get correct color. I tried now with active window of Metatrader 4 below code : Sleep(5500) AutoItSetOption("PixelCoordMode",0) ConsoleWrite(Hex(PixelGetColor(780,110,0x0003055E))&@CRLF) This code showed me correct color of grey area while i set manually active Metatrader 4 window. So i have found my mistake. But from this situation i have there is another question is arise for me . How to identify correctly color of grey area of unnecessay item in virtual list view control where main window Metatrader 4 is not active ? I need automation to work with only non-active window of Metatrader 4 Is there anyway ? Using PixelGetColor or another method ? Link to comment Share on other sites More sharing options...
Nine Posted March 16, 2023 Share Posted March 16, 2023 It is a SysListView, so many ListView functions should work. (see ControlListView and GuiListView UDF) SOLVE-SMART 1 “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...
ilqar200 Posted March 16, 2023 Author Share Posted March 16, 2023 (edited) 55 minutes ago, Nine said: It is a SysListView, so many ListView functions should work. (see ControlListView and GuiListView UDF) It is Syslistview with LVS_OWNERDATA LVS_OWNERDRAWFIXED styles so it's virtual listview. ControlListView text related functions and GuiListView UDF not working on this control. Edited March 16, 2023 by ilqar200 Link to comment Share on other sites More sharing options...
Nine Posted March 16, 2023 Share Posted March 16, 2023 Are you absolutely sure about that last statement ? Because I just tested it with my own virtual list view with both LVS_OWNERDATA and LVS_OWNERDRAWFIXED styles : ControlListView($hWnd, "", $hCtrl, "GetItemCount") and ControlListView($hWnd, "", $hCtrl, "GetText", 1, 0) returns right values... “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...
ilqar200 Posted March 16, 2023 Author Share Posted March 16, 2023 (edited) 2 hours ago, Nine said: Are you absolutely sure about that last statement ? Because I just tested it with my own virtual list view with both LVS_OWNERDATA and LVS_OWNERDRAWFIXED styles : ControlListView($hWnd, "", $hCtrl, "GetItemCount") and ControlListView($hWnd, "", $hCtrl, "GetText", 1, 0) returns right values... yes. i am absolutely sure. I have attached screenshot to this message. Please see it. As you can see Text was not extracted from the virtual list view. there is only items count was outputed to console.In this case is 5 is total items count which is right. So in your case maybe controllistview function can get text from AutoIt created control so it can extract text or maybe different reason - dont know exactly. . But in my case from Metatrader 4 soft it cannot extract text. Edited March 16, 2023 by ilqar200 Link to comment Share on other sites More sharing options...
Nine Posted March 16, 2023 Share Posted March 16, 2023 (edited) try x64 and/or #requireAdmin one thing is sure, your assumption that the 2 styles combined disables the action of controlListView is wrong. Edited March 16, 2023 by Nine “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...
ilqar200 Posted March 17, 2023 Author Share Posted March 17, 2023 11 hours ago, Nine said: try x64 and/or #requireAdmin one thing is sure, your assumption that the 2 styles combined disables the action of controlListView is wrong. I dont think x64 and/or #requireAdmin will help because i am running under administrator account which is only user in my pc - that is me and i have disabled Windows User Account Control (UAC) . In this situation i think #requireAdmin will have no effect. Besides Metatrader 4 soft is x86 type soft so x64 too will have no effect. I didnot say Controllistview actions disabled . I did say Controllistview text related functions not working with Metatrader 4 soft's virtual listview control. For example Controllistview function's Select and Unselect command successfully selects and unselects items in control . But FindItem command not working because it is text related. I have tried these commands.Text is situated in Metatrader's memory area not in control itself. In this situation different approach must be used.One approach is to directly access process's memory. But it is hard for me. I am newbie in programming. All i need at this time to successfully identify visually or programmatically item in virtual listview control with "Баланс" text.After successfull identification of needed item my automation process will good to continue.How I can successfully identify visually or programmatically item with "Баланс" text ? 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