LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I have LabWindow send keyboard commands/key strokes, to another windows program

I need to have my LabWindows program control another program by acting as the keyboard. I was able to create a window script file, which works, but LabWindows wont execute the script. Any Suggestions?
0 Kudos
Message 1 of 6
(5,047 Views)
I used to have the similar project time ago in CVI. But didn't succeed.
I can't help you, but may be you can help me.
I'm interested in the way you write such a window script file wich can act

and control the behaviour of a prgram.
Can you send me a sample script ?
Thanks for help,
--
Fred.
0 Kudos
Message 2 of 6
(5,047 Views)
I just started using data socket on a local machine. This has givin me total control from one app to another. In the client app you have a callback that excepts the keys strokes and acts on them.
Kenny
Message 3 of 6
(5,047 Views)
Were you able get your LabWindows program to control another program?
I'm trying to use LabView to pass data to the text boxes in another Windows application (i.e., remote control another application).
I'll take even take a "yes" or "won't work" answer if you don't have the time.

Thanks, tim.svoboda@teccor.com
0 Kudos
Message 4 of 6
(5,047 Views)
Hi, I'm trying to code in Labview to read some text from a file and pass it to the text boax in another program. Can someone provide some tips or code? Thanks. My email: cchiong@celestica.com
0 Kudos
Message 5 of 6
(4,590 Views)

Hi! 

 

This is what I did to send keyboard commands to another windows program:

 

//==================================================

#include <windows.h>
#include <utility.h>
#include <ansi_c.h>
#include <cvirte.h>    
#include <userint.h>

 

#define ALT_Key  0x12
#define A_Key    0x41
#define C_Key    0x43
#define E_Key    0x45
#define F_Key    0x46
#define X_Key    0x58

 

 

 

int CVICALLBACK LaunchExternalWinApp (int panel, int control, int event,
      void *callbackData, int eventData1, int eventData2)
{
      int app_handle;

 

   switch (event)
   {
      case EVENT_COMMIT:

         LaunchExecutableEx
                  ("notepad.EXE c:\\your_dir\\test.txt",
                   LE_SHOWNORMAL, &app_handle);
        
         Delay(0.1);     //give time for the program to start
        
         // The launched program is focused automatically.
        
               HitKey(ALT_Key);
               HitKey(E_Key);
               HitKey(A_Key);
               HitKey(ALT_Key);
               HitKey(E_Key);
               HitKey(C_Key);
               HitKey(ALT_Key);
               HitKey(F_Key);
               HitKey(X_Key); 
         
      break;
   }
   return 0;
}

 

 

void HitKey(int key_code)
{
   /*
     // keybd_event() is defined in "Windows.h" header.
    
     NOTE: Even if I use 0 for the "bScanCode" parameter in keybd_event(),
           it still works for Windows XP.   
   */
  
   // simulate a key press
   keybd_event( key_code, 0,
                KEYEVENTF_EXTENDEDKEY | 0, 0 );
               
   // simulate a key release
   keybd_event( key_code, 0,
                KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
               
}

 

 

//====================================================

 

 

You can find more info at http://www.codeproject.com/KB/system/keyboard.aspx

 

 

Message Edited by dcl9000 on 12-16-2008 03:52 PM
0 Kudos
Message 6 of 6
(4,542 Views)