pixelsearch Posted October 14, 2022 Share Posted October 14, 2022 (edited) Hi everybody Help file, topic _IsPressed Could we please change this description... A4 Left MENU key A5 Right MENU key ...to that one : A4 Left ALT key A5 Right ALT key Old msdn page indicated this "menu key" description but it has been changed to make it clearer, as you can notice in their actual Virtual-Key Codes web page : Constant Value Description VK_LMENU 0xA4 Left ALT key VK_RMENU 0xA5 Right ALT key Thanks Edited October 14, 2022 by pixelsearch plenty of empty lines at the end of the post ! Link to comment Share on other sites More sharing options...
argumentum Posted October 14, 2022 Share Posted October 14, 2022 (edited) #include <Misc.au3> Global $hDLL = DllOpen("user32.dll"), $sHexKey = "A5" While 1 If _IsPressed("1B", $hDLL) Then ConsoleWrite("_IsPressed - ""1B"" Key reserved for Exit. (" & @MIN & ':' & @SEC & '.' & @MSEC & ')' & @CRLF) ExitLoop ElseIf _IsPressed($sHexKey, $hDLL) Then ConsoleWrite("_IsPressed - """ & $sHexKey & """ Key was pressed. (" & @MIN & ':' & @SEC & '.' & @MSEC & ')' & @CRLF) While _IsPressed($sHexKey, $hDLL) Sleep(1) WEnd ConsoleWrite("_IsPressed - """ & $sHexKey & """ Key was released. (" & @MIN & ':' & @SEC & '.' & @MSEC & ')' & @CRLF) EndIf Sleep(1) WEnd ..tested. It is the ALT key. Guess "Gr" key in some keyboards but I've never seen any type of menu on that key. What would they ever referred to it as menu !?. Edited October 14, 2022 by argumentum better code Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
pixelsearch Posted October 14, 2022 Share Posted October 14, 2022 33 minutes ago, argumentum said: What would they ever referred to it as menu !?. I think it's because you press Alt before another key to access a menu item in plenty of Windows applications. argumentum 1 Link to comment Share on other sites More sharing options...
jpm Posted October 18, 2022 Share Posted October 18, 2022 I fix the doc and expand _IsPressed() to us directly $vk_* values as defined in WinAPIsvirkesConstants.au3 argumentum and pixelsearch 2 Link to comment Share on other sites More sharing options...
pixelsearch Posted October 26, 2022 Share Posted October 26, 2022 (edited) Hi everybody In AutoIt help file (3.3.16.1) we find the same example in 3 topics related to window subclassing. These 3 topics are : _WinAPI_SetWindowSubclass_WinAPI_DefSubclassProc_WinAPI_RemoveWindowSubclass (there is a 4th topic closely related, _WinAPI_GetWindowSubclass , but it doesn't show an example, no big deal) We can't run these examples "as-is" because of the 1st line in the script, which generates a fatal error : ==> Error opening the file.: #include <Extras\WMDebug.au3> To solve this, I created a subfolder named Extras (under \Include) and copied in it the file "WMDebug.au3" found at this location : ..... \Examples\Helpfile\Extras\WMDebug.au3 Maybe this little issue could be fixed in a future release ? Thanks in advance Edit: another solution is to modify the path of the include file in the script, without creating any subfolder on disk : ; #include <Extras\WMDebug.au3> #include <..\Examples\Helpfile\Extras\WMDebug.au3> Edited October 27, 2022 by pixelsearch Musashi and argumentum 1 1 Link to comment Share on other sites More sharing options...
jpm Posted October 27, 2022 Share Posted October 27, 2022 Just post your example for _WinAPI_GetWindowSubclass() I will add it to the doc To none example are referring to it Cheers Link to comment Share on other sites More sharing options...
pixelsearch Posted October 27, 2022 Share Posted October 27, 2022 Hi jpm Based on the script found in this link (which subclasses 2 controls), I modified it a bit and added a call to _WinAPI_GetWindowSubclass during the callback function (results in the console : 111 or 222) but it returns exactly the same value as $dwRefData (the 6th and last parameter of the callback function) which appears inside the 2 InputBox controls. So I'm not sure it's really useful in the following script : expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPIShellEx.au3> #include <WindowsConstants.au3> Global $g_pInputSubClassProc Local $gui010 = GUICreate('SubClass Two Input Controls', 400, 300) Local $inp010 = GUICtrlCreateInput('', 10, 20, 380, 20) Local $inp020 = GUICtrlCreateInput('', 10, 120, 380, 20) Local $hInputSubClassProc = DllCallbackRegister('_InputSubClassProc', 'LRESULT', 'HWND;UINT;WPARAM;LPARAM;UINT_PTR;DWORD_PTR') $g_pInputSubClassProc = DllCallbackGetPtr($hInputSubClassProc) If $g_pInputSubClassProc = 0 Then MsgBox(16, 'Subclass Test', 'Call to DllCallbackRegister failed.') Exit EndIf _WinAPI_SetWindowSubclass(GUICtrlGetHandle($inp010), $g_pInputSubClassProc, 1000, 111) If @error Then MsgBox(16, 'Subclass Test', 'Call to WinProc for inp010 failed.') Exit EndIf _WinAPI_SetWindowSubclass(GUICtrlGetHandle($inp020), $g_pInputSubClassProc, 2000, 222) If @error Then MsgBox(16, 'Subclass Test', 'Call to WinProc for inp020 failed.') Exit EndIf GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($inp010), $g_pInputSubClassProc, 1000) _WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($inp020), $g_pInputSubClassProc, 2000) DllCallbackFree($hInputSubClassProc) Func _InputSubClassProc($hWnd, $iMsg, $wParam, $lParam, $IdSubclass, $dwRefData) Switch $iMsg Case $WM_LBUTTONDBLCLK Switch $IdSubclass Case 1000 GUICtrlSetData($inp010, 'I was double clicked ' & $dwRefData) Case 2000 GUICtrlSetData($inp020, 'I was double clicked ' & $dwRefData) EndSwitch ConsoleWrite(_WinAPI_GetWindowSubclass($hWnd, $g_pInputSubClassProc, $IdSubclass) & @crlf) EndSwitch Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_InputSubClassProc msdn's webpage SetWindowSubclass function gives a bit more information about dwRefData : dwRefData Type: DWORD_PTR DWORD_PTR to reference data. The meaning of this value is determined by the calling application. This value is passed to the subclass procedure in the dwRefData parameter. A different dwRefData is associated with each combination of window handle, subclass procedure and uIdSubclass The GetWindowSubclass function simply retrieves this value : Retrieves the reference data for the specified window subclass callback. Let's hope a user finds a more useful example for this function, fingers crossed Link to comment Share on other sites More sharing options...
AutoXenon Posted October 27, 2022 Share Posted October 27, 2022 Can subclass callbacks have static variables and/or read/write global of the script itself? I have long been wondering how to decouple certain message processing from blocking the main processing loop of the script, previously I use a pseudo-async solution via a global buffer of dummy controls in onevent mode but that is still taking time away from the overall autoit execution, can callback code happen in a truly parallel manner managed by the OS, and if so would that change if it makes stateful references into the script variables? Link to comment Share on other sites More sharing options...
pixelsearch Posted October 27, 2022 Share Posted October 27, 2022 (edited) @jpm I'm modifying the precedent script to add a 3rd input control. When we enter a value (456) in this 3rd input control (which is the lowest one in the GUI) then it will update the 1st window subclass callback and display in AutoIt console : >>> outside subclass 456 Maybe this is the purpose of GetWindowSubclass : to retrieve, outside the callback function, an update made to a subclassed control, no matter this update was done in main or in a function. expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPIShellEx.au3> #include <WindowsConstants.au3> Global $g_pInputSubClassProc Local $gui010 = GUICreate('SubClass Two Input Controls', 400, 300) Local $inp010 = GUICtrlCreateInput('', 10, 20, 380, 20) Local $inp020 = GUICtrlCreateInput('', 10, 120, 380, 20) Local $inp030 = GUICtrlCreateInput('', 10, 220, 380, 20) Local $hInputSubClassProc = DllCallbackRegister('_InputSubClassProc', 'LRESULT', 'HWND;UINT;WPARAM;LPARAM;UINT_PTR;DWORD_PTR') $g_pInputSubClassProc = DllCallbackGetPtr($hInputSubClassProc) If $g_pInputSubClassProc = 0 Then MsgBox(16, 'Subclass Test', 'Call to DllCallbackRegister failed.') Exit EndIf _WinAPI_SetWindowSubclass(GUICtrlGetHandle($inp010), $g_pInputSubClassProc, 1000, 111) If @error Then MsgBox(16, 'Subclass Test', 'Call to WinProc for inp010 failed.') Exit EndIf _WinAPI_SetWindowSubclass(GUICtrlGetHandle($inp020), $g_pInputSubClassProc, 2000, 222) If @error Then MsgBox(16, 'Subclass Test', 'Call to WinProc for inp020 failed.') Exit EndIf GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $inp030 $iNewRefData = Number(GUICtrlRead($inp030)) _WinAPI_SetWindowSubclass(GUICtrlGetHandle($inp010), $g_pInputSubClassProc, 1000, $iNewRefData) ConsoleWrite(">>> outside subclass " & _WinAPI_GetWindowSubclass(GUICtrlGetHandle($inp010), $g_pInputSubClassProc, 1000) & @crlf) EndSwitch WEnd _WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($inp010), $g_pInputSubClassProc, 1000) _WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($inp020), $g_pInputSubClassProc, 2000) DllCallbackFree($hInputSubClassProc) Func _InputSubClassProc($hWnd, $iMsg, $wParam, $lParam, $IdSubclass, $dwRefData) Switch $iMsg Case $WM_LBUTTONDBLCLK Switch $IdSubclass Case 1000 GUICtrlSetData($inp010, 'I was double clicked ' & $dwRefData) Case 2000 GUICtrlSetData($inp020, 'I was double clicked ' & $dwRefData) EndSwitch ConsoleWrite(_WinAPI_GetWindowSubclass($hWnd, $g_pInputSubClassProc, $IdSubclass) & @crlf) EndSwitch Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_InputSubClassProc Edit: don't know if this could be useful, found in msdn's SUBCLASSPROC callback function : dwRefData Type: DWORD_PTR The reference data provided to the SetWindowSubclass function. This can be used to associate the subclass instance with a "this" pointer. <========= Edited October 27, 2022 by pixelsearch Link to comment Share on other sites More sharing options...
pixelsearch Posted October 29, 2022 Share Posted October 29, 2022 @jpm I just read the AutoIt credits webpage and your name is found in the "Inactive Authors" ! It's surely a mistake as you keep on scripting daily, so please anybody, just delete Jean-Paul's name from the "Inactive Authors" section, thank you... and we are not off topic as this concerns the helpfile I noticed you had to rework Yashied's useful functions (a few years ago) especially the variables names, for example the terrific & useful function "_WinAPI_DisplayStruct", changing Yashied's array : Global $__Var[9] = [0, 0, 0, 0, 16385, 8388608, 1, 0, 0] to Global $__g_hFRDlg = 0, $__g_hFRDll = 0 ; corresponds to $__Var[0] and $__Var[1] It was certainly a nightmare to rework things like that, so hats off JP ! Now 2 parts of the help file could be fixed, topic _WinAPI_DisplayStruct , this is what we can read now : $flags ... 1 - Prevent displaying "" and "" fields at the beginning and end of the list. 2 - Prevent displaying "" fields. 4 - Prevent displaying "" in "Member" column of the list if the structure element has no name. ... Yashied's original comments (tested in the script below) : $flags ... 1 - Prevent displaying "<struct>" and "<endstruct>" fields at the beginning and end of the list. 2 - Prevent displaying "<alignment>" fields. 4 - Prevent displaying "<unnamed>" in "Member" column of the list if the structure element has no name. ... Another possible minor change in the help file, DllStructCreate topic, where we read this : Type Details BYTE 8bit(1byte) unsigned char BOOLEAN 8bit(1byte) unsigned char Why not the clearer definition found in DllCall : unsigned integer, instead of the strange unsigned char, as a byte shows a number in the structure, not a character. Concerning the subclassing we discussed just above, you certainly noticed Yashied used it in "_WinAPI_DisplayStruct" with this interesting line : _WinAPI_SetWindowSubclass($__Var[0], $pDll, 1000, DllStructGetPtr($tParam)) So he used the 4th parameter we discussed above, inserting in it... a structure composed of the listview handle + an eventual dummy control ID, in case the user is allowed to double click on a listview row to copy the data in the clipboard (depending on $flags), that's ingenious and saves global variables. And of course he'll retrieve easily his structure in the 6th and last parameter of the callback function, $pData : Func __DlgSubclassProc($sHwnd, $iMsg, $wParam, $lParam, $idLV, $pData) So, as you asked for an example of GetWindowSubclass, I didn't find one in his code (though he scripted the function _WinAPI_GetWindowSubclass in his huge file WinAPIEx.au3 [1779 KB] and wrote in it : ; Example........: Yes But there is no example in his help file WinAPIEx.chm [1308 KB] Here is a script showing the $flags discussed above (lines to be uncommented) but I also find a small issue. _WinAPI_DisplayStruct won't display anything in this script as soon as a Chr(124) (separator character "|") is found in the structure. I'm not sure it's useful to rework the whole function as there are plenty of separators in it ! expandcollapse popup#include <WinAPIDiag.au3> Local $iStart = 32 ; space character ; Local $iEnd = 125 ; nothing is displayed as Chr(124) | is a separator in _WinAPI_DisplayStruct() => issue Local $iEnd = 255 ; ditto Local $tagStruct = "char[" & $iEnd - $iStart + 1 & "]" Local $tStruct = DllStructCreate($tagStruct) _DisplayStructure($tStruct, $tagStruct) ; before data setting For $i = $iStart To $iEnd DllStructSetData($tStruct, 1, Chr($i), $i - ($iStart - 1)) ; nothing is displayed because of Chr(124) | ; DllStructSetData($tStruct, 1, $i <> 124 ? Chr($i) : "?", $i - ($iStart - 1)) ; workaround to display Next _DisplayStructure($tStruct, $tagStruct) ; after data setting $tStruct = 0 ;================================================================== Func _DisplayStructure(Const ByRef $tStruct, Const ByRef $tagStruct) ; for fun : 3 different ways to display the structure using _WinAPI_DisplayStruct : ; _WinAPI_DisplayStruct($tStruct) ; 2nd optional parameter omitted => display as "byte[n]" structure _WinAPI_DisplayStruct($tStruct, $tagStruct) ; _WinAPI_DisplayStruct($tStruct, $tagStruct, "no rows <struct> and <endstruct>", 0, 0, 1) ; _WinAPI_DisplayStruct($tStruct, $tagStruct, "no rows <alignment>", 0, 0, 2) ; _WinAPI_DisplayStruct($tStruct, $tagStruct, "no words <unnamed>", 0, 0, 4) ; _WinAPI_DisplayStruct($tStruct, $tagStruct, "prevent copy to clipboard", 0, 0, 32) ; _WinAPI_DisplayStruct($tStruct, $tagStruct, "force expansion", 0, 0, 64) ; for "byte[n]" and "boolean[n]" type ; _WinAPI_DisplayStruct($tStruct, $tagStruct, "force hexadecimal (if possible)", 0, 0, 128) ; Local $pStruct = DllStructGetPtr($tStruct) ; _WinAPI_DisplayStruct($pStruct, $tagStruct) ; mandatory $tagStruct WHEN 1st param is a memory adress EndFunc Thanks for reading and have a great week-end everybody Musashi 1 Link to comment Share on other sites More sharing options...
mLipok Posted October 29, 2022 Share Posted October 29, 2022 (edited) 36 minutes ago, pixelsearch said: It's surely a mistake as you keep on scripting daily Last 2 years @jpm was the only one really active C++ developer for AutoIt core. Thanks to him we have all this new stuff and fixes in AutoIt core (which was released after 3.3.14.3). Of course @Jon was reviewer. So 36 minutes ago, pixelsearch said: Jpm I just read the AutoIt credits webpage and your name is found in the "Inactive Authors" ! IMO this is really things that should be changed. Edited October 29, 2022 by mLipok Musashi 1 Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
AutoXenon Posted October 30, 2022 Share Posted October 30, 2022 (edited) expandcollapse popup#include <WinAPIvkeysConstants.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #include <Misc.au3> Init() Do Until GUIGetMsg()=-3 Func Init() Global $hWndKeybd = GUICreate('') Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'UsagePage', 0x01) ; Generic Desktop Controls DllStructSetData($tRID, 'Usage', 0x06) ; Keyboard DllStructSetData($tRID, 'Flags', $RIDEV_INPUTSINK) DllStructSetData($tRID, 'hTarget', $hWndKeybd) _WinAPI_RegisterRawInputDevices($tRID) GUIRegisterMsg($WM_INPUT, WM_INPUT) GUISetState(@SW_SHOW) EndFunc Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Switch $hWnd Case $hWndKeybd Local $tRIK = DllStructCreate($tagRAWINPUTKEYBOARD) If _WinAPI_GetRawInputData($lParam, $tRIK, DllStructGetSize($tRIK), $RID_INPUT) Then KeystrokeLogic($tRIK) EndSwitch If $wParam Then Return 0 EndFunc Func KeystrokeLogic($tRIK) If $VK_SPACE = DllStructGetData($tRIK,'VKey') And BitAnd(1, DllStructGetData($tRIK,'Flags')) Then ; on spacebar release Local $tKeys = _WinAPI_GetKeyboardState() Local $chord = ( BitAnd(128,DllStructGetData($tkeys,1,1+$VK_Q)) ? 1 : 0 ) _ + ( BitAnd(128,DllStructGetData($tkeys,1,1+$VK_W)) ? 2 : 0 ) _ + ( BitAnd(128,DllStructGetData($tkeys,1,1+$VK_E)) ? 4 : 0 ) ; add one due to DllStructGetData being 1-based while the byte array is 0-based Switch $chord Case 1 Q() Case 2 W() Case 3 QW() Case 4 E() Case 5 EQ() Case 6 WE() Case 7 QWE() EndSwitch EndIf EndFunc Func Q() Beep(384,200) EndFunc Func W() Beep(432,200) EndFunc Func E() Beep(512,200) EndFunc Func QW() Beep(480,200) EndFunc Func WE() Beep(640,200) EndFunc Func EQ() Beep(576,200) EndFunc Func QWE() Beep(720,200) EndFunc _WinAPI_GetKeyboardState does not seem to have any example, I quickly whipped up this one demonstrating key chording actions for it. Hold a combination of Q+W+E and press spacebar to activate different actions (beeps on a diatonic scale, in this case) Edited October 30, 2022 by AutoXenon argumentum 1 Link to comment Share on other sites More sharing options...
pixelsearch Posted November 10, 2022 Share Posted November 10, 2022 (edited) Hi everybody AutoIt help file, function _WinAPI_PrintWindow, 3rd parameter : $bClient [optional] Specifies whether copies only the client area of the window, valid values: True - Only the client area of the window is copied to device context. False - The entire window is copied (Default). Which corresponds to what's written in msdn PrintWindow function : nFlags The drawing options. It can be one of the following values : Value Meaning PW_CLIENTONLY Only the client area of the window is copied to hdcBlt. By default, the entire window is copied. (thanks msdn for not indicating here the value of PW_CLIENTONLY) Yesterday I was intrigued when I discovered @Nine Screen scraping example, where he writes in his 1st post details that will concern exclusively the PrintWindow function : Version 2022-04-17 Added new optional parameter $iFlag to _GetScreen_GetWindow 0 = full window for Win 7 and over 1 = client area for Win 7 and over 2 = full window for Win 10 and over (this can be used with applications (like Chrome) that do not support WM_PRINT or WM_PRINTCLIENT messages) I wondered where he found these interesting values (especially the value 2 which isn't documented on msdn) Then I found this stackoverflow link where a question had been asked : "PrintWindow() could not print Google Chrome window" and a good answer was given by a guy named Geoff, who wrote : I was stuck for ages on this, then found that I can pass a parameter of PW_RENDERFULLCONTENT as the last parameter to PrintWindow. Googling that shows it's new in Windows 8.1 so presumably doesn't work on 7. It may be worth trying it though, Winuser.h defines it as : #if(_WIN32_WINNT >= 0x0603) #define PW_RENDERFULLCONTENT 0x00000002 #endif /* _WIN32_WINNT >= 0x0603 */ Then I opened Winuser.h and confirm these 3 lines are found there, preceded by another interesting line, which gives us also the value of PW_CLIENTONLY : #define PW_CLIENTONLY 0x00000001 @jpm I don't know what you'll do with all these informations because actually, the 3rd parameter of this function is False (default) and not numeric Thanks for reading and good luck Edited November 10, 2022 by pixelsearch typo Link to comment Share on other sites More sharing options...
pixelsearch Posted November 19, 2022 Share Posted November 19, 2022 (edited) Hello everybody AutoIt help file, topic _GUICtrlListView_SetBkImage Remarks : At this time this function only works with _GUICtrlListView_Create() or External ListViews. Could we please amend this sentence because it also works fine with a native AutoIt listview created with GUICtrlCreateListView . Anyone reading the actual help file may think the UDF creation function is absolutely required if a background image has to be added to the listview. Tested successfully with AutoIt 3.3.14.5 (2018) and 3.3.16.1 (2022) Edited November 19, 2022 by pixelsearch Link to comment Share on other sites More sharing options...
pixelsearch Posted December 19, 2022 Share Posted December 19, 2022 (edited) @jpm I got 2 scripts that could be interesting for the help file (at least the 1st script) : 1) _WinAPI_GetWindowInfo The example found in AutoIt help file could show more functionalities of the interesting function GetWindowInfo (especially $tagWINDOWINFO structure isn't found in the help file), for example : expandcollapse popup#include <WinAPISysWin.au3> Example() Func Example() ; Open Notepad Run("notepad.exe") WinWaitActive("[CLASS:Notepad]") Local $hWnd = WinGetHandle("[CLASS:Notepad]") If $hWnd = 0 Then Exit MsgBox(0, "NotePad", "Handle = 0") ; Move NotePad window to 10, 10 and resize it to 500, 400 WinMove($hWnd, "", 10, 10, 500, 400) ConsoleWrite("Window Title : " & WinGetTitle($hWnd) & @crlf) ; Get infos concerning NotePad Window Local $tWINDOWINFO = _WinAPI_GetWindowInfo($hWnd) ConsoleWrite("Window coords : Left & Top & Right & Bottom : " & _ $tWINDOWINFO.rWindow(1) & " / " & $tWINDOWINFO.rWindow(2) & " / " & _ $tWINDOWINFO.rWindow(3) & " / " & $tWINDOWINFO.rWindow(4) & @crlf) ConsoleWrite("Client coords : Left & Top & Right & Bottom : " & _ $tWINDOWINFO.rClient(1) & " / " & $tWINDOWINFO.rClient(2) & " / " & _ $tWINDOWINFO.rClient(3) & " / " & $tWINDOWINFO.rClient(4) & @crlf) ConsoleWrite("Border : Width & Height : " & _ $tWINDOWINFO.cxWindowBorders & " / " & $tWINDOWINFO.cyWindowBorders & @crlf) ConsoleWrite("Active ? " & ($tWINDOWINFO.WindowStatus = 1 ? "Yes" : "No") & @crlf) ConsoleWrite("Style : " & "0x" & Hex($tWINDOWINFO.Style, 8) & @crlf) ConsoleWrite("Extended Style : " & "0x" & Hex($tWINDOWINFO.ExStyle, 8) & @crlf) ConsoleWrite("Class Atom : " & $tWINDOWINFO.atomWindowType & @crlf) ConsoleWrite("Window creator version : " & "0x" & Hex($tWINDOWINFO.CreatorVersion, 4) & @crlf & @crlf) Local $tWinRECT = _WinAPI_GetWindowRect($hWnd) ConsoleWrite("Reminder : _WinAPI_GetWindowRect : Left & Top & Right & Bottom : " & _ $tWinRECT.left & " / " & $tWinRECT.top & " / " & _ $tWinRECT.right & " / " & $tWinRECT.bottom & @crlf) Local $tCliRECT = _WinAPI_GetClientRect($hWnd) ConsoleWrite("Reminder : _WinAPI_GetClientRect : Left & Top & Right & Bottom : " & _ $tCliRECT.left & " / " & $tCliRECT.top & " / " & _ $tCliRECT.right & " / " & $tCliRECT.bottom & @crlf) MsgBox(0,"Message","End script when you wish") ; Close Notepad window WinClose($hWnd) EndFunc ;==>Example 2) _WinAPI_GetTitleBarInfo If I'm not mistaken, this function doesn't exist in AutoIt. As I needed the GetTitleBarInfo function (which requires the TITLEBARINFO structure) then I scripted what follows : expandcollapse popup#include <WinAPISysWin.au3> Example() Func Example() Sleep(3000) ; give time for user to change the active window Local $hWnd = WinGetHandle("[ACTIVE]") Local $sTitle = WinGetTitle($hWnd) Local $sClassName = _WinAPI_GetClassName($hWnd) ConsoleWrite("Window Active Handle : " & $hWnd & @crlf) ConsoleWrite("Window Title : " & $sTitle & @crlf) ConsoleWrite("Class Name : " & $sClassName & @crlf) Local $tTITLEBARINFO = _WinAPI_GetTitleBarInfo($hWnd) ConsoleWrite("TitleBar Coords : Left & Top & Right & Bottom : " & _ $tTITLEBARINFO.TitleBar(1) & " / " & $tTITLEBARINFO.TitleBar(2) & " / " & _ $tTITLEBARINFO.TitleBar(3) & " / " & $tTITLEBARINFO.TitleBar(4) & @crlf) For $i = 1 To 6 ConsoleWrite("Element " & $i & " : 0x" & Hex($tTITLEBARINFO.State(($i)), 8) & @crlf) Next EndFunc ;==>Example ;================================== Func _WinAPI_GetTitleBarInfo($hWnd) Local Const $CCHILDREN_TITLEBAR = 5 Local Const $tagTITLEBARINFO = 'dword Size;long TitleBar[4];dword State[' & ($CCHILDREN_TITLEBAR + 1 ) & ']' Local $tTITLEBARINFO = DllStructCreate($tagTITLEBARINFO) DllStructSetData($tTITLEBARINFO, 'Size', DllStructGetSize($tTITLEBARINFO)) Local $aCall = DllCall('user32.dll', 'bool', 'GetTitleBarInfo', 'hwnd', $hWnd, 'struct*', $tTITLEBARINFO) If @error Or Not $aCall[0] Then Return SetError(@error + 10, @extended, 0) Return $tTITLEBARINFO EndFunc ;==>_WinAPI_GetTitleBarInfo Let's hope both scripts are correct. Thanks for reading Edited December 19, 2022 by pixelsearch typo Musashi 1 Link to comment Share on other sites More sharing options...
jpm Posted December 19, 2022 Share Posted December 19, 2022 Thanks Just curious in which context are you using _WinAPI_GetTitleBarInfo() for what? Cheers Link to comment Share on other sites More sharing options...
pixelsearch Posted December 19, 2022 Share Posted December 19, 2022 1 hour ago, jpm said: Just curious in which context are you using _WinAPI_GetTitleBarInfo() for what? I used it just after I read this recent thread a few days ago, where OP asked : On 12/16/2022 at 1:30 AM, D3fr0s7 said: I've been searching far and wide for a way to get the title bar size of any active window. The 1st answer OP got was : 12/16/2022 at 1:57 AM, Nine said: Maybe with _WinAPI_GetClientRect vs _WinAPI_GetWindowRect ? But when I tried _WinAPI_GetClientRect vs _WinAPI_GetWindowRect, then the height difference between these 2 functions didn't make it (at least for NotePad) as the Menu bar height was not included in the client area coords, also as shown on this MS pic : That's why I searched for a direct function that could be more reliable and return at once a correct title bar height, no matter the OS. As _WinAPI_GetWindowInfo didn't make it either, then I searched again and found _WinAPI_GetTitleBarInfo, which returned a correct title bar height, excluding an eventual Menu bar. Link to comment Share on other sites More sharing options...
D3fr0s7 Posted December 20, 2022 Share Posted December 20, 2022 (edited) 2 hours ago, pixelsearch said: I used it just after I read this recent thread a few days ago, where OP asked : The 1st answer OP got was : But when I tried _WinAPI_GetClientRect vs _WinAPI_GetWindowRect, then the height difference between these 2 functions didn't make it (at least for NotePad) as the Menu bar height was not included in the client area coords, also as shown on this MS pic : That's why I searched for a direct function that could be more reliable and return at once a correct title bar height, no matter the OS. As _WinAPI_GetWindowInfo didn't make it either, then I searched again and found _WinAPI_GetTitleBarInfo, which returned a correct title bar height, excluding an eventual Menu bar. Hi it’s me, from that thread you’re referencing. I was able to get the title bar size after all. I made a function that can return you title bar size, let me know if it works for you: Func _TitleBarSize( $hWnd) Static $iFrame = _WinAPI_GetSystemMetrics( 32) Static $iBorder = _WinAPI_GetSystemMetrics( 5) $tWinRect = _WinAPI_GetWindowRect( $hWnd) $tClientRect = _WinAPI_GetClientRect( $hWnd) $iWinHeight = DllStructGetData( $tWinRect, “Bottom”) - DllStructGetData( $tWinRect, “Top”) $iClientHeight = DllStructGetData( $tClientRect, “Bottom”) - DllStructGetData( $tClientRect, “Top”) $iTitleBarSize = $iWinHeight - $iClientHeight - $iFrame - $iBorder Return $iTitleBarSize EndFunc ;==>_TitleBarSize Feel free to modify the code in a way that’ll work for you, I typed it up from what I remember doing. Let me know if it helps too. Edited December 20, 2022 by D3fr0s7 My mistake, I thought this was a help thread Link to comment Share on other sites More sharing options...
D3fr0s7 Posted December 20, 2022 Share Posted December 20, 2022 I wasn’t too sure the format of this discussion thread I thought you needed the function I used haha. All I read was someone needing title bar size and I just wanted to drop the little function I created 🙂 Link to comment Share on other sites More sharing options...
pixelsearch Posted December 20, 2022 Share Posted December 20, 2022 8 hours ago, D3fr0s7 said: My mistake, I thought this was a help thread As it's not, I suggest we continue this discussion in your own thread. See you there 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