Mbee Posted March 21, 2019 Share Posted March 21, 2019 (edited) I've searched for explanations of various error returns as a result of calling _WinAPI_EnumProcessWindows() with a valid PID, but I haven't been able to find the relevant info on MSDN or elsewhere. I get an @error = 11. When I call _WinAPI_GetLastErrorMessage() when I get that value, it returns: "The parameter is incorrect." But the parameter (the only one) is just an ordinary binary PID, which is definitely valid. So I can't help wondering if 11 actually means something else, since that error code doesn't make any sense in this situation. I'd appreciate your help in figuring what's up with this. Thanks! Edited March 21, 2019 by Mbee Link to comment Share on other sites More sharing options...
BrewManNH Posted March 21, 2019 Share Posted March 21, 2019 38 minutes ago, Mbee said: ordinary binary PID What do you mean by a binary PID, PIDs are numeric? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Mbee Posted March 21, 2019 Author Share Posted March 21, 2019 4 minutes ago, BrewManNH said: What do you mean by a binary PID, PIDs are numeric? I always assumed so, but the examples just pass 0 so I guess I'm not sure, Let me check at MSDN... Link to comment Share on other sites More sharing options...
Mbee Posted March 21, 2019 Author Share Posted March 21, 2019 (edited) "Each process running in Microsoft Windows is assigned a unique decimal number called the process ID, or PID. This number is used to specify the process when attaching a debugger to it" Forget the debug ref Edited March 21, 2019 by Mbee Link to comment Share on other sites More sharing options...
BrewManNH Posted March 21, 2019 Share Posted March 21, 2019 Post your script, we can't help without more information, and you script will provide that. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Mbee Posted March 21, 2019 Author Share Posted March 21, 2019 4 hours ago, BrewManNH said: Post your script, we can't help without more information, and you script will provide that. Will do, thanks. It's too long to post it all, but I'll post enough surrounding code to see what I'm doing. Please wait a bit... Link to comment Share on other sites More sharing options...
water Posted March 21, 2019 Share Posted March 21, 2019 System error codes are described here. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Mbee Posted March 21, 2019 Author Share Posted March 21, 2019 Some news: In preparing the requested code for posting, I discovered that a likely reason I was getting 11/"The parameter is incorrect" from _WinAPI_EnumProcessWindows() was that the process associated with the definitely correct PID simply has no windows at all, which is the case (i.e., one of the children has no windows). While designing my algorithms, my expectation was that if that was the case, I'd simply get a zero value as the array element count. But instead, it appears that I get the @error = 11 result instead. I'll pause now and read what @water has just posted.. Link to comment Share on other sites More sharing options...
Mbee Posted March 21, 2019 Author Share Posted March 21, 2019 4 minutes ago, water said: System error codes are described here. Thanks, but "ERROR_BAD_FORMAT" is at least as confusing in this situation! Link to comment Share on other sites More sharing options...
Mbee Posted March 21, 2019 Author Share Posted March 21, 2019 (edited) To continue from post # 8, my current hunch is that one simply should not call _WinAPI_EnumProcessWindows() is the PID doesn't have any windows. So then the question becomes, how can I test to see how many windows a given process (by PID) has without calling _WinAPI_EnumProcessWindows() ? One thing I can do is to check if the process represented by the PID has a particular class associated with it: "shadow-layered-window". I could call WinGetClassList(), but since that window has no title or handle or pre-known class (as required as input for that function) -and- it is not necessarily the active window, what on earth can I specify as that parameter? Is there some other technique I can use to determine if the process in question has no windows, please? Thanks! PS: I think I just found a way to do what I need that should work: _WinAPI_GetProcessCommandLine().. I'll post back one way or the other... Edited March 21, 2019 by Mbee Added comment Link to comment Share on other sites More sharing options...
Mbee Posted March 22, 2019 Author Share Posted March 22, 2019 (edited) Well, it turned out that I just pushed the problem elsewhere. I get an @error = 40 (dec) return when I try to obtain the command line, which I thought would solve the problem above. It's too long to post inline, so I've attached my current, preliminary code to this post, if anyone would like to take a look. NOTE that I'm still trying to discover how to manipulate the highly non-standard GUI of Comodo Free Firewall v11, so there are far fewer comments than will be in the finished product. Even if I'm the only one who will ever use it, I always take the time to comment my code well enough for an old man like myself to modify someday... Since my script won't work without the firewall installed (sorry), and they don't offer an offline installer for just the free firewall, you'll have to run the web installer from the following download page (not a direct download): Comodo Free Firewall 2019 Press the Green button on the left. The location of the core error is surrounded by a comment block with a lot of exclamation points in the code. The second file is imported by the first. Thanks! !!! MyComodoPurge_v0.3.au3 _ModStatusMessages2.au3 Edited March 22, 2019 by Mbee Link to comment Share on other sites More sharing options...
Nine Posted March 22, 2019 Share Posted March 22, 2019 12 hours ago, Mbee said: Is there some other technique I can use to determine if the process in question has no windows, please? One way to face your problem is to think the opposite direction. Instead of trying to find the windows of a pid, you could try to find the pid of the windows. To do that : Use WinList to get all windows Use WinGetProcess for each handle you have to get the pids Compare the pids with the one you are looking for. water and Mbee 2 “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...
Deye Posted March 22, 2019 Share Posted March 22, 2019 (edited) Simply put.. #include <WinAPIEx.au3> MsgBox(0, "Windowed ?", _isWindowed("SciTE.exe")) Func _isWindowed($sTitle) Local $iPid = ProcessExists($sTitle) If Not $iPid Then Return False Local $bRet = Not _WinAPI_EnumProcessWindows($iPid) Return ($bRet ? $bRet : False) EndFunc Deye Edited March 22, 2019 by Deye if not pid condition added mLipok 1 Link to comment Share on other sites More sharing options...
Mbee Posted March 22, 2019 Author Share Posted March 22, 2019 (edited) 2 hours ago, Nine said: One way to face your problem is to think the opposite direction. Instead of trying to find the windows of a pid, you could try to find the pid of the windows. To do that : Use WinList to get all windows Use WinGetProcess for each handle you have to get the pids Compare the pids with the one you are looking for. Thanks again, oh wise and kind guide! It turns out that since I followed your advice and started using WinList(), I no longer actually need the PIDs at all. What I was after in the first place was to determine if a window of a specific size or size & position existed somewhere on the screen (I couldn't rely on titles or classes, since they weren't always present). For that I needed a win handle, and I was trying to get that using the PID via _WinAPI_EnumProcessWindows() or whatever. But since WinList also gives you window handles, I can now directly obtain each window's size and position without all the complex WinAPI calls! Once again, I am especially grateful for your knowledge and patience! PS: The Comodo Firewall system is part of a larger set of applications known as Comodo Internet Security, or CIS. So the only downside of no longer using _WinAPI_EnumProcessWindows and the like is that now I no longer have any use for variable names such as: $Lf_ThisCisKidPid Edited March 22, 2019 by Mbee Link to comment Share on other sites More sharing options...
Nine Posted March 22, 2019 Share Posted March 22, 2019 “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...
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