Results 1 to 15 of 15

Thread: Sendkeys alternate?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Posts
    107

    Sendkeys alternate?

    Hi.

    Im using Sendkeys to send keystrokes within my VB app. However, its not too reliable, and skips out on instances. Is there a more reliable, (free) alternate for Sendkeys that can be used in a VB6 app?

    Thanks

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Sendkeys alternate?

    there is an API available for sending keystrokes...just google for that, you will get examples here in VBF
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Sendkeys alternate?

    When using sendkeys, make the wait parameter to True and use Sleep() function to make it more reliable sort of putting a little delay before firing the next sendkeys.

    Sample
    Code:
    Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    
    SendKeys "{F2}", True  'sending F2 keys and wait for the process to finish before firing the next sendkeys
    Sleep 100
    SendKeys "^{C}", True
    
    '... etc etc
    this is some lame tricks if you dont want to use the API sendkeys.

  4. #4
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: Sendkeys alternate?

    Most often the problems with Sendkeys are timing related (as zynder pointed out)

    PS
    MS has guaranteed that VB6 apps would run ok in Vista
    But I am hearing that Sendkeys has problems, and MS does not give a sh....
    So if some kind sole can post a complete alternative module, it would be great.
    Last edited by RobCrombie; May 3rd, 2007 at 12:41 AM.
    Rob C

  5. #5
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068

    Re: Sendkeys alternate?

    Why are you using SendKeys within your own program? What exactly are you doing with it?

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Sendkeys alternate?

    SendKeys is the worst VB function ever made

    Seriously, you can use the keybd_event API to simulate keypresses but it like SendKeys relies upon the receiving object to have the input focus.

    SendMessage and PostMessage APIs are the most reliable and durable functions for sending keypresses or what not.

    SendKeys does not work when trying to send keys to IE7.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: Sendkeys alternate?

    Some sort of spammer i assume? Anyway i know for one in a "Storm.dll" there is a function which is ten times better than SendKeys but i forget what it was.

  8. #8
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068

    Re: Sendkeys alternate?

    Agreed, Sendkeys is awful.

    Especially if you are sending commands to your own program, it is not necessary.

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Sendkeys alternate?

    Maybe its a language issue here. Probably the poster means to send key strokes from within his application to some other destination.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068

    Re: Sendkeys alternate?

    I certainly hope so :|

    Can we get the original poster to help us out and ease our blood pressure yet?

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Posts
    107

    Re: Sendkeys alternate?

    Original poster here.

    Yes, i mucked up with the grammar there. Im trying to get my VB app to send keystrokes to another application. Basically, its a datafeed Im getting in the form of a bunch of invoices. What im trying to do is capture the prices of a certain object from the invoices, and send it to another application.

    There may be other ways ot do it, but i want to use keystrokes, since that is quick in my case, and i will be needing the keystrokes in other areas of this app as well. So any alternate to sendkeys would be much appreciated.

  12. #12
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    403

    Re: Sendkeys alternate?

    Hi style, I recently used sendkeys to control another program from VB6. I got it to work reliably, but only after ZYNDER's suggestion posted above. Add that TRUE word at the end of your string (makes VB6 wait for other program to respond before sending next key) and put loads of sleep delays inbetween sets of keystrokes. I started with sellp 100's, but eventually was able to reduce to sleep 10's - but every program will tend to be different. Unless you are in a big hurry for this thing to work, the longer the delays the better has been my recent experience.

    ca moore

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Sendkeys alternate?

    But with scenerios like using SendKeys and even the keybd_event API you are tieing up your system as you can not disturb the active application.

    If you use SendMessage/PostMessage you can have the automation running in the background while you can continue to work or post here at VBF
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14
    Lively Member
    Join Date
    Mar 2007
    Posts
    111

    Re: Sendkeys alternate?

    i agree with Rob u can use sendmessage or postmessage api

  15. #15
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    403

    Re: Sendkeys alternate?

    Thank you, noted by contributor ca Moore. I am, relative to you folk, a novice at VB but usually I find some waqy to overcome problems (with the help of forum!) albeit not the most elegant.

    CAM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width