Sign in to follow this  
Followers 0
billym

Need PID2WINHANDLE function?

3 posts in this topic

I have a application that when launched with the run command with hide option it still does not hide the window but I am able to hide it when setting the state of the window. I am wanting to minimize the display time or eliminate the display of the window all together. I have tried all of the reccomended solutions in the forum but was unable to find an example of hiding the window by using the PID to get the windows handle then trying to manipulate it from here. When I spy on the window I can see that there is some delay between the creation of the handle and when it is made visible. Any help would be appreciated.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It's not sraight forward to answer your question the way you've asked it because a single PID can have many associated windows.

Here is an approach that should help however...

This uses WinList to get an array of all window titles and handles. It then redim's the resulting array to add a third element in the second dimension that holds the PID of the process associated with each window.

$myWinList = _WinListWithPID()

For $i = 1 to (Ubound($myWinList, 1) - 1)
    ConsoleWrite("Handle: " & $myWinList[$i][1] & _
                " Pid: "    & $myWinList[$i][2] & _
                " Title: "  & $myWinList[$i][0] & @CR)
Next

Exit

Func _WinListWithPID()
    $aWin = WinList()
    Redim $aWin[Ubound($aWin, 1)][3]
    For $n = 1 to (Ubound($aWin, 1) - 1)
        $aWin[$n][2] = WinGetProcess($aWin[$n][1])
    Next
    Return $aWin
EndFunc

Dale

Edit: Corrected error trying to get and report PID of element 0 in the array (this holds the number of windows, not valid window information). Also added Window Title to Example output.

I have a application that when launched with the run command with hide option it still does not hide the window but I am able to hide it when setting the state of the window. I am wanting to minimize the display time or eliminate the display of the window all together. I have tried all of the reccomended solutions in the forum but was unable to find an example of hiding the window by using the PID to get the windows handle then trying to manipulate it from here. When I spy on the window I can see that there is some delay between the creation of the handle and when it is made visible. Any help would be appreciated.

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Hey, I tried to do that once!!

Nice one Dale!


[center]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.[/center]

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