lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

User avatar
DocAElstein
5StarLounger
Posts: 708
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

Post by DocAElstein »

Hi
(This is a bit related, (loosely) to some other threads here: http://www.eileenslounge.com/viewtopic. ... 17#p321817
http://www.eileenslounge.com/viewtopic. ... 22#p321822 , and an old monster Thread of mine somewhere else
)


I am trying (struggling!) to revise and get a bit better clued up on the understanding of some API codings in VBA

As part of my experimenting, I am checking out how to find a window etc.

I came up with things like this, which is a bit enlightening as it locks a message box into a spreadsheet.

Code: Select all

Option Explicit
'    https://eileenslounge.com/viewtopic.php?p=321874#p321874
Private Declare Function APIssinUserDLL_MsgBox_NonModal Lib "user32" Alias "MessageBoxA" (Optional ByVal hWnd As Long, Optional ByVal Prompt As String, Optional ByVal Title As String, Optional ByVal buttons As Long) As Long '
Private Declare Function FindWndNumber Lib "user32" Alias "FindWindowA" (Optional ByVal lpClassName As String, Optional ByVal lpWindowName As String) As Long
Sub TestWndBreaks()          '    http://www.eileenslounge.com/viewtopic.php?f=18&t=28885#p223583
Dim Response As Long, WndNumber As Long

 Let WndNumber = FindWndNumber(lpClassName:="XLMAIN", lpWindowName:=vbNullString): Debug.Print WndNumber '
 Let Response = APIssinUserDLL_MsgBox_NonModal(hWnd:=WndNumber, Prompt:="Q_- Where am I, the MessageBoxA?" & vbCrLf & "I used  lpClassName:=""XLMAIN"", lpWindowName:=vbNullString  to get  hWnd  which was " & WndNumber & "", Title:="Experimanting with  lpClassName:=  ", buttons:=vbOKOnly) '
'Result: Run from Excel(from ExcelVBEditor or from Spreadsheet), or from Word(from WordVBEditor of from document)
'   WndNumber is  1115196  and the Message box pops up in the spreadsheet
End Sub
I have scoured the internet but only found a few other things to put in place of the "XLMAIN". (Those few things I found always return me a WndNumber of 0 , and I think the pop up then comes up on top of my screen, but don’t quote me on that, I am still experimenting )

Can anyone point me to a good list of those lpClassName things , and/or suggest some for me to try.

Thanks
Alan
Arnold: How did I get in here?
Taxi driver: The door opened, you got in.

User avatar
HansV
Administrator
Posts: 79697
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

Post by HansV »

See API: Get Class name of a running app.
Examples:
Microsoft Word = OpusApp
Microsoft Access = OMain
Mozilla Firefox - MozillaWindowClass
Best wishes,
Hans

User avatar
DocAElstein
5StarLounger
Posts: 708
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

Post by DocAElstein »

HansV wrote:
07 Nov 2024, 20:09
See .....
Thx Hans, I will check that out.

(I had just posted a follow up here, but I messed the format up, so deleted it …. I will try again later )

Edit: that works for me, chucks stuff in the Immediate Window nicely. :)

Code: Select all

Class = OfficeTooltip       Caption = Sub/UserForm ausführen (F5)
Class = Button              Caption = Start
Class = VBFloatingPalette   Caption = Direktbereich
Class = VBFloatingPalette   Caption = Überwachungsausdrücke
Class = wndclass_desked_gsk Caption = Microsoft Visual Basic - InputBoxMessageBoxPopUpBugsAPI.xls [Aktiv] - [GetClassNames (Code)]
Class = XLMAIN              Caption = Microsoft Excel non-commercial use - InputBoxMessageBoxPopUpBugsAPI.xls  [Compatibility Mode]
Class = MozillaWindowClass  Caption = API: Get Class name of a running app - Mozilla Firefox
Class = MozillaWindowClass  Caption = lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN".... - Eileen's Lounge - Mozilla Firefox
Class = OpusApp             Caption = InputBoxMessageBoxPopUpBugsAPIForumPosts.doc [Kompatibilitätsmodus] - Microsoft Word nichtkommerzielle Verwendung
Class = Chrome_WidgetWin_1  Caption = Google Übersetzer - Google Chrome
Class = Photo_Lightweight_Viewer          Caption = Higharachy from Office 2016.JPG - Windows Live Fotogalerie
Class = Microsoft-Windows-Tablet-SnipperToolbar         Caption = Snipping Tool
Class = #32770              Caption = DataCardMonitor
Class = CabinetWClass       Caption = Computer
Class = Progman             Caption = Program Manager
Arnold: How did I get in here?
Taxi driver: The door opened, you got in.

User avatar
DocAElstein
5StarLounger
Posts: 708
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

Post by DocAElstein »

…so , what I had tried to say before was … that … I had continued my research….
I often came/come across something called Microsoft Spy++ which gets info about windows. It’s only for things going on at the time, but it is a start at getting that Class name thing, since apparently it shows those, amongst other things. Unfortunately it is a tool in Visual Studio, and I don’t feel like overstretching my brains capture capacity and going off in yet another tangent to get into Visual Studio.
A few suggested sources of getting Microsoft Spy+ without Visual Studio did not work, :(
There are a few things claiming to be a third party equivalent. I have not found and tried them all out yet, but to be going on with this one seems a nice small portable one and is working well for me across a few computers and operating systems, :). (Some bigger things I tried needing instillations and sometimes caused some crashes or slowed my computer down, so for the time being I will forget those for a while.)

There seems to be rather a lot of Class Names found by these "Windows Spy++ things", but a nice characteristic of these tools, perhaps, is that you can drag something into a window , and it will then tell you stuff about that window , amongst other things that Class Name thing , and this little portable one is allowing me to highlight and copy the name .

Hmm…. I researched further

Observation 1
So I amused myself for a few hours with codings like this. For what purpose I don’t know, yet

Code: Select all

Option Explicit
'   https://eileenslounge.com/viewtopic.php?p=321874#p321874
Private Declare Function APIssinUserDLL_MsgBox_NonModal Lib "user32" Alias "MessageBoxA" (Optional ByVal hwnd As Long, Optional ByVal Prompt As String, Optional ByVal Title As String, Optional ByVal buttons As Long) As Long '
Private Declare Function FindWndNumber Lib "user32" Alias "FindWindowA" (Optional ByVal lpClassName As String, Optional ByVal lpWindowName As String) As Long
Sub TestWndBreaks()          '    http://www.eileenslounge.com/viewtopic.php?f=18&t=28885#p223583
Debug.Print Application.Name '   & "  " & Application.hwnd   '   Application.hwnd  only works in Excel 
Dim ClsNames() As Variant, NmeSteer As Variant
'                       Excel   ,   Word
 Let ClsNames() = Array("XLMAIN", "OpusApp")

Dim Response As Long, WndNumber As Long
    For Each NmeSteer In ClsNames()
     Let WndNumber = FindWndNumber(lpClassName:="" & NmeSteer & "", lpWindowName:=vbNullString): Debug.Print NmeSteer & "  " & WndNumber '
     Let Response = APIssinUserDLL_MsgBox_NonModal(hwnd:=WndNumber, Prompt:="Q_- Where am I, the MessageBoxA?" & vbCrLf & "I used" & vbCr & vbLf & "(lpClassName:=""" & NmeSteer & """, lpWindowName:=vbNullString)" & vbCr & vbLf & "to get" & vbCr & vbLf & "hWnd  which was " & WndNumber & "", Title:="Experimanting with  lpClassName:=  ", buttons:=vbOKOnly)   '
    Next NmeSteer
End Sub
I did notice something rather strange, strange that is, when bearing in mind two things:
_1 MessageBoxA is similar to the standard VBA MsgBox except that it is non model, which means that when its up you can still select things
_2 XLMAIN is something important to do with Excel, something to do with a main window. (OpusApp is something like the equivalent in Word)
Well, here is the strange thing: (assume you have Word and Excel open); ….
_ use the hwnd of XLMAIN, (like the coding does in the first loop), and then the MessageBoxA is up, but it loses its non modalability just in Excel.;
_ use the hwnd of OpusApp, (like the coding does in the second loop), and then the MessageBoxA is up, but it loses its non modalability just in Word.
You could sort of say like … tie it into the window you want to use it in and that will break it, or break its non modalabilityx at least.??
???? Maybe the standard VBA MsgBox as we know it, is the MessageBoxA "tied" into a spreadsheet, and so it losses its non modalability, (by design or accident)???
_._________________

Observation 2
A further observation…
_... this could be helpful to reference in the future from a few other places, so for better organising I will post that in the next post…
Last edited by DocAElstein on 08 Nov 2024, 11:00, edited 3 times in total.
Arnold: How did I get in here?
Taxi driver: The door opened, you got in.

User avatar
DocAElstein
5StarLounger
Posts: 708
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

Post by DocAElstein »

…. Continued from last post

Observation 2
A further observation…
This is possibly interesting and revealing, bearing in mind something we have seen in some other threads recently, ( https://eileenslounge.com/viewtopic.php ... 20#p321820
https://eileenslounge.com/viewtopic.php ... 72#p246872
) , … in those threads we have some API codings that worked OK up to Office 2016, but then didn’t for Office 2016 upwards. (or visa versa )
The problem appears to be related to finding a button to press in a window called something along the lines of the Offices Clipboard Viewer. In Excel, my "Spying" discussed above in the last post, suggests it must be in some under/child window with the name EXCEL2. ….
_a) Do a bit of research down the explorer window chains , and you see that for all Office versions there is similarity up to the first two (level/child/generation or whatever the term is), but then at the third, things start looking different for Office 2016
_b) Do that drag something into a window thing into the Offices Clipboard Viewer thing and we see similar things for up to Office 2016 and then different things for Office 2016


That inspired me to look again in a bit more detail, and at the same time I made a few minor modifications to these bits of a big API based OfficersClipboardViewer coding, , a big API coding we often discussed here at Eileen’s Lounge in some Threads, old and new .

Code: Select all

 Let hwndClip = FindWindowEx(Application.hWnd, 0, "EXCEL2", vbNullString)
Let hwndClip = FindWindowEx(hwndClip, 0, "MsoCommandBar", CommandBars(MyPain).NameLocal)
Let hwndClip = GetNextWindow(hwndClip, GW_CHILD)
Let hwndScrollBar = GetNextWindow(GetNextWindow(hwndClip, GW_CHILD), GW_CHILD)
    
    If hwndClip And hwndScrollBar Then
     GetWindowRect hwndClip, tRect1
     GetWindowRect hwndScrollBar, tRect2
     BringWindowToTop Application.hWnd
        For i = 0 To tRect1.Right - tRect1.Left Step 50
         tPt.x = tRect1.Left + i: tPt.Y = tRect1.Top - 10 + (tRect2.Top - tRect1.Top) / 2
…..
……
             Let lResult = AccessibleObjectFromPoint(………………     vKid    … )
……
……
…..
            If InStr("Clear All Borrar todo Effacer tout Alle löschen La légende du bouton", oIA.accName(vKid)) Then
            Call oIA.accDoDefaultAction(vKid) 
…..
……
……
            End If
         DoEvents
        Next i
    End If
The purpose of my modifications and research was to see if I could correlate things in that big coding, to some of the properties the spy was showing me

(The modifications are
_ 1) a small change to prevent the code erroring if it finds a button or something without any caption
_2) some Debug.Print lines

Here is the full modified snippet)

Maybe if anyone passing has any enlightening comments I will think again. Otherwise I think I will leave this thread now for a decade or two
_.__________________________________________-
Edit.....
DocAElstein wrote:
09 Nov 2024, 09:10
...... _1 One of my previous observations was slightly in error ., oops :blush: - The strange phenomena with the big coding doing different things in either a run or step debug mode was not just for Excel 2016, as I had previously concluded. I have now seen the behaviour now in Excels 2003 2010 and 2016. I have not experienced it yet in Excel 2007 or 2013, but I am not holding my breath. We seem to be navigating by points. Perhaps some factors may sometimes slightly influence a bit where things are. ( Or it’s a windows z order mess up :innocent: )
DocAElstein wrote:
11 Nov 2024, 22:39
Here, Post 177 the new results for Excel 2003 2007 2010 2013
The next post, post 178 has the new results for Excel 2016
They are based on the modified bit of the big coding shown on post 176
Basically at every of the 4 or 7 loops, ( 4 for 2003 2007 2019 2013 and 7 for 2016 ), I Debug.Print the found name with oIA.accName(vKid)
For all runs, and also for debug step mode in 2007 and 2013, all is well and I eventually get at Clear All ( or Alle löschen for my German Excels )
But in 2003 2010 and 2016 the step debugs mode fails as it gets weird names, mostly the Name of the code module ( OfficesClipboardViewerTests ) and sometimes the caption of the Immediate Window ( in German Direktbereich )
A strange oddity. But I will continue to monitor this. I have not tried every Single Version that I have on all of my computers
SpeakEasy wrote:
11 Nov 2024, 22:48
......that's because in step debug mode the IDE moves to the top of the z order ...




Alan
Arnold: How did I get in here?
Taxi driver: The door opened, you got in.

User avatar
DocAElstein
5StarLounger
Posts: 708
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

handles and (all) "windows"

Post by DocAElstein »

Hi
…… So I am trying again just now to write a (a)musing notes to get this API stuff straighter in my mind, or maybe write an extra supplement bit with emphasis on handles….
Some questions:
_1) At some point I was thinking a window might be a vague concept, and you(Mike) set me straight a lot on a few things like…
SpeakEasy wrote:
11 Nov 2024, 18:41
.... the Windows API provides us with tools (Win32 API functions such as FindWindow and FindWindowEx)) that let us walk that hierarchy, but they do NOT give us tools to jump direct to any window we want.
does this means … they do not give us tools to get directly at a windows handle? -
, and
_1b) can you (Mike or anyone) word this attempt a bit better for me…..If I have the handle I can refer to it directly, or get it, or get there directly – I am not quite sure how to word that best. Not being pedantic, I am just thinking if I say it right it might help the understanding of it a bit

_2) If I take that Dev Ashish coding Hans found for me , it normally gives me a dozen or so things what I might think is showing mostly the windows I thinks is going on, on my desktop … ( and the author say it is getting stuff of running apps, so I am perhaps not far off )
…. so far so good
Now, If I take out those two Ifs which filter by
__ If I have a caption
, and
__ If I have that visibility stuff

, then there is some reasonable correlation with the Microsoft Spy++ and the much bigger set of results from the Dev Ashish coding ( Main difference I can see is the Microsoft Spy++ gives me about 25% more stuff, ( about 360 / 290 ), and all the handles look unique in Spy++, whereas the Dev Ashish coding gives a few things as having the same handle?? )
Now, I did select Windows in the Spy++ options . So, the question: are these things approximately what are the windows as in the criteria…. a (classic win32) window from a programmers perspective:
( well maybe it is slightly less than all of them as I aint clicked on all the + es yet to see all the children or whatever further down the hierarchies )
_.______

Last question on anyone: Anyone know how to change a setting to get any Spy software to display handle numbers, or
maybe better still, a VBA coding to get the correct hexadecimal computer number thing from a normal number?, ( - after my recent experience with the inverted, 2’s compliment +1 –ve binary stuff, I am reluctant this time to try and do one myself…..)

Thanks
Alan
Last edited by DocAElstein on 22 Nov 2024, 08:25, edited 1 time in total.
Arnold: How did I get in here?
Taxi driver: The door opened, you got in.

JoeP
SilverLounger
Posts: 2155
Joined: 25 Jan 2010, 02:12

Re: lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

Post by JoeP »

See if something at vba convert decimal to hex helps.
Joe

User avatar
DocAElstein
5StarLounger
Posts: 708
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

Post by DocAElstein »

Thanks (The link is a Bing search on vba code to convert decimal to hex, yes?)

There seems actually to be a Decimal to Hex spreadsheet function, ( so I can use that in VBA Evaluate(" ") )
Initially this seems to give me the correct results. Perhaps if a handle is always positive'#* and not too big!!! then that should be OK.
I see also there is Decimal to Binary spreadsheet function. That does not appear to work on those big Style numbers that I had
I assume that handles are never as big as that, so maybe this solution will do for now. ( A coding that does it more fundamentally would be interesting to follow it through, but
Evaluate("=DEC2HEX( )")
may do for now )

'#* I will take a guess that handles are always positive, I have yet to see any negative, - (not that I would recognise a Hexogonalary or whatever negative number, but in many extended lists of all "windows", I generated in my modified versions of the Dev Ashish coding , the decimal long numbers have never been negative. That might mean we don’t call them "signed numbers" perhaps? - I think I read that "signed number" things are the ones in computing that get the binary’s compliment -1 treatment….

!!! the style numbers are "32-bit (long) value" –maybe that sounds like they would be long. There general build up, and the reasons for that give me the feeling they need to be, - because it’s useful to use each binary bit to tell you something if its 1. The handles on the other hand are sort of just address numbers so maybe you would not need to use all them 32 bit spaces, so maybe a more sane number of 1s and 0s is sufficient, and correspondingly the decimal equivalent would also not be too big, at least compared to the decimal style number? Maybe for a while I will check what any handles I play with have as a binary. Maybe I will see some pattern
Last edited by DocAElstein on 22 Nov 2024, 17:41, edited 2 times in total.
Arnold: How did I get in here?
Taxi driver: The door opened, you got in.

User avatar
SpeakEasy
5StarLounger
Posts: 667
Joined: 27 Jun 2021, 10:46

Re: lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

Post by SpeakEasy »

>There seems actually to be a Decimal to Hex spreadsheet function

VBA has its own Dec to Hex function called, funnily enough, Hex

Try debug.? Hex(-275091)

> I will take a guess that handles are always positive
You are right, in a sense, but not for the reason you think. The issue is that an hWnd is actually stored as a UINT, an unsigned integer - this is not a VB integer, but a 4-byte unsigned integer (for 32-bit systems, anyway). And thus is never actually negative as UINTs are never negative. The trouble is that VBA does not have an unsigned integer datatype. The closest it has to this system level datatype is a Long, but a Long is signed, so in VBA an hWnd can indeed appear to be negative simply because the underlying representation is interpreted differently

>Decimal to Binary spreadsheet function
Dec2Bin is of very limited use. it only works on numbers in the range -512 through 511

(oh, and whilst the whole If lngStyle And mcWSVISIBLE Then has been useful as the basis for a discussion of bit masking and the meaning of True and False in VBA, it is time to point out the reality is that it is much easier to call IsWindowVisible, than to retrieve the window style and checking the WS_VISIBLE bit.)

User avatar
DocAElstein
5StarLounger
Posts: 708
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

Post by DocAElstein »

I had missed the spreadsheet functions, (perhaps partly as I was not expecting the slang 2 in place of To in a standard function. I then probably assumed if there was no spreadsheet function for something like that then there would not be a VBA one since I think they usually mirror them).
The DEC2BIN does the Negative numbers in Two's-complement notation. The Microsoft documentation does say that although I expect as a layman I probably would have overlooked that and still ended up learning the Hard way, Lol.

For the numbers that I have been playing with it looks like VBA Hex and Excel DEC2HEX are giving the same numbers. Perhaps that is obvious to some, but after my experience with the binary I was not so sure, Lol. If I don’t find a function that does it more explicitly then I will probably do one for my sins sometime, as it helps to make it clear what is going on.

I tried the If IsWindowVisible(lngx) Then as an alternative to the If lngStyle And WS_VISIBLE Then in the coding and, yes, it seems to do the same job.
I expect I have learnt enough now to write a similar coding myself from scratch, and for a later experiment and practice, I will probably have a go at doing one to get all the extra few "down the tree" to get a hierarchical explorer type output. I might even do it sooner than later while it is all fresh in my head. I am not sure if that will be simple or complicated. Possibly there will be more than 1 sort of thing to consider in the next level down, and/ or some additional filtering will be needed?

Figuring out what the If lngStyle And WS_VISIBLE Then was about was indeed very enlightening and good for learning. I might keep that in. - Efficiency is for now less important to me compared to learning. I could also do the decimal conversion to binary on the style then check for the 1 in the (2^28) place, but I think working through the If lngStyle And WS_VISIBLE Then is really a good un for sparking up a good learning discussion

Interesting info about the Long being used in VBA as it does not have or use a more extended type. As a wild Laymen guess, I am wondering if the artefact of all other than 0 being True is coming from when somewhere in the computer innards/ Entrails a Boolean somewhere gets held as a Long. I remember someone else smart telling me that in VBA it does not help with efficiency / storage minimising to use an Integer variable rather than a Long variable in VBA, since somewhere along the way an Integer gets held as a Long anyway
Arnold: How did I get in here?
Taxi driver: The door opened, you got in.

User avatar
SpeakEasy
5StarLounger
Posts: 667
Joined: 27 Jun 2021, 10:46

Re: lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

Post by SpeakEasy »

>somewhere along the way an Integer gets held as a Long anyway

On occassion it will be stored in 4 bytes or loaded into a register as 4 bytes,, yes. This does not make it a Long though...

User avatar
SpeakEasy
5StarLounger
Posts: 667
Joined: 27 Jun 2021, 10:46

Re: lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

Post by SpeakEasy »

>write a similar coding myself from scratch
I shall await with bated breath. It';s a great opportunity to involve recursion ...

User avatar
DocAElstein
5StarLounger
Posts: 708
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

Post by DocAElstein »

I'm OK with recursion, I did it a few times, mostly the classic Folders and files, and it crossed my mind as a possibility for this one, but I was thinking/ hoping there would not typically be too many levels, so, initially at least, I might do it without recursion. At least until I know what is going on it might be a bit easier to debug.
(Since sussing recursion out, I have thought it’s made a bit more difficult to understand by the typical explanation of saying it’s a function that Calls itself, and then not saying much more. Technically that may be correct. But that tends to leave the thing hanging in a newbies mind as a bit of a mystery, unnecessarily IMHO, and in my own experience.
I would explain it like ….. The (any) function you see is just the text from which some computer innards makes the thing that runs. When that thing runs, if it hits a part that Calls the same named function, then that first thing running pauses/ waits, while another identical one is made and run.
If you run the thing in Debug mode, it might look like the thing jumps back to the start when it hits the call line, but that is just the developer environment’s way, *the only way it has, of showing you starting a new separate copy – *in an ideal world it would paste a copy and go stepping through that….

I think I might have got the point a lot quicker if someone had said that to me

Anyway…. > I shall await with bated breath - Don’t hold your breath though…
….
SpeakEasy wrote:
13 Nov 2024, 16:02
..If you have not already found it, then the website that originates from
… I am spending some time at that allapi mentalis place, I really wish I had found this back when I first tangled with API stuff. – There are Lists, examples, explanations galore.
I probably would put that place at a level of beginner upwards, - that site has obviously been used by professionals for reference, but its readable for someone with reasonable VBA knowledge if they have at least made some start with, and used successfully, a few basic API codings.
It seems that the site was too much work for the volunteers running it and so since about 20 years nothing has been done there. Never the less IMO it definitely should be on the list of places to go and know about if you have any interest in VBA API. Hopefully it will continue to be kept up at least. Their donation button doesn’t work anymore, but there are a few small too obtrusive advertising windows so hopefully that covers their costs.
It is very strange that me and others I know have had difficulty finding these sort of useful VB sites on a search. I wonder if there is some bug or quirk in the search algorithms. Perhaps VBA and VB is initially got and then in the sorting the lack of third characters results in some asymptotic lower level placement that finally leads to some truncation/ resolution limit, resulting in an untypical absolute zero which chucks a False somewhere and the thing vanishes from the list and nobody at Google & co. noticed yet that phenomena/ artefact.
( BTW I read there also that some Boolean constants get held as l.ong somewhere along the way, and I wonder if that somehow contributes to the artefact that sometimes things other than zero is seen as True )

If I understand correctly we can consider VB VBA language to some extent as just using/ controlling API functions, so it is a reasonable proposition to use them directly to do some things as we may find they do something else useful.
But I have read and am fairly sure I have experienced in the last couple of weeks some strange unhealthy things having occurred. I expect a major part of the VB VBA interface is some sort of protection/ error handling to minimise the worse happening. I have broken two computers in the course of recent API experiments. One I could repair with a classic restore to an earlier time point – that continues to work very well on older systems. The other may need something more drastic. Luckily it is dual boot, the operating system I did not use is perfect, the other does crazy things to the display on trying to boot
I would not recommend anyone getting heavily into API research and experimenting unless you have some computers to spare. I have a feeling also that the spy software can cause some strange problems as well. Messing heavily with many windows is perhaps unhealthy generally, and I suppose normal average software is limited to less windows.
Having said that I am cautiously encouraged that some of this VB stuff/ documentation is useful for the home user with an inclination to using older Microsoft stuff. Things like this sometimes make me think I did not miss so much as I had expected in windows development over the last 20 years, at least not in the areas of MS Office that I am interested in, as an end user, - I don’t mean to offend anyone involved in development of back end things that I know nothing about.
Arnold: How did I get in here?
Taxi driver: The door opened, you got in.

User avatar
SpeakEasy
5StarLounger
Posts: 667
Joined: 27 Jun 2021, 10:46

Re: lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

Post by SpeakEasy »

> BTW I read there also that some Boolean constants get held as l.ong somewhere along the way

I already explained to you that boolean True is stored internally in VB(A) as &hFFFFFFFF (and boolean False is stored as &h00000000). That is to say they are both stored in 4 bytes - the same number of bytes as a long

>I wonder if that somehow contributes to the artefact that sometimes things other than zero is seen as True
I have also explained that in VB(A) anything not False is True. It isn't an artifact, and it isn't 'sometimes'

>I have broken two computers in the course of recent API experiments
I'v e been using the API from VB for just over 30 years. And the worst issue i have had are blue screen crashes , and whilst there might have been a subsequent loss of data - specifically the program i was working on - I have never suffered any additional damage to the system, far less having broken a PC, so I am not sure what you have been doing ...

> hoping there would not typically be too many levels
Depends what you mean by 'too many', I guess. A quick check on my PC with a quick walker I put together indicates a fair number of windows having a hierachy of 7 levels

>Recursion ... another identical one is made and run.
No. Same bit of code, just with a new stack frame. The code for the function/procedure resides in memory once, regardless of how many times it is called. Each recursive call does not duplicate the function's code.

>It seems that the site was too much work for the volunteers running it
Yep, pretty much. The original site was allapi.net As they (KPDteam) themselves said "The site became too big for us to handle in our spare time. Practically every free minute we had went to the site, and this became unbearable. We had to make some decisions and one of them was to stop working on AllAPI.net.". But they kept hosting it for a few years .. and then came the time when they admitted it was going to go offline. Fortunately mentalis.org stepped in to take over hosting duties

> expect a major part of the VB VBA interface is some sort of protection/ error handling to minimise the worse
yes, there are all sorts of safety rails hidden within VB(A) to protect the programmer from themselves, and dealing with such chores as memory management (that other languages expect the programmer to do). Once you step outside those safety rails - particularly if you don't realise what you are doing - then all bets relating to system stability are off.

>I have a feeling also that the spy software can cause some strange problems as well
It is possible for Spy++ to cause problems, thanks to the way it works - but that is predominantly the message monitoring part. I am unaware of walking the windows hierarchy causing problems

User avatar
DocAElstein
5StarLounger
Posts: 708
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: lpClassName:="????" Windows Class Names, (List of?) like in FindWndNumber(lpClassName:="XLMAIN"....

Post by DocAElstein »

The thing with the 4 bytes and stuff is a bit above me for now, but its not wasted on me, I often, most always, come back later, sometimes years later, when people have told me these things, and then it helps the penny to finally drop
_.____________
… Same bit of code, just with a new stack frame …. Sounds a bit like a way to effectively be running like a new/ separate copy…. I think I may understand what you are saying, - its like saying, run the thing on a shelf, pause the thing if/ when it "calls itself" , hold any variables values on that shelf, run the thing then again on another shelf, a new set of the same variable go on that shelf, and so on. I still find the copy explanation one that is easy to understand and fits how things work. I need to think of a similar one to match the shelf idea. Stack frame and a shelf perhaps have the potential to be similar things by a different word
_.________________
I read the same bit from KPDteam you quoted, I also noticed a lot of things have a latest date in the range 2002-2008 ( they have a new win32 thing from 2008 but it seems the same size exactly as the original. I think perhaps not many new API functions have been added in the last 20 years , - but that is a bit of a guess, you’ll perhaps set me straight on that one if I am wrong )
I guess mentalis is just somewhere that keeps the place up on the internet. I probably missed the point that allapi.net was the original name, obvious now with hindsight thinking about it. No matter, better late than never, I just took a look for allapi.net on web archive org Wayback machine and it looks like they have everything from it very well archived so that is another possibility to get t it all
_.________________________
It could have been a coincidence with one or both computers that broke in the last couple of weeks, they are both older Acer Aspire laptops, Vista originally, one still is – the one that the restore to earlier time point seemed to fix. The other one, still broke, had been updated to windows 7 when I got it. A few years ago, for the practice, I (re)installed Vista on it on a partition and that is till OK. I was not using that, I was using the Windows 7 on it when it went wonky. Could also be something else. (I was messing with those "office clipboard" clearing big and small codings when it broke. Shame because it had a few Office versions on that one. Not a major problem, I just have to get up off my lazy bottom and walk around a bit more now to other computers to test things on a few different office versions.
Anyway it’s good to have some confirmation about the risks when doing API stuff. As a subject I might introduce API in VBA at an intermediate level, saying that its working a bit more fundamentally, which goes against my preference of tackling useful important fundamentals early, but I would justify that saying that one reason for things like VB / VBA existing is to protect us from ourselves
_.___
I only quickly read that article about Spy++ innards and entrails. They mention hooks and things. I remember when I was first messing with that API message box thing I did, I sometimes got scary very light grey apparitions permanently where my Pop up had been. I am not sure if it was related to a strange recursion/ or maybe multiple calling of the call back routine that I noticed. I don’t think it is supposed to run more than once. I introduced a global variable, that keeps track of the copy number shelf number of the recursion, and then stops the routine from being done more than once. Everything worked then, so my guesss is/was that the recursion was undesirable/ not necerssary . I never noticed yet anyone else do something like that to stop their call back routine being done more than once. Possibly some never noticed, - sometimes a call back routine could be set off a few times and it would not affect the final result, at least not always noticably.

I definitely experienced hanging sometimes when using the Spys

Also the VB Editor chucks a spanner in the works sometimes with the Spy things. I saw that myself and then when I searched I found that others have reported it as well
Arnold: How did I get in here?
Taxi driver: The door opened, you got in.