Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. how to get window name of a specific application

how to get window name of a specific application

Scheduled Pinned Locked Moved C#
helpquestioncsharpdatabasetutorial
3 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    batmanAgen
    wrote on last edited by
    #1

    hi guys, how can i get the window name of a program (e.g. MS Word) programatically? im using c#, and im using this in my program that ends/terminates an application based on data returned by some queries from a database. i have no problems if i start a fresh instance of MS Word since i can have the window name hardcoded in my program (the default window name is "Document1 - Microsoft Word"), thus i can still close that application using my code. the problem is that when i open an existing file (thus the window name is dependent on the filename specified by the user), now when this happens, i cannot close the application since i cant get the window name dynamically. pls help.. tnx :)

    G S 2 Replies Last reply
    0
    • B batmanAgen

      hi guys, how can i get the window name of a program (e.g. MS Word) programatically? im using c#, and im using this in my program that ends/terminates an application based on data returned by some queries from a database. i have no problems if i start a fresh instance of MS Word since i can have the window name hardcoded in my program (the default window name is "Document1 - Microsoft Word"), thus i can still close that application using my code. the problem is that when i open an existing file (thus the window name is dependent on the filename specified by the user), now when this happens, i cannot close the application since i cant get the window name dynamically. pls help.. tnx :)

      G Offline
      G Offline
      Gokulan Venattil
      wrote on last edited by
      #2

      Hi, First get the active word application and iterate thru the Documents. private void IterateWordDocs() { //Iterate docs foreach (Microsoft.Office.Interop.Word.Document doc in WordApp.Documents) { //Your doc name doc.Name == "YourDocName" } } Regards Gokul

      1 Reply Last reply
      0
      • B batmanAgen

        hi guys, how can i get the window name of a program (e.g. MS Word) programatically? im using c#, and im using this in my program that ends/terminates an application based on data returned by some queries from a database. i have no problems if i start a fresh instance of MS Word since i can have the window name hardcoded in my program (the default window name is "Document1 - Microsoft Word"), thus i can still close that application using my code. the problem is that when i open an existing file (thus the window name is dependent on the filename specified by the user), now when this happens, i cannot close the application since i cant get the window name dynamically. pls help.. tnx :)

        S Offline
        S Offline
        S Senthil Kumar
        wrote on last edited by
        #3

        You can use Process.GetProcesses to get the Process instances associated with MS Word and then use MainWindowTitle[^] to get the window titles. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups