Need Help with a bit of desktopX programming - URGENT

SO , i need an image that changes if a process is running or not

basicly...

 if process.exe is running then i want the image to be tick.png  , and if process.exe is not running then i want the image to be cross.png

 

i'm building an antivirus with the interface in desktop x and i need to say if the sheilds are running , they are processes on the system ,

 

any help would be appriciated

59,491 views 12 replies
Reply #1 Top

RomanDA did something that monitored any process herre: http://romanda.wincustomize.com/skins.aspx?skinid=1&libid=77

Check out his tutorials, I'll bet he documented how he did it somewhere.  Check out his tutorials and if I see him I'll give him a poke.

Reply #2 Top

WMI is what is used to check on the memory usage or anything else about a running process.

procs = name of process to check for

Code: vbscript
  1. Function GetMemSize(Procs)
  2.     strComputer = "."
  3.     Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
  4.     sql = "SELECT * FROM Win32_Process where Caption Like '%" & Procs & "%'"
  5.     Set colItems = objWMIService.ExecQuery(sql,,48)
  6.     Found = False
  7.     For Each objItem In colItems
  8.         MemUsage = objItem.WorkingSetSize
  9.         ProcPID = objItem.ProcessId
  10.         Diff = MemUsage - MemUsageOld
  11.         Found = True
  12.     Next
  13.     MemUsageOld = MemUsage
  14.   If Found = True Then
  15.      'Do something here if you want, or not, mine makes a popup window show up
  16.     Else
  17.      ' show that the process is not running, gray out the box, whatever.
  18.   End If
  19.    
  20. End Function

good luck

Reply #3 Top

Thanks David!

Reply #4 Top

ok ... sounds good  , thanks all , but is there a way to make it show different pictures if it is running or not?

to be honest , i'm not a programmer , i understand the code a bit but i wouldn't know how to make it display different pictures

i'm sorry for my ignorence

 

   ~jman6495

Reply #5 Top

You wnat to fill in the IF/ELSE/ENDIF section at the end with what you want to do.

A little research is prudent now.  Check out https://www.stardock.com/products/desktopx/help/dev_guide_3b_script_reference.htm

object.picture bight be your friend. 

(but then again . . I'm a DX hack :) )

 

Reply #6 Top

Cool code. :star:

Reply #7 Top

Would I need to set proc equal to the process I want or would I just enumerate it in the code?

Reply #8 Top

Jsut add

Code: vbscript
  1. ' add this to the timer, or loop your using to check to see if the process is running
  2. Call GetMemSize("Firefox")
  3.  
  4. ' Then in the function (if you want to swap STATES - much better idea than pictures)
  5. Function GetMemSize(Procs)
  6.     Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
  7.     sql = "SELECT * FROM Win32_Process where Caption Like '%" & Procs & "%'"
  8.     Set colItems = objWMIService.ExecQuery(sql,,48)
  9.     Found = False
  10.     For Each objItem In colItems
  11.         ProcPID = objItem.ProcessId
  12.         Found = True
  13.     Next
  14.     If Found = True Then
  15.      desktopx.object("OBJECTNAMEHERE).state = "Running" 
  16.     Else
  17.      desktopx.object("OBJECTNAMEHERE).state = "NotRunning"
  18.     End If
  19. End Function

then make 2 states in "OBJECTNAMEHERE" called "Running" and "NotRunning" (CaSe Is ImPoRtant)

that should work.

+1 Loading…
Reply #9 Top

Ahhh!

Thanks

Reply #10 Top

Quoting sViz, reply 6
Cool code.

There is soo much WMI can do, the best way to play with it is to download the WMI Code Creator i have used it on XP, Vista and 7 and it works on all of them, granted there are things that are not there on 7 that were there in XP, etc.  But at least you can try out code snippits with it.  Its really great.

+1 Loading…
Reply #11 Top

There is soo much WMI can do, the best way to play with it is to download the WMI Code Creator

Wow. That's awesome! Thanks, Roman. |-)

Reply #12 Top

sViz,

 If im looking for something from the system ill do a google search like "WMI Process Memory Usage" and it will show all kinds of things.

you end up with something like this: http://aspalliance.com/806_CodeSnip_Get_memory_size_usage_using_WMI_and_NET_20

some cool things out there.