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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to get Active Application or File name?

How to get Active Application or File name?

Scheduled Pinned Locked Moved C / C++ / MFC
adobetutorialquestion
7 Posts 4 Posters 0 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.
  • S Offline
    S Offline
    SNI
    wrote on last edited by
    #1

    Hi, I would like to find out which window is active (e.g. in taskbar we have several applications are running ADOBE, Winword, Excel.... and I am working on winword). I would like to know how to get the current application name or file name (e.g. test.doc). Pls suggest. Thanks

    SNI

    H 1 Reply Last reply
    0
    • S SNI

      Hi, I would like to find out which window is active (e.g. in taskbar we have several applications are running ADOBE, Winword, Excel.... and I am working on winword). I would like to know how to get the current application name or file name (e.g. test.doc). Pls suggest. Thanks

      SNI

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      You can use of EnumWindows for enumerates all windows and then you can use of IsWindowEnabled,Is it enable window or no.

      Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

      S A 2 Replies Last reply
      0
      • H Hamid Taebi

        You can use of EnumWindows for enumerates all windows and then you can use of IsWindowEnabled,Is it enable window or no.

        Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

        S Offline
        S Offline
        SNI
        wrote on last edited by
        #3

        thanks for this. Can you help me to find out file names (e.g. Two excel files are open Book1.xls and Book2.xls). How to get the name of file which is having focus. Thanks

        SNI

        S 1 Reply Last reply
        0
        • S SNI

          thanks for this. Can you help me to find out file names (e.g. Two excel files are open Book1.xls and Book2.xls). How to get the name of file which is having focus. Thanks

          SNI

          S Offline
          S Offline
          ShiXiangYang
          wrote on last edited by
          #4

          HWND hWnd=GetActiveWindow(); char *s; GetWindowText(hWnd,s); Then compare s and file name to get focus window. strcmp(s,filename);

          1 Reply Last reply
          0
          • H Hamid Taebi

            You can use of EnumWindows for enumerates all windows and then you can use of IsWindowEnabled,Is it enable window or no.

            Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

            A Offline
            A Offline
            alphaxz
            wrote on last edited by
            #5

            char Buffer[100]; HWND hwnd=::GetForegroundWindow() ; ::GetWindowText(hwnd,Buffer,sizeof(Buffer));

            a beginner

            H 1 Reply Last reply
            0
            • A alphaxz

              char Buffer[100]; HWND hwnd=::GetForegroundWindow() ; ::GetWindowText(hwnd,Buffer,sizeof(Buffer));

              a beginner

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              Do I need to use it? :-D

              Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

              A 1 Reply Last reply
              0
              • H Hamid Taebi

                Do I need to use it? :-D

                Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                A Offline
                A Offline
                alphaxz
                wrote on last edited by
                #7

                sWindowEnabled only check if this window can recive the keyboard and mouse event ,there are many windows can do this ,you canan't find the right window you need

                a beginner

                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