Sign in to follow this  
Followers 0
oktoberfest2

Window handle and ProcessID

8 posts in this topic

First let me ask this question...

For any processid, is there an associated window handle?

If the answer is no, then I probably need to look no further.

What I'm trying to do is get a window handle based on a processid. Something that has been asked many times on the forum. I believe I may have hit two road blocks.

1. The processid I'm trying to get a window handle to is a Windows Service

2. If I remote desktop into a server, will the WinList() function see only windows related to my sessionID or can it retrieve all windows from all sessions (including the console session)?

The ProcessList() function will return the PID of the service. I'm trying to use the UDF '_ProcessGetHWnd' but it does not return a valid window handle.

An example process to try would be clipsrv.exe

Thanks

Share this post


Link to post
Share on other sites



First let me ask this question...

For any processid, is there an associated window handle?

If the answer is no, then I probably need to look no further.

Not all processes are GUI...

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

$PID = WinGetProcess("Windows Live Messenger")

$HWnd = _ProcessGetHWnd($PID)

MsgBox(0,"title", WinGetTitle($HWnd))





Func _ProcessGetHWnd($PID)
    
    local $WinList = WinList()
    
    local $Return = 0
    
    for $i = 1 to $WinList[0][0]
        if WinGetProcess($WinList[$i][1]) = $PID Then 
            $Return = $WinList[$i][1]
            ExitLoop
        EndIf
    Next
    
    Return $Return
    
EndFunc

Share this post


Link to post
Share on other sites

$PID = WinGetProcess("Windows Live Messenger")

$HWnd = _ProcessGetHWnd($PID)

MsgBox(0,"title", WinGetTitle($HWnd))





Func _ProcessGetHWnd($PID)
    
    local $WinList = WinList()
    
    local $Return = 0
    
    for $i = 1 to $WinList[0][0]
        if WinGetProcess($WinList[$i][1]) = $PID Then 
            $Return = $WinList[$i][1]
            ExitLoop
        EndIf
    Next
    
    Return $Return
    
EndFunc
He's already stated he's used that kip

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

I'm trying to use the UDF '_ProcessGetHWnd' but it does not return a valid window handle.

that script was my own script, and not the UDF he found somewhere.

Share this post


Link to post
Share on other sites

that script was my own script, and not the UDF he found somewhere.

Which will return the same exact results....

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

A process like clipsrv.exe doesnt have a Gui, like most services.

@oktoberfest2: Is the process ,you want to do stuff with, in the processlist of the taskmanager? (something different than "System.exe")

Share this post


Link to post
Share on other sites

A process like clipsrv.exe doesnt have a Gui, like most services.

@oktoberfest2: Is the process ,you want to do stuff with, in the processlist of the taskmanager? (something different than "System.exe")

The process is an executable file that runs as a service. It may very well be that the process is not a Gui. What I'm trying to do is run the SQL Server profiler utility and filter based on certain criteria, one of which is application name. This particular process/service runs but has no application name. I was trying to see if it was possible to get a handle to it and somehow set a title or something so that the profiler utility would pick it up so I could filter on it. Right now the only thing I have to go on is the client process id which can change when the computer is rebooted or the service is stopped and restarted.

Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0