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

Similar Messages

  • 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 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 determin wich control has focus

    I'm using arrow keys to drive an external device. I catch the main vi key events and act on it. On this vi is also a textinput. When I navigate true is input with arrow keys the main vi events are also fired. That of course should not happen. Is there a way to distinguis between such events. Thus between a vi's main keyboard events and keyboard events in a control on this vi. I thought of finding out wich control has focus.?

    Sometimes when you dialog controls, the last "OK" button added to the front panel has the focus turned on by default. You can right click on the control and select "Customize >> Key Navigation" and select "None" in the list.
    It seems you have a different problem and are using event structure. Nomally we use the "Value Change" as event condition. Is it possible that you may choose a different condition, such as "Key Down, Key up, etc"?
    -Joe

  • How to determine which drive has the most recent backup?

    I have a few drives that contain backups of files. What would be the easiest way to figure out which of the drives has the most recent backup? When I sort by date, the folder shows one date, though the files inside show a different date? Is there a way to quickly check the drives to find which is the most recent?
    Thanks.

    the folder modification date isn't reliable, as is only tells of changed in the folder, but not in subfolders. there is no efficient way. I however highly suggest Time capsule, it is WAY easier and you can ask it not to sync the System data and/or applications, so it would prevent this hassle.
    You could try this: go to the first drive, type different letters, like a for instance, and see which file is the most recent document/folder.
    do the same thing on the other drives and compare.

  • How do I determine which applications I have which will work with OSX Yosemite?

    I am Currently running OSX 10.6.8, and am considering upgrading to OSX Yosemite.  I would like to know how to determine which applications I have which will not work with OSX Yosemite? 

    Click here and check the table.
    (123205)

  • 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.

  • How does DIADEM import TDMS files? How gets every channel his number and groupindex? How can I determine which channel has which groupindex and number?

    I store different channels in a TDMS file.
    I like to have a time channel at the first position with group index 1 and number 1.
    When I read the TDMS file with DIADEM the time channel (Float64) is on a differernt position, and the channels are not sorted alphabetically.
    Here are my questions:
    How does DIADEM import TDMS files?
    How gets every channel his number and groupindex?
    How can I determine which channel has which groupindex and number?
    Best regards
    Joerg

    Hi Jörg,
    i suppose that you´re programme whose create the *.tdms file is writing on false position. Try to create datas with timechannel on first indes in diadem, then save it and then open it again. you see that all is correct. So please tell me what programm in what version do you use and please attache it here.
    Did you use the library for creating *.tdms files like in the link ?
    http://zone.ni.com/devzone/cda/tut/p/id/6471
    Here you find the gtdms_8.x.zip - when you extract it and opened the *.llb you find vi´s for all functions e.g. writing 2d array of strings to *.tdms file
    when you open the subvi´s then you see how created and writing datas/structure to *.tdms files. Because *.tdms is binary you can´t see structure with open it in editor.
    When you don´t have Labview you can use the 30 days test of current version 8.5 under following link
    german version download link
    https://lumen.ni.com/nicif/d/lveval/content.xhtml
    english version download link
    https://lumen.ni.com/nicif/us/lveval/content.xhtml
    Hope it helps
    Best Regards

  • 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 find which users has used external scripting

    I want to find out the users who used the scripting for doing any mass changes activity.

    Hi Murphy;
    Please check which user has which forms open? and Re: how to determine which forms are currently open?
    Hope it helps you in your issue
    Regard
    Helios

  • 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

  • [svn:fx-trunk] 7073: When looking around a tab group to determine which object to focus on, not only should the object be selected, but it should also be enabled and visible.

    Revision: 7073
    Author:   [email protected]
    Date:     2009-05-19 08:27:59 -0700 (Tue, 19 May 2009)
    Log Message:
    When looking around a tab group to determine which object to focus on, not only should the object be selected, but it should also be enabled and visible.
    QA Notes:
    Doc Notes:
    Bugs: SDK-19717
    Reviewers: Alex
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-19717
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/framework/src/mx/managers/FocusManager.as

    Revision: 7073
    Author:   [email protected]
    Date:     2009-05-19 08:27:59 -0700 (Tue, 19 May 2009)
    Log Message:
    When looking around a tab group to determine which object to focus on, not only should the object be selected, but it should also be enabled and visible.
    QA Notes:
    Doc Notes:
    Bugs: SDK-19717
    Reviewers: Alex
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-19717
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/framework/src/mx/managers/FocusManager.as

  • 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 start a application with a login window?

    hi there
    does anyone have any idea on how to start an application with a login window? a login window is the first frame or window to be displayed when an application starts running. and only correct login id and password have been entered the real application will start. any sample out there? thank you.

    You can start a new thread by making a thread object and passing it an implementation of a runnable object. Runnable has just one method, public void run(), this is was gets executed in a second thread. perhaps the code you would use would look something like this.
    <code>
    // set up thread for login window
    new Thread(new Runnable() {
    public void run() {
    // construct your login window here
    // when you are done processing the
    // password....
    if(goodPassword) {
    authorized = true; // a global variable
    notifyAll(); // don't forget this
    else {
    System.exit(42);
    }).start();
    // control does not stop this code gets executed while
    // the above thread is running.
    // Set up main program here. This is done in the
    // backround.
    while(!authorized) {
    synchronized(this)
    { wait(50); }
    // now when the user logs in this frame pops
    // up real quick.
    myFrame.setVisible(true);
    </code>
    Hope you can figure it out.. good luck :)

  • 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.

Maybe you are looking for

  • Can not transfer multiple photos to camera roll

    When I try to transfer more than one photo to the camera roll the app crashes. This is extremely annoying, as I have just finished editing hundreds of images. I am finding anything regarding transferring images on an iPad/iPhone very long winded and

  • Is there any way to setup server side deferred delivery in Exchange 2013?

    We are utilizing 3rd party software to generate reports and email results.  Unfortunately, the software cannot be configured to execute at a specific time, date only.  This means that some reports are being processed and delivered at 12:00 am.  For b

  • Decode

    Hello, Below is a query To note number of employees hired by year...If I want the format to look like No of employees (Total) Hired in 1996 Hired in 1997 Hired in 1998 Hired in 1999 XXX 10 28 23 18 What is the best approach if I was to use Decode fun

  • Withholding tax-"minimum-maximum amount" & accumulation setting

    Dear FI experts, as the TDS rate changed in Punjab, my client's requirement is,, if they are posting an invoice with amount more than 20000 then tax to withheld, or it will be withheld if more than Rs 50000 transaction is made in a fiscal year. pleas

  • JasperReport with chart in xml?

    Hi, I am using jasperreports 1.0 to create reports in my application. Some reports has charts. I'd like the legend stay of the right side of the chart instead in botton area. How can I determine the legend position in my xml file? I am not using java