Results 1 to 23 of 23

Thread: Fixed code, still need help tho... SIMULATE REAL KEYBOARD COMMANDS

  1. #1

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Fixed code, still need help tho... SIMULATE REAL KEYBOARD COMMANDS

    Ok, i basically want to send the contents of Text1 to the program defined as Appnum the sending will be done by a timer (every 5 minutes...) where in my code have i gone wrong ?

    VB Code:
    1. Private Appnum As Long
    2. Private Sub Command1_Click()
    3. Appnum = Shell("C:\WINDOWS\notepad.exe")
    4. Timer2.Enabled = True
    5. End Sub
    6.  
    7. Private Sub Timer2_Timer()
    8. Timer1.Enabled = True
    9. Timer2.Enabled = False
    10. End Sub
    11.  
    12. Private Sub Timer1_Timer()
    13. AppActivate Appnum
    14. SendKeys (Text1.Text)
    15. End Sub
    Last edited by thegreatone; Dec 25th, 2004 at 05:01 PM.
    Zeegnahtuer?

  2. #2
    Banned
    Join Date
    Dec 2004
    Posts
    174

    Re: More messed Senkeys coding... Help ?

    dont use 2 timers.
    use 1 timer and set its interval to 5000 (5 sex)

  3. #3

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: More messed Senkeys coding... Help ?

    Quote Originally Posted by _visual_basic_
    dont use 2 timers.
    use 1 timer and set its interval to 5000 (5 sex)
    The first timer in that codee is their so that it activates the second timer...

    I know the timer work, i don't need help on that, its just the problems with the sendkeys...
    Zeegnahtuer?

  4. #4
    Banned
    Join Date
    Dec 2004
    Posts
    174

    Re: More messed Senkeys coding... Help ?

    sendkeys "{" & text1.text & "}"

  5. #5

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: More messed Senkeys coding... Help ?

    Quote Originally Posted by _visual_basic_
    sendkeys "{" & text1.text & "}"
    Still no luck
    Thanks for helpin tho
    Zeegnahtuer?

  6. #6
    Banned
    Join Date
    Dec 2004
    Posts
    174

    Re: More messed Senkeys coding... Help ?

    i know what the problem is hold on i will post the form soon

  7. #7
    Banned
    Join Date
    Dec 2004
    Posts
    174

    Re: More messed Senkeys coding... Help ?

    fully functional

  8. #8

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: More messed Senkeys coding... Help ?

    Quote Originally Posted by _visual_basic_
    fully functional
    Yay, that does work, BUT, when modified to open another app it DOES send the keys, BUT as the other app ONLY responds to real keyboard shortcuts how do i make it act as if it came from the keyboard ?
    Zeegnahtuer?

  9. #9
    Banned
    Join Date
    Dec 2004
    Posts
    174

    Re: More messed Senkeys coding... Help ?

    to generate a shortcut

    ^ stands for alt so ^A or ^+A im not sure what it was

  10. #10

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: More messed Senkeys coding... Help ?

    Quote Originally Posted by _visual_basic_
    to generate a shortcut

    ^ stands for alt so ^A or ^+A im not sure what it was
    Yeah i know that, i mean it only seems to work from actual key presses not VB simulated ones
    Zeegnahtuer?

  11. #11
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: More messed Senkeys coding... Help ?

    it has to have focus for shortcut keys to work

  12. #12

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: More messed Senkeys coding... Help ?

    Quote Originally Posted by dglienna
    it has to have focus for shortcut keys to work
    Lol, i kno... is there any way to actually simulate the command from the keyboard to the program, as in, when u press a key it sends the same signal as the one runnin down the ps/2 port ?
    Zeegnahtuer?

  13. #13
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: More messed Senkeys coding... Help ?

    you'd have to find out what it was sending before you could send it. try sending all 256 of them to see which one is correct? you could end up getting lucky?

  14. #14

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: More messed Senkeys coding... Help ?

    Quote Originally Posted by dglienna
    you'd have to find out what it was sending before you could send it. try sending all 256 of them to see which one is correct? you could end up getting lucky?
    Lol, that may take some time... if only i could find someone who had already done this..
    Zeegnahtuer?

  15. #15
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Fixed code, still need help tho... SIMULATE REAL KEYBOARD COMMANDS

    Is this what you need, thegreatone?
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim i%
    3.  
    4.     Shell "notepad", vbNormalFocus
    5.     Clipboard.Clear
    6.     With Text1
    7.         For i = 0 To Len(.Text) - 1
    8.             SendKeys Mid(.Text, i + 1, 1)
    9.         Next i
    10.     End With
    11.     SendKeys "^{c}"
    12.     SendKeys "^{v}"
    13.  
    14. End Sub

  16. #16
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Fixed code, still need help tho... SIMULATE REAL KEYBOARD COMMANDS

    i don't think he is talking about notepad. not sure what it is, though

  17. #17
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Fixed code, still need help tho... SIMULATE REAL KEYBOARD COMMANDS

    Quote Originally Posted by dglienna
    i don't think he is talking about notepad. not sure what it is, though
    ... then what would this mean? ...
    VB Code:
    1. Private Appnum As Long
    2. Private Sub Command1_Click()
    3.     Appnum = Shell("C:\WINDOWS\notepad.exe")
    4.     Timer2.Enabled = True
    5. End Sub

  18. #18
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Fixed code, still need help tho... SIMULATE REAL KEYBOARD COMMANDS

    BUT, when modified to open another app it DOES send the keys, BUT as the other app ONLY responds to real keyboard shortcuts how do i make it act as if it came from the keyboard ?

    AND

    ...same signal as the one runnin down the ps/2 port
    I wasn't sure what he meant, either.

  19. #19
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Fixed code, still need help tho... SIMULATE REAL KEYBOARD COMMANDS

    I guess we just have to wait until he responds ...

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

    Re: Fixed code, still need help tho... SIMULATE REAL KEYBOARD COMMANDS

    You can use the keybd_event API to send keypreses or mouseclicks to
    a window that you can make active and focused.

    VB Code:
    1. Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, _
    2. ByVal dwExtraInfo As Long)
    An example at allapi.net

    HTH
    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

  21. #21

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: Fixed code, still need help tho... SIMULATE REAL KEYBOARD COMMANDS

    Sorry i took so long to reply, so far the closest thing to what i am trying to do is posted by robdog, BUT i am still far from acheiving what i am wanting to do.

    Ok, i am really trying to make this understandable, so here goes :

    When you press a key on your keyboard a signal is sent through the wire to the computer, i want a Visual Basic program to be able to simulate that exact thing. This program MUST be able to make the computer think a key is bieng pressed somehow, and the API and sendkeys features do not do this. Am i aiming far too high for a VB program ?
    Zeegnahtuer?

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

    Re: Fixed code, still need help tho... SIMULATE REAL KEYBOARD COMMANDS

    Checkout the example (keyboard animation) for SetKeyboardState API here.
    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

  23. #23

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: Fixed code, still need help tho... SIMULATE REAL KEYBOARD COMMANDS

    The API does ntohing for me, it doesn't even affect the keyboard lights, needless to say, i think this really would work if it was modified, and then i would have exactly what i wanted, so, anyone want to try and make the example coding work for me ?
    Zeegnahtuer?

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