April 29, 2024, 05:00:06 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


List of open windows

Started by Andy, January 25, 2014, 04:18:47 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Hi,

Is there a way to list all the currently open windows.

Explanation:
When I open Firefox twice, it only shows one Process ID for firefox, is there any way anyone knows of detecting something like Firefox being opened twice or more?

Can you list / count the number of open windows in the taskbar for example?

I can stop a process, but this would kill off both instances of Firefox, and I only want to stop the second
instance of Firefox.

???

Thanks,
Andy.



Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

Have noticed in Task Manager:

Under the "Applications" tab it does show firefox twice or more.

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

So has anyone any ideas how to list the open applications and not the processes?


Thanks,
Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

This will give you the exact same list that you get in the Task window of Task Manager
Hope this will help get you started in the right direction.
I did notice that if you have multiple IE windows open it will only list the one that is currently selected(visible).

openconsole
$include "windowssdk.inc"

DEF hdesk,hnext,style:INT
DEF text:STRING
hdesk = GetDesktopWindow()

hnext = GetWindow(hdesk,GW_CHILD)
if hnext
GetWindowTextA(hnext,text,255)
style = GetWindowLongA(hnext,GWL_STYLE)
if IsWindowVisible(hnext) & ((style  & @CAPTION) > 0) & (len(text) > 0)
?text
endif
DO
hnext = GetWindow(hnext,GW_HWNDNEXT )
if hnext
GetWindowTextA(hnext,text,255)
style = GetWindowLongA(hnext,GWL_STYLE)
if IsWindowVisible(hnext) & ((style & @CAPTION) > 0) & (len(text) > 0)
?text
endif
endif
UNTIL hnext = 0
endif

waitcon
closeconsole


changing to this in both places
if IsWindowVisible(hnext) & ((style & @CAPTION) > 0) & (len(text) > 0)
?text
elseif instr(lcase$(text),"internet explorer")
?text
endif

will pick up the other open explorer windows but I'm getting dupicates.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Hi Larry,

Thats a great starting point.

With this list of applications, how can I use the "Destroywindow" function to kill off one of the applications in the list?

Thanks,
Andy.

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

Hi,

Got it!

I used SendMessage & WM_CLOSE to kill off all instances of Firefox.

See attached code.

once again, thanks Larry.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

QuoteI can stop a process, but this would kill off both instances of Firefox, and I only want to stop the second
instance of Firefox.

Your modified code looks to me like you will delete all instances of firefox unless the first child is firefox

What am I missing?
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Hi Larry,

Yes that was my initial task to kill off all instances as posted, but now with your code i'm able to check each instance of firefox and only kill off the firefox window(s) I don't want such as ads and pop ups when I visit certain sites.

Thus I can now detect multiple firefox windows and select which ones I want the program to close for me.

I added a timer in there with a 1 second deley, which then loops back and re-detects instances of firefox, if it's one I don't want, it kills it off keeping my browser clear of junk.

Hope that's a bit clearer,
once again, many thanks.

When I get time I think i'll write an alternative task manager and post the code here for all.

Andy.
:)




Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.