Jump to content
Sign in to follow this  
MadBoy

Controling windows knowing only PID or process name?

Recommended Posts

MadBoy

Hey,

Wanted to know if it's possible to control some window when i actually know only PID or process name? For example i wanted to control sysdm.cpl, but all i know is rundll32.exe process being opened and it's PID. I don't want to use TitleNames as it will vary with each language. So how would i know that sysdm.cpl was actually on TOP of all other windows so i could control it and switch some things in there (for example drivers signing option). I've been trying some possibilities but maybe there's some i missed.

Run("control.exe sysdm.cpl")

tnx for help.


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites
improbability_paradox

My own contribution :P

CODE
Func _GetWHNDLFromPID($PID)

Local $wHndl="", $WCCount=0, $WList

Do

Local $WList=WinList()

for $WLCount= 1 to $WList[0][0]

if WinGetProcess($WList[$WLCount][1])=$PID Then

$wHndl=$WList[$WLCount][1]

ExitLoop

EndIf

Next

if $WCCount = 400 Then Return -1

Sleep(50)

$WCCount += 1

Until not($wHndl="")

Return $wHndl

EndFunc

Although, upon reviewing the thread which Valuater referenced, this does essentially the same thing as one of the functions listed there.

Edited by improbability_paradox

Share this post


Link to post
Share on other sites
improbability_paradox

Updated the code in my post, as one of the variables was spelled incorrectly at one point

Edit #2

Removed an un-needed EndIf

Edited by improbability_paradox

Share this post


Link to post
Share on other sites
Helge

I've just uploaded a updated version of my old ProcessGetHWnd with a new timeout-parameter and

some other smaller changes. It can return a single HWnd matching a PID and an optional title and it

can also return all matching HWnd's in array.

Files :

- http://www.autoitscript.com/fileman/users/Helge/udfs/_ProcessGetHWnd.au3

- http://www.autoitscript.com/fileman/users/Helge/udfs/_ProcessGetHWnd_test.au3

EDIT : Updated test.

Edited by Helge

Share this post


Link to post
Share on other sites
MadBoy

I've just uploaded a updated version of my old ProcessGetHWnd with a new timeout-parameter and

some other smaller changes. It can return a single HWnd matching a PID and an optional title and it

can also return all matching HWnd's in array.

Files :

- http://www.autoitscript.com/fileman/users/Helge/udfs/_ProcessGetHWnd.au3

- http://www.autoitscript.com/fileman/users/Helge/udfs/_ProcessGetHWnd_test.au3

EDIT : Updated test.

Tnx boys, but i seems to have problem with what i am trying to achieve.

I'm trying to control window that i am first trying to start with Run("control.exe sysdm.cpl").

After that command i check for process rundll32.exe which seems to be the one that is responsible for that. But even when i use PID of rundll32.exe with Helge functions, tests it says it doesn't find any matching windows. So anyone have solution for this?

EDIT: my bad. seems the window has to be active on screen for the script to work..

Edited by MadBoy

My little company: Evotec (PL version: Evotec)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.