VB5.0 Sendkey function to a Dos program

How do i set sendkeys in Visual Basic 5 on a DOS program that requires

Page 1 of 1

8 Replies - 9960 Views - Last Post: 25 January 2007 - 01:47 PM Rate Topic: -----

#1 arkh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 29-December 06

VB5.0 Sendkey function to a Dos program

Posted 29 December 2006 - 01:36 PM

I'm a Molecular biology major trying to do some simple bioinformatics using Visual Basic 5. /:(

Purpose: Is to do DNA sequence alignments. I have a large list of DNA sequence data, and one template DNA sequence file (all of these are in txt). I need to align these sequences individually.

Good news: EMBOSS, an online service, makes availiable for download a program (called WATER) that can do such alignments.
Bad news: Its a DOS program (originally for UNIX) and not automated for my large list of DNA sequences, meaning i have to do it one by one.

Online tutorials have helped me create File and Directory lists, and i've learned how to launch WATER from a Visual Basic program.

My problem: after launch, WATER asks for certain inputs in DOS (sequence A, sequence B, etc etc etc). There are about 5 inputs that i have to enter. I need to program VB5 to automatically put these inputs in EMBOSS for me.

I have figured out i need to use 'sendkeys' but when i run my VB program it launchs WATER, but does not input my sendkeys. I've tried <Sendkeys "test"> as a test, but WATER just loads and waits for me to enter text.

Ultimately, i want to be able to cycle through my entire list of sequences. I figure i need to link sendkey to my list of sequences, but first i need to get my sendkeys working.

Can anyone please help????????

Is This A Good Question/Topic? 0
  • +

Replies To: VB5.0 Sendkey function to a Dos program

#2 KeyWiz  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 439
  • Joined: 26-October 06

Re: VB5.0 Sendkey function to a Dos program

Posted 29 December 2006 - 01:52 PM

The only way this CAN work is if you send the info to a file which the DOS program can read from, there is no way I know to send info From a Windows invironment directly into a DOS program.

Quote

From MSDN Library

Note You can't use SendKeys to send keystrokes to an application that is not designed to run in Microsoft Windows.

Was This Post Helpful? 0
  • +
  • -

#3 gregoryH  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 60
  • View blog
  • Posts: 656
  • Joined: 04-October 06

Re: VB5.0 Sendkey function to a Dos program

Posted 29 December 2006 - 02:34 PM

View PostKeyWiz, on 29 Dec, 2006 - 01:52 PM, said:

The only way this CAN work is if you send the info to a file which the DOS program can read from, there is no way I know to send info From a Windows invironment directly into a DOS program.

Quote

From MSDN Library

Note You can't use SendKeys to send keystrokes to an application that is not designed to run in Microsoft Windows.

You can try intercepting the DOS window Input and output handles, then you can interact with your program.

See here
Was This Post Helpful? 0
  • +
  • -

#4 KeyWiz  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 439
  • Joined: 26-October 06

Re: VB5.0 Sendkey function to a Dos program

Posted 29 December 2006 - 05:28 PM

View PostgregoryH, on 29 Dec, 2006 - 02:34 PM, said:

View PostKeyWiz, on 29 Dec, 2006 - 01:52 PM, said:

The only way this CAN work is if you send the info to a file which the DOS program can read from, there is no way I know to send info From a Windows invironment directly into a DOS program.

Quote

From MSDN Library

Note You can't use SendKeys to send keystrokes to an application that is not designed to run in Microsoft Windows.

You can try intercepting the DOS window Input and output handles, then you can interact with your program.

See here


This code is a C++ not VB AND if you go through the whole thing you find
Requirements
Client Requires Windows Vista, Windows XP, Windows 2000 Professional, or Windows NT Workstation 3.1 and later. 
Server Requires Windows Server "Longhorn", Windows Server 2003, Windows 2000 Server, or Windows NT Server 3.1 and later. 
Header Declared in Winbase.h; include Windows.h.
 



Again, this cannot be accomplished USING DOS.



FYI a DOS WINDOW can have it's handles controlled, but this will not give you access to the program running WITHIN the DOS window.
Was This Post Helpful? 0
  • +
  • -

#5 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: VB5.0 Sendkey function to a Dos program

Posted 29 December 2006 - 08:08 PM

Quote

I have figured out i need to use 'sendkeys' but when i run my VB program it launchs WATER, but does not input my sendkeys. I've tried <Sendkeys "test"> as a test, but WATER just loads and waits for me to enter text.

Did you try giving the "WATER" Application Focus before you used SendKeys?

If you didn't then you'll end up simulating keystrokes to the VB App itself.
Was This Post Helpful? 0
  • +
  • -

#6 m2s87  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: VB5.0 Sendkey function to a Dos program

Posted 30 December 2006 - 05:55 AM

There is always a superuser way, a la taking full control of your computer. Just recently i thought i should add a tutorial on that. But decided not to, because some would be able to do bad things with that. :ph34r:

I sometimes use this for an example, if people say something is totally unbreakable by humans. Actually this would even make (Office) VBA environment look like real programming environment. :blink:

So if you make a class module called SUPERUSER, and add some subclasses like mouse, keyboard, screen, external devices, extra net, intra net, internet... and some procedures in them, do remember that vb 7</vba has a class code completion, so even some 9 year old kid would be able to write

dim x as new SUPERUSER

sub main()
	x.mouse.visible=false
	x.keyboard.ignore_input=true
	x.screen.primary_layer.background=colur.blue
	x.screen.primary_layer.foreground=colur.red
	x.screen.primary_layer.print="Your F'd"
end sub

'About the same to win critical error in 98 :P

But as you needed only 1 part, x.keyboard, then it would be something like - exploit the following API:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Hope it helps :D
Was This Post Helpful? 0
  • +
  • -

#7 KeyWiz  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 439
  • Joined: 26-October 06

Re: VB5.0 Sendkey function to a Dos program

Posted 30 December 2006 - 11:10 AM

View Postm2s87, on 30 Dec, 2006 - 05:55 AM, said:

There is always a superuser way, a la taking full control of your computer. Just recently i thought i should add a tutorial on that. But decided not to, because some would be able to do bad things with that. :ph34r:

I sometimes use this for an example, if people say something is totally unbreakable by humans. Actually this would even make (Office) VBA environment look like real programming environment. :blink:

So if you make a class module called SUPERUSER, and add some subclasses like mouse, keyboard, screen, external devices, extra net, intra net, internet... and some procedures in them, do remember that vb 7</vba has a class code completion, so even some 9 year old kid would be able to write

dim x as new SUPERUSER

sub main()
	x.mouse.visible=false
	x.keyboard.ignore_input=true
	x.screen.primary_layer.background=colur.blue
	x.screen.primary_layer.foreground=colur.red
	x.screen.primary_layer.print="Your F'd"
end sub

'About the same to win critical error in 98 :P

But as you needed only 1 part, x.keyboard, then it would be something like - exploit the following API:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Hope it helps :D

I am curious how you believe this will allow input to a DOS program running in a Windows Dos Window? He dosen't say he has the ability to rewrite the DOS program. He is trying to make a DOS Program accept Keystokes from within a Windows application. You cannot give FOCUS to a DOS PROGRAM, you can give FOCUS to a DOS WINDOW, but this is not controlling the DOS program, it is simply creating a compatible environment for the DOS program to run within.
Was This Post Helpful? 0
  • +
  • -

#8 m2s87  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: VB5.0 Sendkey function to a Dos program

Posted 30 December 2006 - 04:07 PM

Quote

I am curious how you believe this will allow input to a DOS program running in a Windows Dos Window? He dosen't say he has the ability to rewrite the DOS program. He is trying to make a DOS Program accept Keystokes from within a Windows application. You cannot give FOCUS to a DOS PROGRAM, you can give FOCUS to a DOS WINDOW, but this is not controlling the DOS program, it is simply creating a compatible environment for the DOS program to run within.


Are you wondering HOTO write values to a current running application (with basic)?
As you noted you where with it back in 77, and you haven't learned that?

Actually i meant by superuser class, that program imitates input devises, so you actually would see mouse moving in the screen clicking start, run; typing in "cmd" +pressing enter, running his program with set values entering them 1 by 1. (and yes he would not be able to use keyboard or mouse at the time[actually he even would, but it is easier that way])

If i have a bit more time, and nothing better to do, i will write a tutorial on that :P
Was This Post Helpful? 0
  • +
  • -

#9 carpenter131  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-January 07

Re: VB5.0 Sendkey function to a Dos program

Posted 25 January 2007 - 01:47 PM

What about just writing the alignment code in VB? How similar are your sequences. If they are not very similar then take the BLAST approach.
If they are close then try Smith-Waterman method.

A VBA version of the Smith-Waterman method can be found at:

webpages.ull.es/users/jmglezh/Smith-Waterman.htm

The down side is it is not the best design.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1