PDA

View Full Version : How do i get a list of hwds with Win_FindByTitle ?



holomind
19-04-2008, 03:57
Hi,

i need some help with the Win_FindByTitle function. Is there a way to get a list of all current open windows, instead of searching one by class or title.

http://www.thinbasic.com/public/products/thinBasic/help/html/index.html?win_findbytitle.htm


In AHK there is the Function i search, in Example2
http://www.autohotkey.com/docs/commands/WinGet.htm
  WinGet, id, list,,, Program Manager
  Loop, %id%

it would be great if i could simulate this function with thinBasic, even if it is done by DllCall , which can be mapped quite easily in thinBasic.

The Same Function can be done with DllCall + Callback, perhaps somebody can help me to translate this into thinBasic syntax.

--------- start ----------

; Example: The following is a working script that displays a summary of all top-level windows.

; For performance and memory conservation, call RegisterCallback() only once for a given callback:
if not EnumAddress ; Fast-mode is okay because it will be called only from this thread:
EnumAddress := RegisterCallback("EnumWindowsProc", "Fast")

DetectHiddenWindows On ; Due to fast-mode, this setting will go into effect for the callback too.

; Pass control to EnumWindows(), which calls the callback repeatedly:
DllCall("EnumWindows", UInt, EnumAddress, UInt, 0)
MsgBox %Output% ; Display the information accumulated by the callback.

EnumWindowsProc(hwnd, lParam)
{
global Output
WinGetTitle, title, ahk_id %hwnd%
WinGetClass, class, ahk_id %hwnd%
if title
Output .= "HWND: " . hwnd . "`tTitle: " . title . "`tClass: " . class . "`n"
return true ; Tell EnumWindows() to continue until all windows have been enumerated.
}

----------- end -----------

i managed the dllcall-alias syntax already, but the callback looks difficult ...

---------
Declare Function EnumWindows Lib "user32.dll" ALIAS "EnumWindows" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
-----------

its nice as its nearly the visualbasic syntax only enhanced with alias.





i want to port my ahk-script (real expose clone) to thinbasic, because there i can use opengl and other hdc/bitblt functions much easier.
http://www.autohotkey.com/forum/viewtopic.php?t=13001

i am wondering that nobody has used "printWindow" dllcall yet in thinBasic, as this is a very nice function to work with window-contents.

thanks for any links and tipps.
holomind

ErosOlmi
19-04-2008, 08:30
Ciao holomind and welcome here.

Sorry but callbacks are not handled in thinBasic. It is something we will work on in future versions.

Regarding Win_FindByTitle I can inplement it or create new functions that will let you return all the window handler and/or other info about window. Just give me a couple of days and I will do it.

Eros

holomind
19-04-2008, 10:45
Ciao holomind and welcome here.

Sorry but callbacks are not handled in thinBasic. It is something we will work on in future versions.

Regarding Win_FindByTitle I can inplement it or create new functions that will let you return all the window handler and/or other info about window. Just give me a couple of days and I will do it.

Eros



Hi Eros,

it would be great if you can implement just this feature, as the rest for porting my ahk-script should be already in thinbasic. time is no issue. it's great to hear my idea can actually work. i will do some experiments with "one window" in the meantime and implement other parts of the rewrite of my script.

Thanks,
Holomind

ErosOlmi
19-04-2008, 11:13
Be sure I will do by the week-end (sorry but today I'm out otherwise I would have done it today).

ErosOlmi
20-04-2008, 15:45
Holomind,

I think I've got something for you to test.
Please get attached file and:

put attached thinCore.dll into \thinBasic\ directory replacing your current one (be sure to have thinBasic 1.6.0.5 already installed
put attached thinBasic_UI.dll into \thinBasic\Lib\ directory replacing your current one
use Win_Get.tBasic to test and see if new Win_Get function works as expected


Let me know.
Eros

holomind
21-04-2008, 02:13
Thanks, Eros
i have tested it and it works like expected. This should be good enough, for finding all opened windows and then do my hdc / bitblit / printwindow calls.

with the help of psch, i will also be able to do it in opengl which will be a big performance improvement compared to bitblt. (expecially for animation effects).

The Function gives at least as much information as the AHK version of WinGet..., as it also detects minimized and even hidden windows.

Now i Only need to get PrintWindow working as a DllCall, but that should be easy with your WinCapture example in the other forum-thread.