msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Blocking User Input

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB WinAPI
Author Message
Tim Christopher



Joined: 04 Oct 2007
Posts: 12

PostPosted: Sun Jan 13, 2008 4:25 am    Post subject: Blocking User Input Reply with quote

Hi everyone,

I am going to use SENDKEYS in my VB6 application (when a command button is
clicked) to open and then execute some keyboard shortcuts in another
application BUT I want the user of the computer to not be able to affect the
running of SENDKEYS until it has completed. It is very possible that the user
will try to use the keyboard/mouse during this time and I want their input to
be blocked. Is there any way I can do this? Any chance of a small sample code?

Thanks in advance.

Tim Christopher

Archived from group: microsoft>public>vb>winapi
Back to top
View user's profile Send private message
MikeD



Joined: 04 Oct 2007
Posts: 3348

PostPosted: Sun Jan 13, 2008 6:00 pm    Post subject: Re: Blocking User Input Reply with quote

"Tim Christopher" wrote in
message @microsoft.com...
> Hi everyone,
>
> I am going to use SENDKEYS in my VB6 application (when a command button is
> clicked) to open and then execute some keyboard shortcuts in another
> application BUT I want the user of the computer to not be able to affect
> the
> running of SENDKEYS until it has completed. It is very possible that the
> user
> will try to use the keyboard/mouse during this time and I want their input
> to
> be blocked. Is there any way I can do this? Any chance of a small sample
> code?
>


I'd look for a different method to do whatever it is you need to do in this
other app. SendKeys can be very unreliable.

What is this other app and what exactly do you need to have it do?

--
Mike
Microsoft MVP Visual Basic
Back to top
View user's profile Send private message
Tim Christopher



Joined: 04 Oct 2007
Posts: 12

PostPosted: Mon Jan 14, 2008 4:23 am    Post subject: Re: Blocking User Input Reply with quote

The other application opens up its files in an Excel like grid. Rows may
represent employees, columns things like age/name/hours worked etc. I have
tried to open these files through Excel but the data comes out with jibberish
(boxes,picture fonts,Symbol fonts etc.). The only way to get the data into a
legible format is to select a menu item from that application that creates a
CSV file format. I wanted to be able to simulate this process from a VB
application I am writing (open application using shell function then
executing menu item). I tried posting this in the 'general.discussion' and
SENDKEYS was a suggestion. But my experience with SENDKEYS in the past is
that while it is running, the user of the PC it is running on must not use
the keyboard/mouse until SENDKEYS has finished. I then read somewhere on
Google about blocking user input using an API call and thought that maybe
this would work. Any ideas would be greatly appreciated.

Tim Christopher.

"MikeD" wrote:

>
> "Tim Christopher" wrote in
> message @microsoft.com...
> > Hi everyone,
> >
> > I am going to use SENDKEYS in my VB6 application (when a command button is
> > clicked) to open and then execute some keyboard shortcuts in another
> > application BUT I want the user of the computer to not be able to affect
> > the
> > running of SENDKEYS until it has completed. It is very possible that the
> > user
> > will try to use the keyboard/mouse during this time and I want their input
> > to
> > be blocked. Is there any way I can do this? Any chance of a small sample
> > code?
> >
>
>
> I'd look for a different method to do whatever it is you need to do in this
> other app. SendKeys can be very unreliable.
>
> What is this other app and what exactly do you need to have it do?
>
> --
> Mike
> Microsoft MVP Visual Basic
>
>
>
Back to top
View user's profile Send private message
MikeD



Joined: 04 Oct 2007
Posts: 3348

PostPosted: Mon Jan 14, 2008 1:05 pm    Post subject: Re: Blocking User Input Reply with quote

"Tim Christopher" wrote in
message @microsoft.com...
> The other application opens up its files in an Excel like grid. Rows may
> represent employees, columns things like age/name/hours worked etc. I have
> tried to open these files through Excel but the data comes out with
> jibberish
> (boxes,picture fonts,Symbol fonts etc.). The only way to get the data into
> a
> legible format is to select a menu item from that application that creates
> a
> CSV file format. I wanted to be able to simulate this process from a VB
> application I am writing (open application using shell function then
> executing menu item). I tried posting this in the 'general.discussion' and
> SENDKEYS was a suggestion. But my experience with SENDKEYS in the past is
> that while it is running, the user of the PC it is running on must not use
> the keyboard/mouse until SENDKEYS has finished. I then read somewhere on
> Google about blocking user input using an API call and thought that maybe
> this would work. Any ideas would be greatly appreciated.


Sounds like these files are a proprietary format. If that's the case, then
it's likely that only this other app can read them and create the CSV file
that you need.

The problem with SendKeys is that it send keystrokes to whatever the active
application is. It doesn't care what that app is and there's no way to send
keystrokes JUST to a specific app (at least that I know of). Even if the
user doesn't type anything or use the mouse, lots can go wrong. Just for
examples, some other app running in the background could pop up a window,
during the export there could be some error (bad file name, bad or
non-existant file or directory), etc., etc.

Also, how is your app going to know that the export was successful? Mere
existance of the CSV file does not necessarily indicate that.

IMO, you should not automate this. It's just another step in the process
that the user needs to perform.

--
Mike
Microsoft MVP Visual Basic
Back to top
View user's profile Send private message
Thorsten Albers



Joined: 04 Oct 2007
Posts: 756

PostPosted: Mon Jan 14, 2008 10:22 am    Post subject: Re: Blocking User Input Reply with quote

Tim Christopher schrieb im
Beitrag ...
> The other application opens up its files in an Excel like grid. Rows may
> represent employees, columns things like age/name/hours worked etc. I
have
> tried to open these files through Excel but the data comes out with
jibberish
> (boxes,picture fonts,Symbol fonts etc.). The only way to get the data
into a
> legible format is to select a menu item from that application that
creates a
> CSV file format. I wanted to be able to simulate this process from a VB
> application I am writing (open application using shell function then
> executing menu item). I tried posting this in the 'general.discussion'
and
> SENDKEYS was a suggestion. But my experience with SENDKEYS in the past is

> that while it is running, the user of the PC it is running on must not
use
> the keyboard/mouse until SENDKEYS has finished. I then read somewhere on
> Google about blocking user input using an API call and thought that maybe

> this would work. Any ideas would be greatly appreciated.

In general on 32 bit Windows versions you should use keybd_event (Windows
API) instead of SendKeys, and on Windows versions with NT technology
(NT/2K/XP etc.) you should use SendInput() (Windows API).
But what you want to do usually is solved best by DDE or COM. You first
should check, if the application in question may be automated by DDE or
COM. While COM support of 'smaller' applications is unlikely usually there
is a good chance that the application supports DDE. For more information on
DDE see the VB online documentation as well as the documentation on the
application in question.

--
----------------------------------------------------------------------
THORSTEN ALBERS Universität Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------
Back to top
View user's profile Send private message
Michael C



Joined: 04 Oct 2007
Posts: 335

PostPosted: Tue Jan 15, 2008 6:59 pm    Post subject: Re: Blocking User Input Reply with quote

"MikeD" wrote in message @TK2MSFTNGP04.phx.gbl...
> The problem with SendKeys is that it send keystrokes to whatever the
> active application is. It doesn't care what that app is and there's no
> way to send keystrokes JUST to a specific app (at least that I know of).

The SendMessage api should do it.

> IMO, you should not automate this. It's just another step in the process
> that the user needs to perform.

I agree.

Michael
Back to top
View user's profile Send private message
MikeD



Joined: 04 Oct 2007
Posts: 3348

PostPosted: Tue Jan 15, 2008 10:59 am    Post subject: Re: Blocking User Input Reply with quote

"Michael C" wrote in message @TK2MSFTNGP02.phx.gbl...
> "MikeD" wrote in message
> @TK2MSFTNGP04.phx.gbl...
>> The problem with SendKeys is that it send keystrokes to whatever the
>> active application is. It doesn't care what that app is and there's no
>> way to send keystrokes JUST to a specific app (at least that I know of).
>
> The SendMessage api should do it.

I actually meant using SendKeys, but you're right, SendMessage or other
Win32API should be able to.

--
Mike
Microsoft MVP Visual Basic

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB WinAPI All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group