Key Binding to a Subroutine

Discussion in 'Questions (Windows Mobile)' started by ohkovar, Dec 19, 2008.

  1. ohkovar

    ohkovar Member Licensed User

    Is there a way to bind keys to call a particular subroutine? For instance, I have a login screen when the app starts. I have a special admin password that
    will allow me to bypass the user's password and login (for debugging someone's device). I would like to have a special Ctrl+Shift+A or something similar to automatically call a login subroutine to login me in.

    Thanks in advance!
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can use the door library to do it (the source code is attached):
    Code:
    Sub Globals
        
    'Declare the global variables here.

    End Sub

    Sub App_Start
        Form1.Show
        obj.New1(
    False)
        obj.FromControl(
    "Form1"'Get a reference to the relevant form.
        obj.SetProperty("KeyPreview",True'Setting the KeyPreview property to true will allow the form KeyPress event to handle all key presses.
        keypress.New1(obj.Value,"KeyDown"'Catch the KeyDown event.
    End Sub

    Sub keypress_NewEvent
        obj.Value = keypress.Data
        
    If obj.GetProperty("Control") = True AND obj.GetProperty("Alt") = True AND obj.GetProperty("KeyCode") = "E" Then
            
    Msgbox("Ctrl+Alt+E was pressed.")
        
    End If
    End Sub
     

    Attached Files:

    • 1.sbp
      File size:
      631 bytes
      Views:
      69
  3. ohkovar

    ohkovar Member Licensed User

    Thanks! That's just what I needed.
     
  4. ohkovar

    ohkovar Member Licensed User

    Okay, what is the obj object? I'm getting the following error (runtime error):

    obj.New1(False)
    Object reference not set to an instance of an object.
     
  5. ohkovar

    ohkovar Member Licensed User

    Nevermind..Brain-fart. I got it working.
     
  6. Byak@

    Byak@ Active Member Licensed User

    Erel and what about get keypress event if my form not in forward?my form is minimized.
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    I haven't tried this but I think it will work.
    You can create an array of type Int32 and insert the values of all keys you want to catch. The values (in hexadecimal) are here: Virtual-Key Codes
    You should then pass this array to HardKey.New2.
     
  8. Byak@

    Byak@ Active Member Licensed User

    Erel please show me example.when i do it program catch only cursor buttons.
     
  9. Byak@

    Byak@ Active Member Licensed User

    heh,problem with my AEbutton+.i'm kill it and algoritm work.i catch all buttons?but button "Call" (114) doesnot catch.BUT attached proram(keycode.exe) catch all my buttons.why?
     

    Attached Files:

  10. Erel

    Erel Administrator Staff Member Licensed User

    What is AEbutton+ ?
    It is possible that the Call button is treated differently than the other regular buttons and therefore you will not be able to catch it with HardKey.
     
Loading...
  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