Jump to content



Photo

Possible to get PID from Window Name?


  • Please log in to reply
6 replies to this topic

#1 lolp1

lolp1

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 283 posts

Posted 12 July 2009 - 08:33 AM

Topic, I am looking for some method to do this but I can't find. Anyone of some help?





#2 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,364 posts

Posted 12 July 2009 - 08:40 AM

lolp1,

Do you think this function I found in the Help file might be what you are looking for? :)

WinGetProcess: Retrieves the Process ID (PID) associated with a window.

WinGetProcess ( "title" [, "text"] )


M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#3 lolp1

lolp1

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 283 posts

Posted 12 July 2009 - 08:57 AM

Doh! Well, I found another clever method, wish I'd have known about that 10 minutes ago :)

I used something along the lines of $pid = DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $hWnd, "int_ptr", 0)

EDIT: I also suggest the Help file be updated, seems like it didn't list many ways and thats why I was confused.

is the unique number which identifies a Process. A PID can be obtained through the ProcessExists or Run commands.

The process is polled approximately every 250 milliseconds.


Edited by lolp1, 12 July 2009 - 09:00 AM.


#4 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 12 July 2009 - 03:55 PM

You only need one way. In a language, having many different built in functions that do the same thing is redundant and pointless. Look at the help file first, search the forum second, then search google, and if you still can't find the answer, ask someone on the forum. This could have been found if you follow these steps.
"Failure is not an option -- it comes packaged with Windows" Gecko Web Browser, Yahtzee!, Toolbar Launcher (like RocketDock)Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI Triangle Solver, TCP File Transfer, Valuater's Autoit WrappersOOP In AutoItUsing Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com

#5 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,563 posts

Posted 12 July 2009 - 04:47 PM

In any language, the help file is your best friend.
GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!"

#6 lolp1

lolp1

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 283 posts

Posted 13 July 2009 - 01:15 AM

You only need one way. In a language, having many different built in functions that do the same thing is redundant and pointless. Look at the help file first, search the forum second, then search google, and if you still can't find the answer, ask someone on the forum. This could have been found if you follow these steps.


For what I needed I needed the PID from the window name - I did a google search/auto it help file and found nothing auto it related, hence my fix using the DllFunc call of auto it...

#7 bo8ster

bo8ster

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,189 posts

Posted 13 July 2009 - 02:19 AM

Have a look at http://www.autoitscript.com/forum/index.php?showtopic=97833&st=0&p=703478&hl=GetWindowThreadProcessId&fromsearch=1&#entry703478
Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)Brett F's Learning To Script with AutoIt V3Valuater's AutoIt 1-2-3, Class... is now in SessionContribution: Get SVN Rev Number, Control Handle under mouse, A Presentation using AutoIt, Log ConsoleWrite output in Scite




2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users