Keypresses....

Discussion in 'Programming General' started by RawrTo1, Oct 2, 2008.

Keypresses....
  1. Unread #1 - Oct 2, 2008 at 2:09 PM
  2. RawrTo1
    Referrals:
    0

    RawrTo1 Guest

    Keypresses....

    [VB6]

    Okay, Basically i have created a program which works in just the same was a macro.

    The application listens for a key to be pressed before it sends the text which is inside one of the text boxes on the form.

    What i have been trying to do is make it so that the user can define their own button to press to send the macro

    Currently it works if in the code if specify something like vbkeyF1 or vbKeyY or any vbKey code.


    But when i try to put it in a variable it just gives me the run time error '13' blah blah....

    I have tried using a CONST as a variable but they cannot be changed during run time and are fixed variables.


    I Currently use "Private Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal KEY As Long) As Integer" to listen to global keypresses...


    If there is an easier way of being able to listen to keypresses the way i want it please tell me :p


    Thanks if anyone can help... :)
     
  3. Unread #2 - Oct 2, 2008 at 11:28 PM
  4. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Keypresses....

    Give the user a dropdown list of all the keys available for the use of the shortcut.
    Then on the "Click" or "Change" event of the dropdown button set your selected hotkey to a variable using the Asc() function.

    The GetAsyncKeyState is also the recommended API.
    You may also be interested in these:
    http://allapi.mentalis.org/apilist/apilist.php
    http://allapi.mentalis.org/apilist/GetAsyncKeyState.shtml
    http://allapi.mentalis.org/apilist/RegisterHotKey.shtml
    http://allapi.mentalis.org/apilist/UnregisterHotKey.shtml

    I've uploaded a demo project for you to study.
     

    Attached Files:

< Windows Media COM component help? | Listbox help >

Users viewing this thread
1 guest


 
 
Adblock breaks this site