Author Topic: VB .NET Help  (Read 12127 times)

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
VB .NET Help
« on: June 23, 2007, 08:17:42 PM »
Hi guys,
This question is not exactly about Genesys API but related to a Softphone requirement.

I usually develop on VB6 but now I'm trying to make a parallel version of my App on Vb.Net, i'm just starting to learn about it.

I want my application to capture keyboard combinations so it allows the agents to put themselves Ready/NotReady more fast.

On VB6 this is my code:

Private Declare Function GetAsyncKeyState Lib "User32" _
  (ByVal vKey As KeyCodeConstants) As Long

Private Function KeyDown(ByVal vKey As KeyCodeConstants) As Boolean
  KeyDown = GetAsyncKeyState(vKey) And &H8000
End Function

And a timer that keeps reading the users input:

Private Sub Timer1_Timer()

    If KeyDown(vbKeyControl) And KeyDown(vbKeyF11) Then 'Ready
        TExtension1.TReady
        Exit Sub
    End If
   
End Sub

On VB.Net i tried this:

Private Declare Function GetAsyncKeyState Lib "User32" (ByVal vKey As Keys) As Long

Private Function KeyDown1(ByVal vKey As Keys) As Boolean
        KeyDown1 = GetAsyncKeyState(vKey) And &H8000
End Function

But doesn't work

Any help please as many users here have more experience on Vb.Net

Thanks a lot

Offline bublepaw

  • Sr. Member
  • ****
  • Posts: 283
  • Karma: 10
Re: VB .NET Help
« Reply #1 on: June 24, 2007, 04:08:34 PM »
Hi,

Please take a look at the following article http://www.codeproject.com/csharp/globalhook.asp. It is written in C# but can be easily used in VB .Net. Solution provided by this library will create system level shortcuts - no matter which application is active.

Regards

Paul


Offline René

  • Administrator
  • Hero Member
  • *****
  • Posts: 1832
  • Karma: 62
Re: VB .NET Help
« Reply #2 on: June 24, 2007, 07:08:58 PM »
Hi cavagnaro,

If you don't need global/system level shortcuts then most of the graphical components (Form, TextBox etc.) do support the event "KeyPressed". You can assign your own handler to that Event and check which keys were pressed.

René

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: VB .NET Help
« Reply #3 on: June 24, 2007, 10:28:22 PM »
Well the main idea is that agent can be on any application (CRM, email, internet, etc) and change it status without going to CTI Application itself.
It seems i'll have to learn C# now, no VB.Net library of this? Seems .NET is still very young then.
Thanks

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: VB .NET Help
« Reply #4 on: June 25, 2007, 05:49:34 AM »
Yay! It works!

[quote]
    Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Keys) As Long

    Private Function KeyDownStatus(ByVal vKey As Keys) As Boolean
        KeyDownStatus = GetAsyncKeyState(vKey) And &H8000
    End Function

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If KeyDownStatus(Keys.ControlKey) And KeyDownStatus(Keys.F10) Then
            Debug.Print("ok")
        End If
    End Sub
[/quote]

Not sure why now but it works like a charm :D Marvelous Google Code Search

Offline bublepaw

  • Sr. Member
  • ****
  • Posts: 283
  • Karma: 10
Re: VB .NET Help
« Reply #5 on: June 25, 2007, 10:15:41 AM »
[quote author=cavagnaro link=topic=2329.msg8560#msg8560 date=1182724102]
Well the main idea is that agent can be on any application (CRM, email, internet, etc) and change it status without going to CTI Application itself.
It seems i'll have to learn C# now, no VB.Net library of this? Seems .NET is still very young then.
Thanks
[/quote]

In .NET You can use C# libraries under VB.NET and vice versa - that how .NET works :) - for example Genesys .NET libraries are written in C# but can be easily used under VB

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: VB .NET Help
« Reply #6 on: June 25, 2007, 12:31:03 PM »
Uh..how? I have found an excellent idea (deskbank) and would like to implement that on my application but all code is on C#.
Is there a Tool or something to import directly from C# to Vb.Net?
Thanks a lot

Offline bublepaw

  • Sr. Member
  • ****
  • Posts: 283
  • Karma: 10
Re: VB .NET Help
« Reply #7 on: June 25, 2007, 12:58:52 PM »
It works like this - You must create C# project of type "Class library" or "Windows Control library" with code You need. Compile it. You will receive dll. Then You just need to add this dll to references of Your VB application and You can access class or controls stored in this dll. If You need help with creating this file feel free to send this C# code to convert into library.

Paul

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: VB .NET Help
« Reply #8 on: July 05, 2007, 05:33:36 PM »
HI guys,
I found this:
http://www.codeproject.com/csharp/BandObjects20.asp

It's very cool.
I have tried to make it VB.Net compatible but without any success.
Can anybody please try to do a very simple thing on Vb.Net with it?
Thanks in advance for any help  ;D

Offline bublepaw

  • Sr. Member
  • ****
  • Posts: 283
  • Karma: 10
Re: VB .NET Help
« Reply #9 on: July 06, 2007, 09:50:27 AM »
Hi

In attached file You will find modified project from CodeProject with sample VB.Net application - I hope it helps. Important thing is to set minimum and maximum size to values other then 0,0.

Paul

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: VB .NET Help
« Reply #10 on: July 06, 2007, 03:22:37 PM »
Hi bublepaw,

Thanks a lot for the help.
A question when i build the Lib i get this:
RegAsm : warning RA0000 : No types were registered

What else do i need to modify?
Thanks

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: VB .NET Help
« Reply #11 on: July 06, 2007, 03:32:48 PM »
It works now like a charm :D
Thanks a lot! Hope i can return help someday