Author Topic: Key board control  (Read 3951 times)

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Key board control
« Reply #15 on: December 08, 2016, 12:15:03 AM »
then I got the code to stay without error but when I test it this happens not sure what this means

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Key board control
« Reply #16 on: December 08, 2016, 12:47:06 AM »
It looks correct to me. Instead of copy and paste, if you start typing the line of code, will Intellisense start completing the code for you or give you an option to select?

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Key board control
« Reply #17 on: December 08, 2016, 01:01:11 AM »
ok so I did that but I still get this error

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Key board control
« Reply #18 on: December 08, 2016, 01:10:55 AM »
Are you using RSEmulate?

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Key board control
« Reply #19 on: December 08, 2016, 01:26:51 AM »
I am indeed using rs emulate

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Key board control
« Reply #20 on: December 08, 2016, 01:32:46 AM »
I don't have any experience with RSEmulate, so I can't offer any help with it. Maybe someone else will chime in that has used RSEmulate.

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Key board control
« Reply #21 on: December 08, 2016, 02:18:28 AM »
ok great thanks for all you help so far....

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Key board control
« Reply #22 on: December 08, 2016, 08:26:55 AM »
hey sorry its me again I tried that code for Ethernet driver not connected to emulate or any other plc and I still get this error .any thoughts?

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Key board control
« Reply #23 on: December 08, 2016, 08:28:36 AM »
sorry here is that error

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Key board control
« Reply #24 on: December 08, 2016, 09:48:21 AM »
Before you started this topic and asked the question, was your program working OK and communicating with RS Emulate?

Also, take a look at Archie's reply #16:

It looks correct to me. Instead of copy and paste, if you start typing the line of code, will Intellisense start completing the code for you or give you an option to select?

In the pictures you posted, Intellisense doesn't seem to be working since it should have changed "com1" to "Com1" at the end of your driver name.

Look at the very first post here to see how to make changes:

https://www.google.ca/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=visual+studio+turn+on+intellisense

Also change the code from:

   SerialDf1forSLCMicrocom1.write("B3/0","1")
to:
   SerialDf1forSLCMicroCom1.write("B3:0/0", "1")


EthernetIPforCLX driver was suggested only as an example. It cannot communicate with RSLogix Emulate 500.
« Last Edit: December 08, 2016, 07:29:32 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Key board control
« Reply #25 on: December 08, 2016, 10:36:45 PM »
Another possible approach to assign keyboard shortcuts for different events could be done within the form's KeyUp event:

Code: [Select]
    Private Sub MainForm_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        If (e.Shift AndAlso e.KeyCode = Keys.A) Then ' SHIFT+A keys combination --> Write "1" to B3:0/0
            SerialDF1forSLCMicroCom1.Write("B3:0/0", "1")
        ElseIf (e.Shift AndAlso e.KeyCode = Keys.B) Then ' SHIFT+B keys combination --> Write "0" to B3:0/0
            SerialDF1forSLCMicroCom1.Write("B3:0/0", "0")
        ElseIf (e.Shift AndAlso e.KeyCode = Keys.C) Then ' SHIFT+C keys combination --> Open Calculator
            System.Diagnostics.Process.Start("calc.exe")
        End If
    End Sub

This approach doesn't require a control to be present on the form.
« Last Edit: December 08, 2016, 10:38:56 PM by Godra »

carlthesparky

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Key board control
« Reply #26 on: December 09, 2016, 01:20:47 AM »
hi thanks for all the input ive put in the new code and typed it in as said and not just copy pasted it and the button works when I click but not when I use the key board so my new quesrion is would I still put the address in the click address or where would I put it for the key board to write ?

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Key board control
« Reply #27 on: December 09, 2016, 10:19:03 AM »
You should try to use the whole code from my previous post, just copy and paste it.
Once you run the program, see if you get any errors and if not then try all 3 combinations of keys one at the time (SHIFT+A, SHIFT+B, SHIFT+C).

This is what you should know in general:

- PLCAddressClick field of the BasicButton should have address like B3:0/0
- Text field of the BasicButton can have any text in it. If you put "&" before any specific letter or number then that letter/number can be used together with ALT key on the keyboard to perform Click.
- When using the code to perform write then you have to use format like SerialDf1forSLCMicroCom1.write("B3:0/0", "1"). This line of code needs to be placed inside a sub (just like Archie explained it in previous posts).
« Last Edit: December 09, 2016, 10:23:04 AM by Godra »