Send text from mobile device via bluetooth to PC cursor location

Gwasshoppa

Newcomer
Joined
Apr 6, 2011
Messages
7
Hi

I am developing a very small exe application on a Motorola MC55 that simply accepts a barcode into a textbox, and sends that barcode (via bluetooth ActiveSync) to the cursor location on the PC.

The cursor location will be emPOWER (an accounting system)... although this is probably irrelevant as it could just be notepad... I simply want to sent the barcode directly to the cursor position on the PC.

This can be easily achieved with a dumb scanner attached to the PC via a COM Port, but the reason i'm not using a dumb barcode scanner is because some of the barcodes require manipulation before they are sent to the PC.
i.e. a barcode 99019-24 would need to be sent to the PC as 901924. (note the - is removed and the first number is also removed... where as a barcode of say 462-au-a12667 needs to be sent as 462aua12667 only the - is removed.

I have had to load the Motorola DataWedge software to enable the barcode scanner on the MC55, but it appears that the API provided is pretty small and doesn't have a way of sending the text based barcode to the cursor on the PC.

Does anyone know how I might achieve this using either C# or VB.Net and any code that may be out there to assist with this?

Cheers
Gwasshoppa
 
I am also thinking this can be done via a wireless network i.e. connect the MC55 to the wireless network and then access the webservice on the PC, and then allow the webserver to determine its current caret position.

I have found some code here...
http://www.codeproject.com/KB/dialog/CaretPosition.aspx. This is kind of what I want to do.

I need to change this code around to perform the following...
On the device i scan a barcode into a form with 1 textbox, and when the carriage return is fired I call a webservice on the PC. The MC55 is connected to the PC using a wireless network. I access the webservice deployed on the PC and the webservice does basically what the above link application does, and returns the point where the Caret is currently placed.

From here I can push that point back to the webservice and write the barcode (stripped of unnecessary characters) to the position where the caret is.

My next question is... how do i access the webservice? It keeps saying unable to connect to host :(

Any thoughts or help on this would be excellent
Cheers
Gwasshoppa
 
Ok i have made a bit of progress and found this:
http://beta.codeproject.com/KB/dialog/CaretPosition.aspx
It allows you to find the caret position of the machine.

I have used parts of this to see if I can write a webservice to return the current caret placement on the "server PC"

Note the server PC is a standard XP machine.

I have connected to the development machine via a wireless network, and can get the webservice details, however the service always returns point(0,0)

Here is the code i have:

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports System.Threading
Imports System.Diagnostics

Public Class CaretPositioning

Public Sub New()
MyBase.New()
End Sub


'Structure Required by user32.dll
<StructLayout(LayoutKind.Sequential)> Public Structure RECT
Public Left As UInteger
Public Top As UInteger
Public Right As UInteger
Public Bottom As UInteger
End Structure

'Structure Required by user32.dll
<StructLayout(LayoutKind.Sequential)> Public Structure GUITHREADINFO
Public cbSize As UInteger
Public hwndActive As IntPtr
Public hwndFocus As IntPtr
Public hwndCapture As IntPtr
Public hwndMenuOwner As IntPtr
Public hwndMoveSize As IntPtr
Public hwndCaret As IntPtr
Public rcCaret As RECT
End Structure

Private sPosition As Point = New Point ' Point required for ToolTip movement by Mouse
Private guiInfo As GUITHREADINFO
Private components As System.ComponentModel.IContainer ' To store GUI Thread Information
Private caretPosition As Point ' To store Caret Position

#Region "Dll Imports"

Public Declare Function GetGUIThreadInfo Lib "user32.dll" Alias "GetGUIThreadInfo" (ByVal tId As UInteger, ByRef threadInfo As GUITHREADINFO) As Boolean
Public Declare Function ClientToScreen Lib "user32.dll" (ByVal hWnd As IntPtr, ByRef position As Point) As Boolean

#End Region


''' <summary>
''' Evaluates Cursor Position with respect to client screen.
''' </summary>
Public Function GetCaretPosition() As Point
caretPosition = New Point
' Fetch GUITHREADINFO
CurrentCaretPosition()
caretPosition.X = (CType(guiInfo.rcCaret.Left, Integer) + 25)
caretPosition.Y = (CType(guiInfo.rcCaret.Bottom, Integer) + 25)
Debug.Print(caretPosition.X & " " & caretPosition.Y)
ClientToScreen(guiInfo.hwndCaret, caretPosition)
Debug.Print(caretPosition.X & " " & caretPosition.Y)
Return New Point(caretPosition.X, caretPosition.Y)
End Function


''' <summary>
''' Get the caret position
''' </summary>
Public Sub CurrentCaretPosition()
guiInfo = New GUITHREADINFO
guiInfo.cbSize = CType(Marshal.SizeOf(guiInfo), UInteger)
' Get GuiThreadInfo into guiInfo
GetGUIThreadInfo(0, guiInfo)
End Sub

End Class

Can anyone shed some light on why it will not return the current caret position on the "server PC"?
 
A bit of info i missed out above...

I am writing a webservice to return the caret position of the "server PC" so this I can strip off certain characters from the barcode, and then send the full characters to the PC via a wireless network.

This way I can manipulate the barcode before it gets tot he "server PC" and then the application (emPOWER) can accept the correct characters without the dashes and other unneeded characters.
 
Well it appears that the webservice (from another remote machine) only returns 0,0 as a location no matter where the cursor is on the host pc :(

Can anyone suggest any way of sending wireless data to a PC at the cursor (caret) location?
 
Back
Top