LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending Keystrokes to open windows applications

I would like to send the following keystrokes to a windows application:
1234 enter
 
How can I perform this task in CVI?  Do sample programs exist?
 
 
0 Kudos
Message 1 of 10
(5,802 Views)
Hello:
 
It is simple using in SDK of Windows with CVI. At this time I don't find the application that I made some years ago in which I take the control of another application under Windows sending messages of keys.
 
Ahead of time I can comment you that you can solve it with the SDK.
 
Give me some days to locate the example and I send it to you.
 
My English excuses, it is not good as you will be able to realize.
 
Greetings!
0 Kudos
Message 2 of 10
(5,797 Views)

Autoit would be your answer.

 

http://www.autoitscript.com/autoit3/downloads.php

Just include .h, .lib file to your project. Copy dll to your project dir and start calling functions.

Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
Message 3 of 10
(5,786 Views)

I am using CVI (ANSI C) and am having trouble with the .h file.  I receive error messages like the one shown below:

 Iline.c - 20 errors
  "AutoIt3.h"(36,21)   syntax error; found 'identifier' expecting ';'.
  "AutoIt3.h"(39,21)   Redeclaration of 'WINAPI' previously declared at AutoIt3.h:36.
 

Any suggestions?

0 Kudos
Message 4 of 10
(5,767 Views)
TheSpecialist,

Though its not supported by NI, I took a look at that header file. You'll need another #define WINAPI at the top of the file. Once that's there you'll have to comment out one of the functions in order to get it to compile.
Test Engineer - CTA
0 Kudos
Message 5 of 10
(5,717 Views)
I added the WINAPI def and it cleared most of the error messages.  It still does not compile completly.  What examples exist in CVI that can perform keystrokes to a windows app?
0 Kudos
Message 6 of 10
(5,657 Views)
There are not any examples for doing that. However there is a function in CVI called FakeKeystroke that will allow you to send keystrokes. See this thread for more information on using it.

Message Edited by Jon M on 05-29-2007 11:04 AM

Test Engineer - CTA
0 Kudos
Message 7 of 10
(5,640 Views)
I reviewed the example and am having trouble sending the characters.  I have the handle that I would like to send 1234 then enter but am having trouble sending the characters.  I am not familiar with SDK.  Here is my code:
 stat= LaunchExecutableEx("C:\\Program Files\\Honeywell\\ConfigTool\\ConfigTool.exe ",LE_SHOWNORMAL
       ,&CONFIG);
      
        Delay(7); 
    
    iHwnd = FindWindow(NULL, "Start");
    PostMessage(iHwnd, WM_CHAR,49, 1);
    PostMessage(iHwnd, WM_CHAR,50, 1);    
    PostMessage(iHwnd, WM_CHAR,51, 1);    
    PostMessage(iHwnd, WM_CHAR,52, 1);    
    PostMessage(iHwnd, WM_CHAR,13, 1);    
 
The application opens, after 7 seconds the panel in the background loses focus but the characters are not sent.
0 Kudos
Message 8 of 10
(5,625 Views)
TheSpecialist,

As noted on the other thread, you will probably need to send WM_KEYDOWN messages and possibly WM_KEYUP messages as well. I would suggest looking at the MSDN information about Keyboard Input.
Test Engineer - CTA
0 Kudos
Message 9 of 10
(5,605 Views)
I finally figured it out.  Thanks for the help!!

Jon K.

0 Kudos
Message 10 of 10
(5,582 Views)