Something about Hardkey

Discussion in 'Questions (Windows Mobile)' started by blackiice, Oct 26, 2007.

  1. blackiice

    blackiice Member

    In a background app,I can use hk.new1("form1",false,true,true) to catch the keypress event of the hardware keys,as we all know.
    in sub hk_HardKeyPressed,I want to catch hk.Key1 pressed,I can wtire this :
    Select hk.KeyPressed
    case hk.Key1
    msgbox("Key1 was pressed")
    ens select
    so,when user pressed key1,he will get a message "key1 was pressed" and the default action assigned to key1(for example :run note.exe) would be canceled,but what I need is,how can I do this like this:
    Select hk.KeyPressed
    case hk.Key1
    if checkbox1.checked=true then
    msgbox("Key1 was pressed")
    (run the default app asigned to key1)
    ens select
  2. Erel

    Erel Administrator Staff Member Licensed User

    You will need to find the applications paths in the registry.
    If I remember correctly you can find them under: LocalMachine\SOFTWARE\Microsoft\Shell\Keys
  3. blackiice

    blackiice Member

    If the hardwarekey was assigned to a .exe file,I can use registry to find what to do, But Sometimes,hardwarekey is not assigned to an application,but be assigned to some "operate" (such as "open Startmenu,press ok button,show SIP,rotate screen" and so on),so we can not found something to shell.
    maybe we need a founction like "hk.DoDefaultAction" or "hk.CancelCatch"(stop catch the keypress event of the hardware keys.)
  4. konisek

    konisek Member Licensed User

    After using HardKeyPressed I cannot move cursor to the left in a textbox while pressing the HW button LEFT. How can I do it?

    Sub hk_HardKeyPressed
    Select hk.KeyPressed
    Case hk.KeyEnter [I]'action while pressing ENTER[/I]
       'do something
    Case hk.KeyLeft [I]'action while pressing LEFT[/I]
       'move cursor to the left
    End select
    End Sub
  5. klaus

    klaus Expert Licensed User

    You can do it that way:
    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]TextBox1.Focus[/SIZE][/FONT]
    FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] TextBox1.SelectionStart>[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/FONT]
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]  TextBox1.SelectionStart=TextBox1.SelectionStart-[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT]
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT]
    Best regards.
  6. konisek

    konisek Member Licensed User

    Super, it works great. I just thought there was a code like
    hk1.KeyPress(asc("A")) 'Writes a
    even for cursor "move left".
    But cannot use it for "move up" or "move down".
    Thanx anyway.
    Last edited: Jun 11, 2010
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice