Results 1 to 12 of 12

Thread: [RESOLVED] F-Keys, what's up with F10??

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2008
    Posts
    18

    Resolved [RESOLVED] F-Keys, what's up with F10??

    Folks,

    I'm working on a CNC control program, based on a DLL that someone else wrote.
    No problems with that sofar, as i get good support from the writer.

    the problem i do have to tackle is the following:
    I want to acces all the functions by means of softkeys ( the F-Keys at the top of our keyboards )
    when the program starts it shows the Main menu softkeys ( F1-F12), and each F-key has a function assigned to it, some will make the machine move, others will show another menu, or a fileopen/save dialog, depending on the chosen keys.

    all works fine and handy-dandy, except for the F10 key, it seems to be "Sticky", when i press it, the program will not react to any other key, only the F10 key can get it back in "normal state" accepting every key with a function assigned..

    how to "unstick" the F10 after pressing it?.. because pressing F10 now, means no other key will do anything, and that may become dangerous, when the machine is moving and it must be stopped..

    Thanks in advance
    Last edited by Hack; Apr 8th, 2009 at 10:21 AM. Reason: Added RESOLVED to thread title and green resolve checkmark

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: F-Keys, what's up with F10??

    This sounds more like a question for the writer of the program - we have no idea what the problem with the F10 key could be. We don't know what it does nor do we know what it is supposed to do.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2008
    Posts
    18

    Re: F-Keys, what's up with F10??

    it has nothing to do with the dll, i experienced the same problem in another program i wrote, but i could avoid the problem by not assigning any functions to F10.

    it looks like the F10 key acts as some sort of "On/Off" switch, press once to switch on, press again to switch off.

    the code i use :
    Code:
     key = e.KeyValue
            If key > 111 And key < 124 Then
                softkey()
            End If
    
            If e.KeyCode = Keys.Left Then
                cncapi.StartJog(0, -1, 1, 1)
            End If
            If e.KeyCode = Keys.Right Then
                cncapi.StartJog(0, 1, 1, 1)
            End If
    where in the first "if/then" the keyvalue is retrieved, and a sub Softkey is called.

    in this sub softkey, now all i do is display the keyvalue in a textbox, just for testing purposes, but lateron, it will furter call subroutines depending on which Fkey is pressed.

    all the F-keys work fine, but only the F10 key "Stalls" the program, until i hit it again..

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: F-Keys, what's up with F10??

    I put together a quickie test
    vb.net Code:
    1. Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    2.         Select Case e.KeyCode
    3.             Case Keys.F10
    4.                 TextBox1.Text = "F10"
    5.             Case Keys.F5
    6.                 TextBox2.Text = "F5"
    7.             Case Keys.F3
    8.                 TextBox3.Text = "F3"
    9.         End Select
    10. End Sub
    I now know what you mean by "stuck"

    I googled this problem and found a number of people posting the same question and/or reporting the issue.

    I didn't find any resolution however.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2008
    Posts
    18

    Re: F-Keys, what's up with F10??

    well, i found a solution for this problem, although it's a bit "quick'n'dirty"

    if key = 121 ( value of F10) call a sub containing
    Sendkeys.send(121)
    so everytime i press F10 once, the program presses another time..
    this happens before i call the sub with the assigned functions, so a multi-level menu is'nt harmed by this behaviour.
    that seems to work sofar..

  6. #6
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: F-Keys, what's up with F10??

    It has to do with Menus. Normally (sic) F10 activates the menu. Press it now and if you have a menu bar the first item is highlighted.

    I added a menu to Hack's example and then the code executed as expected.
    Last edited by dbasnett; Apr 8th, 2009 at 07:58 AM.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  7. #7
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: F-Keys, what's up with F10??

    Adding e.Handled = True stops F10 from bubbling up. Works with / without menu.

    Code:
        Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
            Select Case e.KeyCode
                Case Keys.F1
                    TextBox1.Text = "F1"
                Case Keys.F2
                    TextBox1.Text = "F2"
                Case Keys.F10
                    TextBox1.Text = "F10"
                    e.Handled = True
                Case Else
                    TextBox1.Text = "other"
            End Select
        End Sub
    Last edited by dbasnett; Apr 8th, 2009 at 07:57 AM.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: F-Keys, what's up with F10??

    Case Keys.F10
    TextBox1.Text = "F10"
    e.Handled = True

    Works well!

  9. #9
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: F-Keys, what's up with F10??

    @hack - You a noob Very funny.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Nov 2008
    Posts
    18

    Re: F-Keys, what's up with F10??

    well.. to be honest.. i'm sort of a noob also, been writing VB.net for only some 7 months..

    Gonna try e.Handled in my code also.. looks nicer than my solution..

    Thanks a lot!

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: F-Keys, what's up with F10??

    Quote Originally Posted by dbasnett View Post
    @hack - You a noob
    In VB.NET I am (can't you tell by some of my posts )?

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Nov 2008
    Posts
    18

    Re: [RESOLVED] F-Keys, what's up with F10??

    Code:
     key = e.KeyValue
            If key > 111 And key < 124 Then
                If key = 121 Then
                    e.Handled = True
    
                End If
                softkey.F_key()
            End If
    This is what i got in my code now, all keys except the Function keys are ignored, because of their Key-Value, and if you hit F10, well..you figured, e.handled is set to true..

    Works like a Charm!...

    Thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width