How to determine which Windows application has focus

I'm new to JAVA and new to programming. I hope someone will help me out. I'm trying to write a simple JLink program (JLink is a JAVA API for Pro|Engineer, a CAD design program). In part of this program I need to determine if Pro|E has focus. Is there some way to use JAVA to determine which actively running Windows application has focus?
I basically want my program to pause when focus changes to another program. For example: While Pro|E is active and has focus the program runs, when I select an Excel window, or Outlook, or Notepad or any other window my program will pause until focus is returned. I just need to determine which window within Windows has focus.
I hope I have explained this properly. I searched the internet for an answer but found nothing. I did come across some references to JNI, but I'm not sure what that is or how to use it.
Thank you!

I just need to determine which window within Windows has focus.No, you don't. All you need to determine is whether your application has the focus. If it doesn't, then some other application does, but it's really irrelevant which one does. All that's relevant is that your application doesn't have the focus and hence it should pause.

Similar Messages

  • How to determine which FileChooser ExtensionFilter has been selected

    Hi,
    I'm using a JavaFX fileChooser.showSaveDialog with two extension filters (*.csv and *.xml). How can I determine which filter was selected when the end-user clicks the save button?
    I am writing a program that allows the end-user to create an output file in CSV or XML format.
    If the end-user enters a file name with no extension, I need a way to determine if I should create a CSV or XML file. I would also like to add the proper extension to the file name if none is specified by the end-user. I want to do this based on which filter the end-user has selected. I wrote a Java program 5 years ago and I was able to do this with the following instruction:
    String extension = jFileChooser.getFileFilter().getDescription();
    I can't find a similar instruction for JavFX.
    My JavaFX Code:
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(new File(options.getOutputDirectory()));
    ExtensionFilter filter1 = new FileChooser.ExtensionFilter("Comma Delimited (*.csv)", "*.csv");
    fileChooser.getExtensionFilters().add(filter1);
    ExtensionFilter filter2 = new FileChooser.ExtensionFilter("XML Document (*.xml)", "*.xml");
    fileChooser.getExtensionFilters().add(filter2);
    File file = fileChooser.showSaveDialog(stage);
    String filename = file.getAbsolutePath();...How do I determine which extension filter has been selected?
    My Java Code:
    JFileChooser jFileChooser = new JFileChooser();
    jFileChooser.setCurrentDirectory(new File(outputDirectory));
    jFileChooser.setSelectedFile(new File(backupfile));
    FileFilter filter = new FileNameExtensionFilter("Comma Delimited (*.csv)", "csv");
    jFileChooser.addChoosableFileFilter(filter);
    jFileChooser.setFileFilter(filter);
    filter = new FileNameExtensionFilter("XML Document (*.xml)", "xml");
    jFileChooser.addChoosableFileFilter(filter);
    jFileChooser.setAcceptAllFileFilterUsed(false);
    jFileChooser.setDialogTitle("Export Alarms");
    jFileChooser.setBackground(colorFileChooser);
    int returnVal = jFileChooser.showDialog(jFrame, "Export");
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = jFileChooser.getSelectedFile();
        String filename = file.getAbsolutePath();
        String extension = jFileChooser.getFileFilter().getDescription();
        if (extension.equals("XML Document (*.xml)")) {
            if (!filename.endsWith(".xml") && !filename.endsWith(".XML")) {
                filename = filename + ".xml";
            saveTableXML(filename);
        else if (extension.equals("Comma Delimited (*.csv)")) {
            if (!filename.endsWith(".csv") && !filename.endsWith(".CSV")) {
                filename = filename + ".csv";
            saveTableCSV(filename);
    }Thanks,
    Barry
    Edited by: 907965 on May 13, 2012 1:14 PM
    Edited by: 907965 on May 13, 2012 1:15 PM
    Edited by: 907965 on May 13, 2012 1:19 PM

    This problem is currently tracked as http://javafx-jira.kenai.com/browse/RT-18836.

  • How to determine which chipset my Satellite L300/700 has?

    I have a SATELLITE L300/700 (PSLB8A-047004). The User Guide covers several models. It indicates that the chipset determines which memory modules I need for a memory upgrade. How do I find out which chipset I have, please?
    Kev.

    > I'm still curious about how to determine which chipset I have - any thoughts?
    Go to the device manger and click on IDE Ata/Atapi controllers:
    http://img814.imageshack.us/img814/7321/chipset.jpg
    There you will see your chipset installed on your laptop. In my case, as shown on the screenshot is Intel ICH9m

  • How to determine which elements are queryable via Web Services QueryPage

    I am trying to query opportunities by associated opportunity product revenue records, but I continue to receive errors like "Unexpected text: = '9598015'".
    From reviewing the forums, it looks like this is when I am querying a field that is not defined to be queryable.
    Could someone please tell me how to determine which fields are queryable on a particular record type like this? I have tried using basic short text fields and indexed short text fields - but continue to receive the error message above.
    Thanks in advance.

    I found at least partial answers to my questions.
    MessageContext.getPropertyNames() can be used to see the properties on a given flow.
    MessageContext.getProperty(prop) can be used to get information for paroperties such as:
    prop=javax.xml.rpc.service.endpoint.address
    prop=wsdl.portName
    -- Frank

  • How CSSCAN determines which indexes need to be rebuild ?

    Hi everybody,
    i'm currently migrating 3 Oracle databases that contain CP1252 characters unproperly stored in WE8ISO8859P1 instances.
    The key steps of the migration are :
    1. ALTERing CHARACTERSET to WE8MSWIN1252
    2. changing CHARACTER SEMANTIC LENGTH for CHAR and VARCHAR2 columns
    3. truncating data stored in VARCHAR2(4000) columns
    2. Full export
    3. Full import in a ALL32UTF8 instance
    To do all of this (and especially the step 3), i use the CSSCAN utility (very practical !!!).
    And i have a question about CSSCAN: how CSSCAN determines which indexes need to be rebuild. What is the logic ?
    Looking at the CSSCAN report, i have a lot of cells/columns that are affected by the characterset migration, and i have just a few index to rebuild.
    Why would i like to understand the logic ? Because i would like to rebuild ONLY indexes that REALLY need to be rebuilt and i am not sure that all the indexes specified by CSSCAN really need to be rebuilt.
    Thanks for any information about that.
    (and sorry for my english)
    NB: i have managed "function-based indexes" specifically: i drop them before the export, and i recreate them after the import. So my question mostly target the "regular indexes"

    1. All indexes whose key contains at least one character column with convertible or exceptional data, excluding indexes with names equal to some constraint name for the same owner.
    plus
    2. All functional indexes on tables that have columns needing conversion, excluding indexes with names equal to some constraint name for the same owner.
    The condition regarding constraints does not seem to be very fortunate but it comes from times when the appropriate flag in index metadata was not yet available.
    But note that in your migration scenario, you do not actually have to care much about indexes. Step 1 & 2 do not need any modifications to the user data and hence to index contents. Step 3, if done through UPDATE, will modify affected indexes automatically. Step 4 does not affect the database. Step 5 will recreate all existing indexes anyway.
    -- Sergiusz

  • How to determine which application has focus in Windows

    Hello all-
    I'm trying to work around the "Labview freezes when there is large data on the clipboard known issue" (http://forums.ni.com/t5/LabVIEW/Labview-freeze-when-accessing-a-custom-menu-with-data-on-the/m-p/200...) and one thought is to try to determine if Labview has focus, and if it does then clear the clipboard.  If Labview doesn't have focus, then let the user use the clipboard.  This would be a good work-around because it would let the users paste screen shots and such into notes files and wouldn't risk a nasty clipboard/ menu/ freeze-crash.
    My initial search for determining windows application focus, came up empty though.  This old thread (from 2005) pretty much covers it:
    http://forums.ni.com/t5/LabVIEW/Is-there-a-simple-way-to-programatically-tell-which-VI-window/m-p/20...
    The "Is Frontmost' property does not do it.  I need to determine if Labview has focus, as opposed to Windows, notepad, firefox, etc.  I also reviewed the commad prompt commands and didn't find anything immediately helpful there either.
    Any ideas?
    Thanks,
    Casey
    Solved!
    Go to Solution.

    Christian-
    That's perfect!  By using GetForegroundWindow, GetWindowTextA and GetWindowFileNameA in user32.dll I can detect which window has focus.  If Labview has focus then I programatically clear the clipboard so the user can still use it when not clicking on Labview windowns, but also we do not risk a freeze and crash because of the clipboard/ freeze bug.
    I briefly thought about using the .NET versions of these functions, but because that would have forced an upgrade to at least .NET framework 3.0 for all of my user computers, I decided on the unmanaged user32.dll.
    Thanks for the suggestion.  I think I'm pretty close to a work around here that should last me until they fix the clipboard/ freeze bug.
    Thanks,
    Casey

  • JSF: How to determine which element has the focus?

    Hi all,
    I have a JSP with some input fields and a text area. When I press "ENTER" the data I have entered should be saved. That works fine (I use JavaScript to catch the keyPressed-event). But when I want to insert a new line in the text area, I press ENTER too and this invokes the javascript function. So it�s not possible to insert a new line in the text area. And I don`t want to save the data when I�m just inserting a new line.
    is it possible to determine which element has the focus at the moment of pressing ENTER? if it`s the text area then I won�t save the data and inserting a new line is possible? Or how to say: "Insert an new line if the user presses SHIFT+ENTER" or something like that?
    I�m using JSC for my application and this is my JS-function:
    function checkIt(evt)      
    var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
         if (charCode == 13)
              document.getElementById('form1:bt_Save').click();
              return false;
              return true;
    I�m looking for something like that:
    if(charCode == 13) {
    if(document.getElementById('form1:textArea').hasFocus())
    doNothing...
    else {
    document.getElementById('form1:bt_Save').click();
         return false;
    thanks for any help

    Hi,
    I searched through many forums (js of course too) but
    I couldn�t find a solution. Everybody knows how to
    set the focus but not how to get it. We often use
    JSF/JSP with javascript and maybe somebody here has
    another approach to this problem (how to solve it
    using jsf itself or anything else)?Take easy. I just suggested to search in a JavaScript forum , in your question you didn't mentioned this. Good luck man.
    Cya.

  • How to determine which item is currently in focus

    Is there a quick javascript way of determining which element on a page is currently in focus??

    You tend to complicate things :-)
    What you seem to want is: User is typing in some text field, clicks the Submit button, you would like the page to refresh and focus to return to the same text field so the user can continue typing as if nothing has happened?
    Then why do a traditional page submit? This seems like a perfect use for the AJAX stuff. Just do the stuff in the background instead of going thru all these hoops to save and restore focus.
    Also, it makes (some) sense for text fields, but what use does this feature provide for other input elements like checkboxes and radiogroups and select lists?
    What functionality are you trying to provide exactly?
    was just thinking about a quick and easy way of setting scrollbar position
    on page refreshYou mean having the page refresh and scroll down to some pre-determined point instead of at the top?
    This is best done by using named anchors. Just capture the item name that causes the page to submit in a hidden page item and add it to the same-page branch using the
    f?p=...#&P1_ANCHOR.syntax.
    Just sprinkle your region and label templates with these named anchors and you are done.
    Hope this helps.

  • How to determine which user has an Access 2013 databse open

    How can I tell which user / PC has opened a Backend Access database?

    If the file is stored on a server and you have access to it, you could check in Computer Management, then go into System Tools, Shared Folders, Open Files, and you should find the file listed there along with which user has it open currently.

  • How to determine which cell the user has just left?

    I want to check the contents of a JTable cell just after the user has left that cell.
    What is the most reliable way to determine which cell the user has just left?

    Hi,
    I use the cellRenderer for that... if the value is not correct, I call an editCellAt() method...
    JRG

  • How to determine which new add-ons were installed?

    I am troubleshooting on a system that I use regularly, but I am not the primary user. When I started Firefox today I got an Add-ons window saying that "3 new add-ons have been installed". I'd like to know which 3 are the newly installed add-ons, because I suspect they are things my mother agreed to inadvertently. This system now has 15 Extensions, 1 Theme, and 17 Plugins installed, including the 3 new ones. Is there any way for me to determine which 3 are the new ones? By the way, I'm not entering this question from the system inquestion, so any info of that type that gets appended to this submission should be ignored. The system in question is running Windows XP Home SP3 and Firefox 3.6.10.

    Pre-Deployment Planning — Enterprise Administration Guide States "
    Installing Acrobat DC Standard¶
    Acrobat DC products delivered via an ESD EXE download provide one installer that is used for both Acrobat Standard and Professional. The serial number you use determines which product is installed. What’s important to note is that when you extract the Acrobat ESD EXE (Acrobat_DC_Web_WWMUI.exe or Acrobat_2015_Web_WWMUI.exe), you’ll see AcroPro.msi in the output folder. This is the correct behavior. Simply remember to use AcroPro.msi in any command line scripts.
    Note
    Existing scripts that use AcroStan.msi should be updated."
    Both Acrobat DC Pro and Standard have KEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Adobe\Adobe Acrobat\2015\Installer ENU_GUID {AC76BA86-1033-FFFF-7760-0E0F06755100}
    On the laptop with DC standard installed C:\ProgramData\regid.1986-12.com.adobe\regid.1986-12.com.adobe_V7{}AcrobatESR-12-Win-GM-e n_US.swidtag
    On the laptop with DC Pro installed C:\ProgramData\regid.1986-12.com.adobe\ is empty
    Your guide does not have any information regarding Acrobat DC. Please explain how to verify if Acrobat DC Pro or standard is installed. or explain how to get the ENU_GUID for standard to start with {AC76BA86-1033-FFFF-BA7E.

  • How to determine which diskgroups a database is using

    We want to be able to determine which diskgroups a database is using. We have been using the following query which works but only if the database has open or had open the "right set of files" recently --
    SQL> select dg.name from v$asm_diskgroup_stat dg, v$asm_client c where dg.group_number = c.group_number and c.db_name = 'MYDB';
    If no archived logs have been generated in a while then the diskgroup that contains the FRA will no be listed in this query. We can cause the FRA diskgroup to show up if we archive the current log. Here is an example.
    SQL> select * from v$asm_client;
    GROUP_NUMBER INSTANCE_NAME
    DB_NAME  STATUS
    SOFTWARE_VERSION
    COMPATIBLE_VERSION
                5 +ASM
    DBI03    CONNECTED
    11.2.0.3.0
    11.2.0.0.0
    SQL> alter system archive log current;
    System altered.
    SQL> select * from v$asm_client;
    GROUP_NUMBER INSTANCE_NAME
    DB_NAME  STATUS
    SOFTWARE_VERSION
    COMPATIBLE_VERSION
                5 +ASM
    DBI03    CONNECTED
    11.2.0.3.0
    11.2.0.0.0
    GROUP_NUMBER INSTANCE_NAME
    DB_NAME  STATUS
    SOFTWARE_VERSION
    COMPATIBLE_VERSION
                7 +ASM
    DBI03    CONNECTED
    11.2.0.3.0
    11.2.0.0.0
    Notice how diskgroup "7" shows up after the log is archived? It appears that the instance for diskgroup "7" will eventually be drop off after some idle period. Is there a way to generate the list of diskgroups consistently?

    Hi,
    If your database was configured manually (i.e not using DBCA) you should check v$(datafile,controlfile,logfile,block_change_tracking,etc) and parameters of database (log_archive_dest,db_recovery_file_dest,spfile,etc) to map these info.
    If your database was configured using DBCA you can try it:
    $ srvctl config database -d <database_name> |grep "Disk Groups"

  • How to determine which file descriptor opened my driver?

    Suppose a user process opens my driver twice. How does open() determine which file descriptor opened the device? In Linux, the kernel will pass a pointer to a structure which represents the open file descriptor. However, Solaris only passes the device number to open(), so I can only determine my device was opened, but not which file. I need this information because my driver needs to keep track of all file descriptors opened for the device.
    Thanks!
    -Darren

    I'm still at a loss why you need to know the file descriptor value (unless the app is sufficiently spaghettied that it has to query the driver to figure out what it opened with what). It's like asking what filename was used to open the device (which you can't get either). Since Solaris is based on a Streams framework, it would be bad to have drivers to even think it has a direct mapping into user space. It would be the same in asking (using /bin/sh):
    prog3 4>&1 3>&1 2>&1 | prog2 | prog1
    and you want to know from prog1 what descriptor prog3 wrote to. I don't see how linux even does this properly, since any given file open can have multiple file descriptors (via dup).

  • How to determine which AD server User Profiles is pulling from?

    I have a User Profile set up, and can't recall specifying an AD server.
    I've been asked to run multiple UP incrementals during the day. The SharePoint and SQL server seem capable of handling it, but I forgot to check performance of the AD server(s) during the nighly incremental.
    How would I determine which AD server is being used, so I can test CPU and memory?
    Thanks,
    Scott

    Go to:
    C:\Program Files\Microsoft Office Servers\14.0\Synchronization Service\UIShell\miisclient.exe
    On the Operations tab, if you look at any of the operations, there is a Connection Status box in the middle right. This contains the DC that it has connected to.
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • How to determine which Aperature Library is the original?

    I purchased an Imac a couple of years ago and switched to Aperature to help eliminate duplicates.  I spent time bringing them in a little at a time as not to duplicate.  I have moved what I thought was the master copy to an external drive so that it would not take up all the space.  I show eight copies of Aperature when I click option & then Aperature.  Please help me determine which is the main copy as they all have different version and original numbers.  I am so confused and was just trying to break it down so that I could manage it in even years at a time so that I could organize faces.  Not even really sure what version means as opposed to original.  I hope with some guidence I can finally get this right.  Thank you in advance if you understand where I am coming from

    My short guide here may help you understand the parts of Aperture better, which in turn will help you ask specific questions.
    I advise all users of Aperture to read and understand the first seven chapters of the User Manual -- it's available on-line, as well as via "Help➞Aperture Help" -- as they provide a tour of the interface.
    You are going to have to do some work.  I can tell that you are confused -- Aperture, assuredly, is confusing at first -- but I can't tell what you are asking.  You need to distinguish, in your questions, between the files you imported (Aperture calls these "Originals" after you've imported them) and the Images in Aperture (Aperture refers to these as both Images and as Versions).  Every Image has an Original.  The Original (remember, it's a file) can be stored inside the Aperture Library package, or outside the Library package.  These distinctions are covered in both of the resources mentioned above.
    If nothing makes sense, post back and we'll see how we can help you.
    --Kirby.

Maybe you are looking for