Danilo gave me this snippet as a starting point:
I've added this code below the "pid_num" section to retrieve the windows titles:Danilo wrote:Here is the start to enum the windows and get the PID:grabiller wrote:I found this:
https://github.com/nint22/WindowSnaps/b ... Delegate.mIt is pretty straightforward to translate the code, so I hope you can do the rest yourself. I'm having a beer or two now (after returning from nightshift work),Code: Select all
ImportC "" CGWindowListCreate(_1, _2) CGWindowListCreateDescriptionFromArray(arr) CFArrayGetCount(arr) CFArrayGetValueAtIndex(arr, index) CFRelease(arr) CFDictionaryGetValue(_1,_2) CFStringCreateWithCharacters(alloc,text.p-Unicode,len) CFNumberGetValue(_1,_2,_3) EndImport ;CFArrayRef WindowList = CGWindowListCreate(1, 0) Debug WindowList DescriptionList = CGWindowListCreateDescriptionFromArray(WindowList) Debug DescriptionList Debug "--------------" If DescriptionList count = CFArrayGetCount(DescriptionList) If count For i = 0 To count-1 id = CFArrayGetValueAtIndex(DescriptionList,i) Debug "ID: "+id pid_num = CFDictionaryGetValue(id, CFStringCreateWithCharacters(0,"kCGWindowOwnerPID",17)) If pid_num CFNumberGetValue(pid_num,9,@pid.l) Debug "PID: "+pid EndIf Next EndIf EndIf CFRelease(DescriptionList) CFRelease(WindowList)
not in the mood for doing all the work for you. It is boring because PB does not import any of this API functions, but it should be doable.
Press ALT+CMD+ESC to terminate the running processes, if it does not exit correctly (possibly some clean-up missing).
Code: Select all
nameRef = CFDictionaryGetValue(id, CFStringCreateWithCharacters(0,"kCGWindowName",13))
If nameRef
namePtr = CFStringGetCStringPtr( nameRef, #kCFStringEncodingUTF8 )
If namePtr
name$ = PeekS( namePtr, -1, #PB_UTF8 )
Debug "-> NAME: "+name$
EndIf
EndIf
From the Apple SDK:
Obviously the Lightwave windows show titles nonetheless, so I guess there must be another way to retrieve it somehow.kCGWindowName
The key that identifies the name of the window, as configured in Quartz. The value for this key is a CFStringRef type. (Note that few applications set the Quartz window name.)
Any idea ? Another API I should use ?

