Results 1 to 8 of 8
  1. #1

    how to detect key presses?

    Does anyone have a good function or bit of code for detecting key presses ? (I've searched in this forum and WR user guide but not come up with anything...)

  2. #2

    Re: how to detect key presses?

    Oops - I should have looked in Merc's knowledge base first. There is stuff in there. I will try it out and update here after that...

  3. #3

    Re: how to detect key presses?

    Yes the stuff (function = GetKeyStatus) from Merc knowledge base seems to work fine.

    Does anyone have the encoded list of all virtual key definitions in TSL - ie defining all the key numbers as VK_xxxx ..., eg

    public VK_END = 35;
    etc ?

  4. #4

    Re: how to detect key presses?

    hey stephen.. plz can u tell me how to search the knowledge base?? i'm lookn for info on key presses too...

  5. #5

    Re: how to detect key presses?

    Go to Mercury Support site. Click "Knowledge Base." Go from there.

  6. #6

    Re: how to detect key presses?

    I have had to make an improvement to this function now, but couldn't paste the code. Did I see there are some "code markers" that I should be using to paste sample code? How do I do it please?
    (btw - I did just read/skim the READ BEFORE POSTING - expecting to find this answer, but couldn't find it!)

  7. #7

    Re: how to detect key presses?

    Hi Stephen,
    To paste code in use the below replacing curly brackets with square ones.


    Paste Code

    Richard Hunter

  8. #8

    Re: how to detect key presses?

    (Thanks Richard - so here's the updated function now I know how to paste the code!)

    Having used the GetKeyStatus function for detecting key presses for a few days now, I have found that it periodically gives an error "window {active:1} is not found" - presumably because the "active window" is in a state of flux. Therefore I have improved the function by adding a check that the window exists just before it executes the statements which cause this error. It is still possible to get this error (I have had it once since) but I expect this will reduce its frequency a lot (seems to have done so)... (if anyone can suggest how to cure it completely please tell me!).

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">function GetKeyStatus(in vKey)
    auto pid, thread_id, win_desc, hWnd, KeyState, win_log_name, win_full_desc, focused_obj_desc;

    win_desc = &quot;{active:1}&quot;;
    if (win_exists(win_desc)==0)
    win_get_desc(win_desc, &quot;&quot;, &quot;&quot;, &quot;&quot;, win_full_desc);
    GUI_map_get_logical_name( win_full_desc, &quot;&quot;, win_log_name, &quot;bla&quot;
    win_get_info(win_desc, &quot;handle&quot;, hWnd);

    pid = GetWindowThreadProcessId(hWnd, NULL);
    KeyState=GetKeyState (vKey);

    if (KeyState &lt; 0)
    return(0); # Key is pressed
    return (1); # Key is not pressed
    return (-1); # No active window found, so cannot determine key state
    } </pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 05:37 PM.

Copyright BetaSoft Inc.