Re: Computing for Outlook Express in VB.




"Mike Williams" <Mike@xxxxxxxxxxxxxxxxx> wrote in message
news:dgpern$e5d$1@xxxxxxxxxxxxxxxxxxxxxxx


Certainly. The VB Sendkeys function is designed for just such a purpose. It
doesn't work very
well for lots of things though, and I couldn't get it to work properly for
Ctrl S. However, all
is not lost. You can use the keyboard event API to get at the keyboard from
a slightly lower
level, and that works fine. For starters, try the following code. It
obviously needs some more
work, but it will get you started. As it stands it sends CtrlS to whatever
window happens to be
the active window, at the rate of one per minute. Later you will probably
want to change it so
that it detects the current active window and only sends CtrlS if it is an
Outlook Express new
message window. Also, you'll propably want to hide the VB Form, or perhaps
write the code in a
VB project that does not use a Form (in which case you'll need to use the
various API Timer
functions instead of the VB Timer Control). Anyway, paste the following code
into a VB Form
containing a Timer Control and run the program. Then start a new Outlook
Express message and
start writing your text. You should find that Outlook Express saves the
message every minute,
under control of the VB Timer code.

Mike

Option Explicit
Private Const VK_CONTROL = &H11
Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Sub Form_Load()
Timer1.Interval = 60000 ' approx 1 minute
End Sub

Private Sub Timer1_Timer()
Call keybd_event(VK_CONTROL, 0, 0, 0) ' press Ctrl key
Call keybd_event(Asc("S"), 0, 0, 0) ' press S key
Call keybd_event(Asc("S"), 0, 2, 0) ' press s key
Call keybd_event(VK_CONTROL, 0, 2, 0) ' release Ctrl key
Caption = Val(Caption) + 1
End Sub





> Oops. Slight mistake in the comments in the code I posted. The correct
> version is:
>
> Call keybd_event(VK_CONTROL, 0, 0, 0) ' press Ctrl key
> Call keybd_event(Asc("S"), 0, 0, 0) ' press S key
> Call keybd_event(Asc("S"), 0, 2, 0) ' release S key (I said press before)
> Call keybd_event(VK_CONTROL, 0, 2, 0) ' release Ctrl key
>
> Also, the line "Caption = Val(Caption) + 1" is only there for test
purposes.
> You should of course remove it.

Hello Mike,

Many thanks for this mighty awesome piece of code. I reckoned that I am an
intermediate level VB programmer but if I say this code snippet is beyond my
capabilities then you might insist I downgrade my perceived status.
Let me copy and paste code and get it working and post to this NG to let you
know how I get on but it may take longer or much longer than the blistering
pace you work at.
I'm a humble physicist. I love programming even if I proceed at the speed of
a tortoise.

:)

Peter Nolan.
Dubin.


.



Relevant Pages

  • Re: Computing for Outlook Express in VB.
    ... well for lots of things though, and I couldn't get it to work properly for Ctrl S. However, all ... the active window, at the rate of one per minute. ... containing a Timer Control and run the program. ... Private Sub Timer1_Timer ...
    (comp.lang.basic.visual.misc)
  • Re: CB_SETTOPINDEX and Combobox
    ... to add a timer control to the form - I've never used one before. ... Private Sub Timer1_Timer ... Private Const CB_SETTOPINDEX As Long = &H15C ... Public Function cbo_set_topindex ...
    (microsoft.public.vb.general.discussion)
  • Re: Launch a window that stays topmost but doesnt steal focus
    ... they choose to click--thus it shouldn't become the active window and take ... without interrupting what they are doing by stealing the focus. ... simply drag a timer control from toolbox then ... Protected Overrides ReadOnly Property ShowWithoutActivation() As ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Launch a window that stays topmost but doesnt steal focus
    ... they choose to click--thus it shouldn't become the active window and take ... display on top as a little popup. ... simply drag a timer control from toolbox then ... End Sub ...
    (microsoft.public.dotnet.languages.vb)
  • Memory problem with images
    ... I'm developing a ppc application that receives images from a url and ... periodically displays them in a picturebox (I use a timer control). ... private sub tickhandles myTimer.tick ...
    (microsoft.public.dotnet.framework.compactframework)