1. What Programs are running?

How can I get a list of the programs that are currently running?
Like when I press ctl+alt+del?
In a euphoria sequence of course.

Don Cole
SF

new topic     » topic index » view message » categorize

2. Re: What Programs are running?

don cole wrote:
> 
> 
> How can I get a list of the programs that are currently running?
> Like when I press ctl+alt+del?
> In a euphoria sequence of course.
> 
> Don Cole
> SF
> 

The closest you will find is this:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=Monitor+All+Windows

It's Monitor all Windows, by Greg Haberek.  It includes a demo, to show you
how it works.  If I remember right though, this will only detect Windows,
not Proccesses.  However, I could be wrong.  But it will give you a place
to start at for doing a Task Manager like system in Euphoria.

Mario Steele
http://enchantedblade.trilake.net
Attaining World Dominiation, one byte at a time...

new topic     » goto parent     » topic index » view message » categorize

3. Re: What Programs are running?

> don cole wrote:
> > 
> > 
> > How can I get a list of the programs that are currently running?
> > Like when I press ctl+alt+del?
> > In a euphoria sequence of course.


there is a task manager improvement in MSDN samples if i remember.  i dont
remember how its called, just search "task manager" on msdn site. if you cant
find it i can look it up.

new topic     » goto parent     » topic index » view message » categorize

4. Re: What Programs are running?

don cole wrote:
> 
> 
> How can I get a list of the programs that are currently running?
> Like when I press ctl+alt+del?
> In a euphoria sequence of course.
> 
> Don Cole
> SF
> 

Don:
   You can use this:

BOOL EnumWindows(
  WNDENUMPROC lpEnumFunc,  // pointer to callback function
  LPARAM lParam            // application-defined value
);
 
The EnumWindows function does not enumerate child windows. 

You use this for child windows:

BOOL EnumChildWindows(
  HWND hWndParent,         // handle to parent window
  WNDENUMPROC lpEnumFunc,  // pointer to callback function
  LPARAM lParam            // application-defined value
);
 
You will have to write a callback to process the list.


Bernie

My files in archive:
w32engin.ew mixedlib.e eu_engin.e win32eru.ew

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

5. Re: What Programs are running?

Bernie Ryan wrote:

> Don:
>    You can use this:
> 
> BOOL EnumWindows(
>   WNDENUMPROC lpEnumFunc,  // pointer to callback function
>   LPARAM lParam            // application-defined value
> );
>  
> The EnumWindows function does not enumerate child windows. 
> 
> You use this for child windows:
> 
> BOOL EnumChildWindows(
>   HWND hWndParent,         // handle to parent window
>   WNDENUMPROC lpEnumFunc,  // pointer to callback function
>   LPARAM lParam            // application-defined value
> );
>  

Actually, that's the method that Greg Haberek does it.  And thank you for
reminding me, that I was right, the include file that Greg uses, only
enumerates the Windows, and Child Windows running on your Windows desktop.

This will not work for all processes, as not all processes create a window
to run.  The only time a Program or Process will create a window, is if they
want to use some Win32 API that requires a Window Handle to dispatch, or they
wish to make use of the Windows Timing System or Window Message System.

Otherwise, a program does not have to create a window, in order to run in
Windows.  EG:
atom a
a = 0
while a < #FFFFFFFF do
   a += 1
end while


That will run on Windows, and will never create a Window.

Mario Steele
http://enchantedblade.trilake.net
Attaining World Dominiation, one byte at a time...

new topic     » goto parent     » topic index » view message » categorize

6. Re: What Programs are running?

Hi Mario,

You could use the TASKLIST command line utility that comes with windows and
redirect the output to a file

system("tasklist.exe > process.txt",0)

then read the process.txt file

I don't which version of windows is required for takslist!

regards,
Jacques Deschênes

new topic     » goto parent     » topic index » view message » categorize

7. Re: What Programs are running?

jacques desch=EAnes wrote:

> Hi Mario,
>
> You could use the TASKLIST command line utility that comes with windows a=
nd
> redirect the output to a file
>
> system("tasklist.exe > process.txt",0)
>
> then read the process.txt file
>
> I don't which version of windows is required for takslist!

Interesting!
Unfortunately, tasklist.exe isn't contained in Windows 98.

Regards,
   Juergen

new topic     » goto parent     » topic index » view message » categorize

8. Re: What Programs are running?

don cole wrote:
> 
> 
> How can I get a list of the programs that are currently running?
> Like when I press ctl+alt+del?
> In a euphoria sequence of course.
> 
> Don Cole
> SF
> 

winclassdll.e will give a list of handles 

include winclassdll.e
atom a 
sequence s
s = listWindows()
a = open("handles.txt","w")
for i= 1 to length(s) do
printf(a,"%d -- ",s[i])
puts(a, getCaption(s[i])&"\n")
end for 
close(a)


some of the output I get;

184 -- RPCSSWindow
712 -- OLEChannelWnd
532 -- MM USB Keyboard Driver
296 -- One-touch Multimedia Keyboard
536 -- Microsoft PC State Manager
604 -- OleMainThreadWndName
608 -- DDE Server Window
724 -- MS_WebcheckMonitor
748 -- Power Meter
840 -- USBMMKBD
948 -- OleMainThreadWndName
952 -- AnalogX PortBlocker Log...
972 -- PortBlocker
976 -- OleMainThreadWndName
804 -- FastCache
988 -- Proxy
992 -- Connection Manager
1108 -- Adaptec DirectCD Wizard
1532 -- WIN95 RPC Wmsg Window
2604 -- DDHelpWndClass
564 -- WIN95 RPC Wmsg Window
1796 -- ÿ
1548 -- WIADCWND
1540 -- STI Monitor
1536 -- STI Monitor
1520 -- OLEChannelWnd


--"ask about our layaway plan".
--

new topic     » goto parent     » topic index » view message » categorize

9. Re: What Programs are running?

Michael Raley wrote:
> 
> don cole wrote:
> > 
> > 
> > How can I get a list of the programs that are currently running?
> > Like when I press ctl+alt+del?
> > In a euphoria sequence of course.
> > 
> > Don Cole
> > SF
> > 
> 
> winclassdll.e will give a list of handles 
> 
> }}}
<eucode>
> include winclassdll.e
> atom a 
> sequence s
> s = listWindows()
> a = open("handles.txt","w")
> for i= 1 to length(s) do
> printf(a,"%d -- ",s[i])
> puts(a, getCaption(s[i])&"\n")
> end for 
> close(a)
> </eucode>
{{{

> 
> some of the output I get;
> 
> 184 -- RPCSSWindow
> 712 -- OLEChannelWnd
> 532 -- MM USB Keyboard Driver
> 296 -- One-touch Multimedia Keyboard
> 536 -- Microsoft PC State Manager
> 604 -- OleMainThreadWndName
> 608 -- DDE Server Window
> 724 -- MS_WebcheckMonitor
> 748 -- Power Meter
> 840 -- USBMMKBD
> 948 -- OleMainThreadWndName
> 952 -- AnalogX PortBlocker Log...
> 972 -- PortBlocker
> 976 -- OleMainThreadWndName
> 804 -- FastCache
> 988 -- Proxy
> 992 -- Connection Manager
> 1108 -- Adaptec DirectCD Wizard
> 1532 -- WIN95 RPC Wmsg Window
> 2604 -- DDHelpWndClass
> 564 -- WIN95 RPC Wmsg Window
> 1796 -- ÿ
> 1548 -- WIADCWND
> 1540 -- STI Monitor
> 1536 -- STI Monitor
> 1520 -- OLEChannelWnd
> 
> 
> --"ask about our layaway plan".
> --
> 
I have two programs accessing the same database.
'find.exe' and 'add.exe'.
 if 'find.exe' is still running
when using 'add.exe' then all the info added is lost when I close 'find.exe'.
I solved the problem with:

</eucode>
{{{

 include window.ew

global function is_file_open(sequence file)
 sequence windows,class,captions
 object caption
   captions={}
    windows = window_ListAll()
    for i = 1 to length(windows) do
      class = GetClassName( windows[i] )
      caption = window_GetCaption( windows[i] )
      if length(class) then
          captions=append(captions,caption)
      end if
   end for
    if find(file,captions) then
      return 1
    else
      return 0
    end if
end function

procedure check(integer self, integer event, sequence params)
   object ok
   if is_file_open("Find") then
         ok = message_box(   "Close Find and Restart", 
                     "Find.Exe Open",
         MB_ICONHAND+ MB_TASKMODAL )
       closeWindow(Window1)
   end if
end procedure
setHandler(Window1,w32HActivate,routine_id("check"))

</eucode>
{{{


Don Cole
SF

new topic     » goto parent     » topic index » view message » categorize

10. Re: What Programs are running?

Why not do this instead? It completely eliminates the internal find() loop.

global function is_file_open(sequence file)

  sequence windows, class
  object caption

  windows = window_ListAll()

  for i = 1 to length(windows) do
    caption = window_GetCaption( windows[i] )
    if equal( file, caption ) then
      -- file is open
      return 1
    end if
  end for

  -- not found
  return 0
end function


~Greg

new topic     » goto parent     » topic index » view message » categorize

11. Re: What Programs are running?

Greg Haberek wrote:
> 
> Why not do this instead? It completely eliminates the internal find() loop.
> 
> }}}
<eucode>
> global function is_file_open(sequence file)
> 
>   sequence windows, class
>   object caption
> 
>   windows = window_ListAll()
> 
>   for i = 1 to length(windows) do
>     caption = window_GetCaption( windows[i] )
>     if equal( file, caption ) then
>       -- file is open
>       return 1
>     end if
>   end for
> 
>   -- not found
>   return 0
> end function
> </eucode>
{{{

> 
> ~Greg
> > 
> 


I thought of tyhat but I thought using the if question on every count
would slow things down.
I the 'found' program was the first one on the list then it would be
much faster your way.
But if it was the last prougram on the list I don't know.
I see you eliminated tyhe class

new topic     » goto parent     » topic index » view message » categorize

12. Re: What Programs are running?

I hit some key and he message got sent before I was done.

I meant:

I thought of that, but I thought using the if question on every count
would slow things down.
If the 'found' program was the first one on the list then it would be
much faster your way.
But if it was the last prougram on the list then I don't know.
I see you eliminated the class question which should speed things up.

Don Cole
sf

new topic     » goto parent     » topic index » view message » categorize

13. Re: What Programs are running?

On Tue, 05 Apr 2005 02:08:35 -0700, don cole <guest at RapidEuphoria.com>
wrote:

>I thought of that, but I thought using the if question on every count
>would slow things down.
Testing every iteration is going to be way faster than building a
table and running a find on it at the end...

If you are worried about speed, I have a "single instance checker" in
Edita (Arwen-based) which I have just ported to win32lib. Let me know
if you want it.

Pete

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu