Button Keypress 'd


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Button Keypress 'd

  1. #1
    Join Date
    Mar 2008
    Posts
    10

    Button Keypress 'd

    hi,

    im using this code to simulate a leftmousetclick to a particular window (button) using an API

    SendMessageLong(BtnHwnd, WM_KEYDOWN, VK_SPACE, 0&)

    It does what is supposed to do. i didnt send the the Const WM_KEYUP = &H101 so that the button remains pressed.

    My problem is when i move the target window or just click or type anything on the form of the target window it released the mouse left click. I even tried to disable that window but it still released the button when it move.

    is there a way so i can lock that window so it wont release its keypress hold on the button? or do i have to use a timer control then keep sending that message to that window???

    tnx

  2. #2
    Join Date
    Jan 2009
    Posts
    10
    try to put a mouse_left_button _flag. and tell it to your program that if the 1st press encountered, mouse_left_button _flag = true. Then the keypress to your target will be like this;

    if mouse_left_button _flag then
    <nothing>
    else
    <release keypress>
    endif

    and if the 2nd press encountered to your mouse, mouse_left_button _flag will be false.

    I hope I get it right.

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Is the target window a part of the app you are developing, or is it an external window in another app?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  4. #4
    Join Date
    Mar 2008
    Posts
    10
    Quote Originally Posted by Hack View Post
    Is the target window a part of the app you are developing, or is it an external window in another app?
    its in another application

    its something like this

    Private Sub cmdbutton_Click()
    Select Case cmdbutton.Caption
    Case Is = "LOCK BUTTON"
    cmdbutton.Caption = "UNLOCK BUTTON"
    Call SendMessageLong(BtnHwnd, WM_KEYDOWN, VK_SPACE, 0&)
    Case Is = "UNLOCK BUTTON"
    cmdbutton.Caption = "LOCK BUTTON"
    frmMAIN.cmdbutton.Caption = "LOCK BUTTON"
    Call SendMessageLong(BtnHwnd, WM_KEYUP, VK_SPACE, 0&)
    End Select
    End Sub
    it does press the button on another app but when the target application moves (or it recieves another message i think????) the keypress on the button gets released.

    I want it to press the button and keep holding it down (keydown) until i say to release it (keyup).
    ???

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Quote Originally Posted by jonah View Post
    I want it to press the button and keep holding it down (keydown) until i say to release it (keyup).
    Why? What are you attempting to achieve by doing this?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  6. #6
    Join Date
    Mar 2008
    Posts
    10
    Quote Originally Posted by Hack View Post
    Why? What are you attempting to achieve by doing this?
    Actually its a Talk Mic Button. I want to lock it on keypress so i wont have to use the mouse to keep it holding it down

    When i send the message

    SendMessageLong(BtnHwnd, WM_KEYDOWN, VK_SPACE, 0&)

    it does hold down the button if i dont send the WM_KEYUP. But it releases the button when the target app moves or when i type something on that app.

Similar Threads

  1. Replies: 7
    Last Post: 07-17-2013, 12:47 AM
  2. Replies: 5
    Last Post: 12-16-2008, 12:02 PM
  3. Pseudocode Problem
    By zobi316 in forum VB Classic
    Replies: 3
    Last Post: 03-10-2008, 08:05 AM
  4. Need help with calculator...
    By 2eXtreme in forum Java
    Replies: 0
    Last Post: 04-05-2006, 08:38 AM
  5. button listener not working
    By DrunkinP in forum Java
    Replies: 0
    Last Post: 03-31-2005, 10:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center