Results 1 to 7 of 7

Thread: N00B Need Help :)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2003
    Location
    At Home
    Posts
    31

    Red face N00B Need Help :)

    I got a problem here i think i want my app to just hit Delete and then Enter ive tried to do like this:

    SendKeys "DEL"
    SendKeys "ENTER"


    ok but when i try it VB just freeze down and cant do anything
    Weeeeeeeeeeeeeeee

  2. #2
    Lively Member Harvester's Avatar
    Join Date
    May 2002
    Location
    God's Country
    Posts
    124

    Braces

    Try it with curly braces

    VB Code:
    1. Call Sendkeys("{ENTER}")
    2. Call Sendkeys("{ESC}")

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2003
    Location
    At Home
    Posts
    31
    The proggy still freeze and dont do what its supposed to do
    Weeeeeeeeeeeeeeee

  4. #4
    Lively Member Harvester's Avatar
    Join Date
    May 2002
    Location
    God's Country
    Posts
    124

    Another way?

    I meant

    VB Code:
    1. Call Sendkeys("{DEL}")
    2. Call Sendkeys("{ENTER}")
    by the way.


    Sorry, I didn't pay close enough attention to your original post... don't know where I came up with Enter ESC...

    What do you want the app to do? I assume you are trying to communicate with another program. There may be a better way. Sendkeys isn't a very reliable thing to use.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2003
    Location
    At Home
    Posts
    31
    yes im trying to communicate with another program i want it like when u click on a item then when start my progg it will sendkeys delete and then enter
    Weeeeeeeeeeeeeeee

  6. #6
    Lively Member Harvester's Avatar
    Join Date
    May 2002
    Location
    God's Country
    Posts
    124

    Potential Explaination

    Here's what I think is happening.

    The form that calls the SendKeys function is the enabled form at the time and thus is also receiving the Sendkeys function which, in turn, recalls the Sendkeys again. You end up in a loop of sorts. Ctrl+Break will break you out of the loop and get you into break mode in VB.

    As far as fixing the issue. I think you're going to need to find the window handle of the window you wish to send the keys to and then use the SetForeGroundWindow function right before you call the sendkeys function to ensure that the keys go to the correct window.

    VB Code:
    1. Public Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long

    Other functions you may need to play with

    VB Code:
    1. Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    2. Public Declare Function GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
    3. Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    Wish I could help more but its lunch time...

  7. #7
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575
    ive never seen SendKeys before, I would have thought you should use the KeyDown or KeyUp event.

    Want to try that out? I think alot of people can help you there much easier

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