| View previous topic :: View next topic |
| Author |
Message |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed May 14, 2008 7:13 pm Post subject: picking up new processes |
|
|
I have a question. How do you pick up new processes. Like in task manager. If you have it open and then open up notepad it will update and show notepad.exe in the process list. How do you do that. Like detect that a new process got opened.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Overload Master Cheater
Reputation: 0
Joined: 08 Feb 2008 Posts: 293
|
Posted: Wed May 14, 2008 7:20 pm Post subject: |
|
|
| just keep looping checking for the processes. Instead of calling all the processes once, put that into a loop.
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed May 14, 2008 7:26 pm Post subject: |
|
|
Notice the taskmanager flicker? It's because it recalls everything
_________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed May 14, 2008 7:27 pm Post subject: |
|
|
Excuse me but may I ask how. I mean, if I already listed the processes. I could just loop the listprocess() function, but then I would keep adding and i'd have like a bajillion list strings for the same process. And I can't really delete each one at the end of the loop. Isn't there a way to like loop and take a snapshot of all the processes, and then compare it to the other snapshot, and then if they're different figure out which process it is that has been added?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Wed May 14, 2008 7:42 pm Post subject: |
|
|
Send The Message LB_RESETCONTENT before you print out the new items.
_________________
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed May 14, 2008 8:12 pm Post subject: |
|
|
If you decide that you want to view the source i added a timer and added LB_ERASECONTENT in ListProcess
You can fix the scrolling problem
Every 3 seconds, on timer, it will erase and go to top
_________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed May 14, 2008 8:30 pm Post subject: |
|
|
| blankrider wrote: | If you decide that you want to view the source i added a timer and added LB_ERASECONTENT in ListProcess
You can fix the scrolling problem
Every 3 seconds, on timer, it will erase and go to top |
LB_ERASECONTENT does not exist. And how would I fix the scrolling problem. For those of you that don't know, the scrolling problem is it that it resets the scroll bar to the top so if your browsing through the processes your reset to the top every 3 seconds. Oh yes, and hwo do I not have it flicker every 3 seconds. Like task manager only flickers when you open a new process not every "x" seconds.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed May 14, 2008 8:34 pm Post subject: |
|
|
It doesn't use LB_CONTENTERASE or w/e
I don't think so
I know it refreshes on a timer and not when new processes open because you can customize the time
_________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed May 14, 2008 8:40 pm Post subject: |
|
|
| blankrider wrote: | It doesn't use LB_CONTENTERASE or w/e
I don't think so
I know it refreshes on a timer and not when new processes open because you can customize the time |
I know,but can't I make it so it refreshed when a process opens. or at least refresh without resetting the scrollbar.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Wed May 14, 2008 8:40 pm Post subject: |
|
|
1. LB_RESETCONTENT
2. Get the current index, then get the string at that index using LB_GETCURSEL and LB_GETTEXT then use LB_FINDSTRING and LB_SETCURSEL to put it back to that string, you can have it make a check for -1 index returned by FINDSTRING (incase process is gone) and then set it back to the index returned by LB_GETCURSEL in the beggining.
will look like this:
| Code: | int index = SendMessage( hList, LB_GETCURSEL, 0, 0 );
TCHAR tszText[260];
SendMessage( hList, LB_GETTEXT, index, (LPARAM)tszText );
//do your reset and fill list again
int newindex = SendMessage( hList, LB_FINDSTRING, -1, (LPARAM)tszText );
if ( newindex != CB_ERR )
SendMessage( hList, LB_SETCURSEL, newindex, 0 );
else
SendMessage( hList, LB_SETCURSEL, index, 0 ); |
Else make the list box bigger?
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Thu May 15, 2008 1:12 am Post subject: |
|
|
Look at the example I uploaded in your other topic Obi, I have a function to refresh the list.
_________________
- Retired. |
|
| Back to top |
|
 |
Zand Master Cheater
Reputation: 0
Joined: 21 Jul 2006 Posts: 424
|
Posted: Thu May 15, 2008 5:29 am Post subject: |
|
|
| Um, get the number of processes running, keep looping it and if old number < new number then refresh it or something?
|
|
| Back to top |
|
 |
Estx Expert Cheater
Reputation: 0
Joined: 04 Mar 2008 Posts: 172
|
Posted: Thu May 15, 2008 6:59 am Post subject: |
|
|
Take x0r's advice, saves processing time and memory space - good coding practice as well. You can also compare the memory of the previous result and the current with this method without having to worry about all the extra information that changes with other indirect API calls.
And obviously don't update the display every-time you refresh unless data has changed that you need displayed (CPU usage, Memory usage, Open Threads etcetera).
| Quote: | | Um, get the number of processes running, keep looping it and if old number < new number then refresh it or something? |
If one process terminated and another started between the interval that the processes are being enumerated at, then there would be no update to what's refreshed.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Thu May 15, 2008 7:33 am Post subject: |
|
|
Or instead of including psapi (if you don't want to) you can call ZwQuerySystemInformation yourself with SystemProcessesAndThreadsInformation ( 5 ) to get the same result.
CreateToolhelp32Snapshot also calls ZwQuerySystemInformation as does EnumProcess, so you get the same results basically either way. One function offers more results then the other.
_________________
- Retired. |
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu May 15, 2008 8:27 am Post subject: |
|
|
| Wiccaan wrote: | | Look at the example I uploaded in your other topic Obi, I have a function to refresh the list. |
You added a refresh button. I want an automatic update xD.
@xor
Looking up EnumProcesses right now.
| Code: |
DWORD epProcesses[1024], epByteRet, epNumProcesses;
EnumProcesses(epProcesses, sizeof(epProcesses), epByteRet);
epNumProcesses = epByteRet / sizeof(DWORD);
for(int i = 0; i<epNumProcess; i++) {
SendMessage(hList, LB_ADDSTRING, NULL, (LPARAM)epProcesses[i]);
}
|
Is that right? Btw, if I made a for loop that had the original from startup, and then enumerated the processes. Saw if epNumProcesses had decreased/increased, it could relist all the processes. But where would I put the for loop? Btw, how do I fix the scrollbar problem?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
|