Author Topic: Key board control  (Read 3156 times)

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Key board control
« on: December 07, 2016, 03:37:28 AM »
is their a way to press a push button or a basic button by using a key on the keyboard?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5267
    • View Profile
    • AdvancedHMI
Re: Key board control
« Reply #1 on: December 07, 2016, 05:50:33 AM »
In the Text property of a button, insert an "&" before the keyboard letter you want to use. For example "Start &Motor". When you run the program, you can use Alt-M to click that button.

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Key board control
« Reply #2 on: December 07, 2016, 06:15:28 AM »
Does not seem to work.... Lets say in the text property I say ''&S'' then I should be able to type Alt S and should be working?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5267
    • View Profile
    • AdvancedHMI
Re: Key board control
« Reply #3 on: December 07, 2016, 06:34:28 AM »
Does not seem to work.... Lets say in the text property I say ''&S'' then I should be able to type Alt S and should be working?
Yes. Try this:

- Add a BasicButton to the form
- Change the Text property to "&BasicButton1"
- Double click the button to get back to the code
- Enter this code:

 MsgBox("Button clicked!")

- Run the application and press Alt-B on the keyboard

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5267
    • View Profile
    • AdvancedHMI
Re: Key board control
« Reply #4 on: December 07, 2016, 06:46:12 AM »
I just thought about it and this will probably not work when controlling the PLC because the Alt-B action clicks the button, but the PLC writing is activated by Mouse Down and Mouse Up events.

Another option that may work is to Tab through the controls to get the button highlighted that you want to click , then press Enter.

Or you could write to the PLC via code in the Click event handler. In the example above, instead of using the MsgBox, you would use something like this:

EthernetIPforCLXCom1.Write("MyButtonTag","1")

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Key board control
« Reply #5 on: December 07, 2016, 06:51:38 AM »
I will try option 3 but in my case im using comdf1 will that still work?

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Key board control
« Reply #6 on: December 07, 2016, 06:55:53 AM »
Oh and please show me where in the code I must make these changes im am a noob at code

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5267
    • View Profile
    • AdvancedHMI
Re: Key board control
« Reply #7 on: December 07, 2016, 07:09:52 AM »
- Add a BasicButton to the form
- Change the Text property to "&BasicButton1"
- Double click the button to get back to the code
- Enter this code:

 EthernetIPforCLXCom1.Write("MyButtonTag","1")

- Run the application and press Alt-B on the keyboard

Keep in mind this will only set your PLC bit to true. You will need another mechanism to clear the bit, such as logic in the PLC

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Key board control
« Reply #8 on: December 07, 2016, 08:24:03 AM »
Ok I copy and pasted the code then I get a build error hahaha im sorry being a pain

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5267
    • View Profile
    • AdvancedHMI
Re: Key board control
« Reply #9 on: December 07, 2016, 08:26:24 AM »
What driver are you using?

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Key board control
« Reply #10 on: December 07, 2016, 08:30:55 AM »
SerialDf1forSLCMicrocom1

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5267
    • View Profile
    • AdvancedHMI
Re: Key board control
« Reply #11 on: December 07, 2016, 08:39:10 AM »
SerialDf1forSLCMicrocom1.write("B3/0","1")

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Key board control
« Reply #12 on: December 07, 2016, 08:44:03 AM »
[

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5267
    • View Profile
    • AdvancedHMI
Re: Key board control
« Reply #13 on: December 07, 2016, 09:33:14 AM »
Show a screen shot of your MainForm so I can see the exact name of your driver.

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Key board control
« Reply #14 on: December 08, 2016, 12:13:44 AM »
Ok here it is