Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Getting process id of a window that name changes
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Getting process id of a window that name changes

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    14

    Getting process id of a window that name changes

    Well...

    In this window the name of window change becouse show your FPS... só, each second it change and i'm having dificulty about getting process id...

    What i try:

    Code:
    procedure TForm1.Button1Click(Sender: TObject);
    var
      H,PH:THandle;
      ProcessID, THandleID, R : DWORD;
    begin
      H := FindWindow(nil,Pchar('Big Boss'));
      THandleID := GetWindowThreadProcessId(H, @ProcessID);
      ProcessID := OpenProcess(PROCESS_ALL_ACCESS,FALSE,ProcessID);
      button1.caption :=  inttostr(ProcessID);
    end;
    The button1.caption allways be 0...

    An example of the window text:

    Big Boss [FPS:195]

    After 1 sec:

    Big Boss [FPS:103]

  2. #2
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: Getting process id of a window that name changes

    Get the class name instead, it won't change

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    14

    RE: Getting process id of a window that name changes

    when i list all process, this is the class that return: "could not be fetched;"

    I use this source to list all processes:

    Code:
    function EnumProcess(hHwnd: HWND; lParam : integer): boolean; stdcall;
    var
      pPid : DWORD;
      title, ClassName : string;
    begin
      //if the returned value in null the
      //callback has failed, so set to false and exit.
      if (hHwnd=NULL) then
      begin
        result := false;
      end
      else
      begin
        //additional functions to get more 
        //information about a process.
        //get the Process Identification number.
        GetWindowThreadProcessId(hHwnd,pPid);
        //set a memory area to receive 
        //the process class name
        SetLength(ClassName, 255);
        //get the class name and reset the 
        //memory area to the size of the name
        SetLength(ClassName, 
                  GetClassName(hHwnd,
                               PChar(className), 
                               Length(className)));
        SetLength(title, 255);
        //get the process title; usually displayed 
        //on the top bar in visible process
        SetLength(title, GetWindowText(hHwnd, PChar(title), Length(title)));
        //Display the process information
        //by adding it to a list box
        form1.ProcessListBox.Items.Add
          ('Class Name = ' + className +
           '; Title = ' + title + 
           '; HWND = ' + IntToStr(hHwnd) +
           '; Pid = ' + IntToStr(pPid));
        Result := true;
      end;
    
    
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    EnumWindows(@EnumProcess,0)
    end;


    I have tryed including an if before add tolistbox, like this:
    Code:
    if lowercase(copy(title,1,8)) = 'big boss' then
    begin
        //Display only the process information of Big Boss
        //by adding it to a list box
        form1.ProcessListBox.Items.Add
          ('Class Name = ' + className +
           '; Title = ' + title +
           '; HWND = ' + IntToStr(hHwnd) +
           '; Pid = ' + IntToStr(pPid));
        Result := true;
    end;
    But nothing is returned to listbox D:

  4. #4
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: Getting process id of a window that name changes

    Are you sure the class name is "Big Boss"? Also, some system processes (at least on WinXP 32-bit) doesn't return class names

  5. #5
    Junior Member
    Join Date
    Nov 2010
    Posts
    14

    RE: Getting process id of a window that name changes

    the name that appear when i list all processes is Big Boss [FPS 169]...

  6. #6

    RE: Getting process id of a window that name changes

    How about launching your application with Olly? If you set up a breakpoint at RegisterClassA (or something similar like RegisterClassExW etc), you can see what actually gets passed as the class name.
    Also, it's not impossible that "could not be fetched;" is the class name after all, just to confuse you.

  7. #7
    Administrator
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    1,274

    RE: Getting process id of a window that name changes

    Use this program to find the class name..

    Open it up, then press Ctrl+F and a little window will appear.

    On that window you will see the icon of a little window with a "target" symbol over it. Click and drag that symbol on top of the window you wish to see the class name, and it will display the class name there.

    After you've selected a window with that target thing, make sure it is selected to "Properties" under the "Show" area, and press OK.

    A new window will appear called Property Inspector, click on the tab "Class", and there you can view, select and copy the class name of that process.

    It's very useful when people are sneaky and have the class name as blank spaces, since you can highlight the text there and copy it.

  8. #8
    Junior Member
    Join Date
    Nov 2010
    Posts
    14

    RE: Getting process id of a window that name changes

    @volf ram

    I found "_jv_registerclasses" but i didn't found the class name...

    @Dark Pallys

    The result:



    Maybe the class name is could not be fetched how volf ram said, just to confuse me...



    MY PROBLEM WILL BE SOLVED IF SOMEONE TELL ME HOW I CAN TAKE THE PID OF THE CURRENT WINDOW.

    I've tryed GetCurrentProcessID with a global hotkey, but only get PID of project1.

  9. #9
    Administrator
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    1,274

    RE: Getting process id of a window that name changes

    Quote Originally Posted by Antharaz
    @volf ram

    I found "_jv_registerclasses" but i didn't found the class name...

    @Dark Pallys

    The result:



    Maybe the class name is could not be fetched how volf ram said, just to confuse me...



    MY PROBLEM WILL BE SOLVED IF SOMEONE TELL ME HOW I CAN TAKE THE PID OF THE CURRENT WINDOW.

    I've tryed GetCurrentProcessID with a global hotkey, but only get PID of project1.
    Do as I said, click OK on that window and it will show you a property window, where you can copy the exact class name from a textbox

  10. #10
    Junior Member
    Join Date
    Nov 2010
    Posts
    14

    RE: Getting process id of a window that name changes

    Hmm...

    Class name in edit: "could not be fetched"

    So, how volf ram said, this is the class name...

    TY so much Dark Pallys... now i'll search how to get a process id by class name :B


    EDIT

    I search but not found how get a processid by class name.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •