Motorola Handheld MC55A Development [closed] - windows-ce

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
i have Motorola Handheld MC55A with windows embedded handheld 6.5 and i want to start develop an app to read barcode .I didn't find any reference to do my command
i have installed VS2008 and start to create Smart Device Application with a simple form

Merit who deserve merit: Initially I didn't write the following code, I'm not sure who initially did it, may be was written by symbol developers...I'm not sure, I only have used it.
1- First at all download and install the Motorola EMDK, after that, you will copy the C:\Program Files (x86)\Motorola EMDK for .NET\v2.5\SDK\Smart Devices\Symbol.Barcode.dll file to \My Device\Windows folder in your pocket.
Public Class frmTest
Dim MyReader As Symbol.Barcode.Reader = Nothing
Dim MyReaderData As Symbol.Barcode.ReaderData = Nothing
Dim MyEventHandler As System.EventHandler = Nothing
Dim MyHandlerCB As System.EventHandler = Nothing
Private Sub frmTest_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
InitReader()
End Sub
Protected Overloads Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs)
StopRead()
Me.TermReader()
MyBase.OnClosing(e)
End Sub
Private Function InitReader() As Boolean
' If reader is already present then fail initialize
If Not (Me.MyReader Is Nothing) Then
Return False
End If
'Create new reader, first available reader will be used.
Me.MyReader = New Symbol.Barcode.Reader
'Create reader data
Me.MyReaderData = New Symbol.Barcode.ReaderData( _
Symbol.Barcode.ReaderDataTypes.Text, _
Symbol.Barcode.ReaderDataLengths.DefaultText)
' create event handler delegate
Me.MyEventHandler = New System.EventHandler(AddressOf MyReader_ReadNotify)
'Enable reader, with wait cursor
Me.MyReader.Actions.Enable()
Return True
End Function
Private Sub TermReader()
'If we have a reader
If Not (Me.MyReader Is Nothing) Then
'Disable reader, with wait cursor
Me.MyReader.Actions.Disable()
'free it up
Me.MyReader.Dispose()
' Indicate we no longer have one
Me.MyReader = Nothing
End If
' If we have a reader data
If Not (Me.MyReaderData Is Nothing) Then
'Free it up
Me.MyReaderData.Dispose()
'Indicate we no longer have one
Me.MyReaderData = Nothing
End If
End Sub
Private Sub StartRead()
'If we have both a reader and a reader data
If Not ((Me.MyReader Is Nothing) And (Me.MyReaderData Is Nothing)) Then
'Submit a read
AddHandler MyReader.ReadNotify, Me.MyEventHandler
Me.MyReader.Actions.Read(Me.MyReaderData)
End If
End Sub
Private Sub StopRead()
'If we have a reader
If Not (Me.MyReader Is Nothing) Then
'Flush (Cancel all pending reads)
RemoveHandler MyReader.ReadNotify, Me.MyEventHandler
Me.MyReader.Actions.Flush()
End If
End Sub
Private Sub MyReader_ReadNotify(ByVal o As Object, ByVal e As EventArgs)
Dim TheReaderData As Symbol.Barcode.ReaderData = Me.MyReader.GetNextReaderData()
'If it is a successful read (as opposed to a failed one)
If (TheReaderData.Result = Symbol.Results.SUCCESS) Then
'Handle the data from this read
Me.HandleData(TheReaderData)
'Start the next read
Me.StartRead()
End If
End Sub
Private Sub HandleData(ByVal TheReaderData As Symbol.Barcode.ReaderData)
txtBarCode.Text = TheReaderData.Text
End Sub
Private Sub txtBarCode_GotFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBarCode.GotFocus
StartRead()
End Sub
Private Sub txtBarCode_LostFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBarCode.LostFocus
StopRead()
End Sub
End Class

You want to scan barcodes and insert them into textboxes from your app?
Try to enable Data Wedge from Control Panel.

Related

Bring previous opened window (Word document) to foreground

Suppose I have two hyperlinks (on excel sheet) referring to two documents:
e.g ( A.doc and B.doc ) on my local intranet.
I will open the first document "A.doc" then I will open the second one "B.doc"
The problem:
If there is already an opened word document and then I clicked hyperlink (Word Document on my local intranet),
The later file is not opened automatically and I have to click on the flashing taskbar button to open the cited second file.
This issue occurs only with Microsoft word documents found on my local intranet.
If there is no open document and I clicked on any word hyperlink, It opens normally without any issue.
Please watch this short video to understand my problem.
I need to utilize FollowHyperlink event in excel or any other method to:
bring the previous opened window A.doc to front and then bring the second one B.doc to front.
you may find it a strange question! But I have to do it manually each time to show and bring the second one to front.
I have used this API code (in a Word document) on Normal-ThisDocument:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Dim LHwnd As Long
Private Sub Document_Open()
If Application.Documents.Count > 1 Then
LHwnd = FindWindow("rctrl_renwnd32", Application.ActiveWindow.Caption)
SetForegroundWindow (LHwnd)
End If
End Sub
And used that code on my excel sheet itself:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
On Error Resume Next
Dim objWd As Object
Set objWd = GetObject(, "Word.Application")
AppActivate objWd.ActiveWindow.Caption
Set objWd = Nothing
End Sub
Finally, I found this helpful page Bring an external application window to the foreground But I could not adapted it to my need.
Please, try the next BeforeDoubleClick event. If the problem is related only to hyperlinks, it should work...
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.column = 1 And Target.Value <> "" Then 'limit this behavior to the first column
If LCase(left(Target.Value, 5)) = "http:" Then
Cancel = True
Dim objWd As Object, d As Object, arrD: arrD = Split(Target.Value, ".")
If LCase(left(arrD(UBound(arrD)), 3)) <> "doc" Then Exit Sub
On Error Resume Next
Set objWd = GetObject(, "Word.Application") 'find the Word open session, if any
On Error GoTo 0
If objWd Is Nothing Then
Set objWd = CreateObject("Word.Application")
End If
With objWd
.Visible = True
Set d = .Documents.Open(Target.Value)
End With
'force somehow the new open document window expose its handler...
Dim i As Long
Do Until objWd.ActiveWindow.Caption = d.name Or _
objWd.ActiveWindow.Caption = left(d.name, InstRev(d.name, ".")-1) & " [Read-Only] [Compatibility Mode]"
i = i + 1: Debug.Print objWd.ActiveWindow.Caption, left(d.name, InstRev(d.name, ".")-1) & " [Read-Only] [Compatibility Mode]"
DoEvents: If i >= 10 Then Exit Do 'just in case, if something unexpected happens...
Loop
SetForegroundWindow CLngPtr(objWd.ActiveWindow.hWnd)
End If
End If
End Sub
It should work in 64 bit, but it is easy to be adapted for both cases, supposing that it works as you need.

How do i get an ODBC refresh to trigger vb code

I have an odbc connection named "Parcel Picks by Hour" that is on an auto run timer every 15 minutes. I want to run an script that sends an email with the updated data after the refresh event is complete. all codes I have found were unsuccessful. since the timer is already built into the ODBC i dont want a code that refreshes the connection then sends an email i just want the refresh to trigger the code to run.
NOT AN ANSWER AN IDEA
Create a class like so, ive called mine clsCustomConnection
Private WithEvents cn As ADODB.Connection
Public Sub Initialise(cnADO As ADODB.Connection)
Set cn = cnADO
End Sub
Private Sub cn_ExecuteComplete(ByVal RecordsAffected As Long, ByVal pError As ADODB.Error, _
adStatus As ADODB.EventStatusEnum, ByVal pCommand As ADODB.Command, _
ByVal pRecordset As ADODB.Recordset, ByVal pConnection As ADODB.Connection)
' Email function
MyEmailFunction ("VBAEventExample.co.uk")
End Sub
Then in a normal module, something like so
Public CustomADOConnection As clsCustomConnection
Sub setupADOconnection()
Dim ADOConn1 As New ADODB.Connection
' Set up connection
ADOConn1.ConnectionString = ""
ADOConn1.CursorLocation = adUseClient
' Sink to custom connection
Set CustomADOConnection = New clsCustomConnection
CustomADOConnection.Initialise ADOConn1
End Sub

Need to run a dummy VBA, SAPI code written by Microsoft but it is not clear how to make calls to those subroutines with arguments

Following code has been taken from the URL:
https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ms720590(v=vs.85)
The page does attempt to tell something about it but it is vague.
The following code sample represents a simple, but functional, recognition application, using the in process (or InProc) recognizer. It uses a dictation grammar and allows free dictation. The commented lines refer to hypothetical labels in a form to possibly display information. To see the recognized phrase, add one label, named Label1. Of course you may modify this application as needed to fit your own requirements.
Before running the application, a speech reference must be included. Using the Project->References menu, find and select the Microsoft Speech Object Library.
An InProc recognizer requires additional lines that shared recognizers do not. For InProc recognizers, the audio object for either input or output must be explicitly assigned.
'Dim WithEvents RC As SpInProcRecoContext
Dim Recognizer As SpInprocRecognizer
Dim myGrammar As ISpeechRecoGrammar
Sub Form_Load()
On Error GoTo EH
Set RC = New SpInProcRecoContext
Set Recognizer = RC.Recognizer
Set myGrammar = RC.CreateGrammar
myGrammar.DictationSetState SGDSActive
Dim Category As SpObjectTokenCategory
Set Category = New SpObjectTokenCategory
Category.SetId SpeechCategoryAudioIn
Dim Token As SpObjectToken
Set Token = New SpObjectToken
Token.SetId Category.Default()
Set Recognizer.AudioInput = Token
EH:
If Err.Number Then ShowErrMsg
End Sub
Sub RC_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)
On Error GoTo EH
Range("G8").Value = Result.PhraseInfo.GetText
EH:
If Err.Number Then ShowErrMsg
End Sub
Private Sub ShowErrMsg()
' Declare identifiers:
Const NL = vbNewLine
Dim T As String
T = "Desc: " & Err.Description & NL
T = T & "Err #: " & Err.Number
MsgBox T, vbExclamation, "Run-Time Error"
End
End Sub
Sub MyMacro()
Call Form_Load
Call RC_Recognition
End Sub````
Not able figure out how to call subroutine "RC_Recognition" that is taking some arguments.
the Dim WithEvents RC As SpInProcRecoContext line is the key. This automatically maps the function RC_Recognition as the handler for the Recognition event.

Method 'Text' of object 'ISapCTextField' failed

I have to pull data from SAP. This error happens randomly:
Method 'Text' of object 'ISapCTextField' failed
I searched but none of the solutions work. Error handling by trying multiple times also didn't work. Instead of trying more methods, I avoided the .Text method altogether.
Example of line causing the error:
session.findById("wnd[0]/usr/ctxtMATNR-LOW").text = "500000000"
To avoid using the .text method, I used SendKeys to achieve the same thing. Basically making the SAP window as active window and selecting the desired field in SAP GUI by using set focus, and then using Ctrl+V via sendkeys to paste the text from a range to the field. Below is the code:
'Declaration
Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Declare Function SetForegroundWindow Lib "user32" ( _
ByVal HWnd As Long) As Long
'Finds SAP Window.
Public Sub ActivateSAPWindow()
Dim HWnd As Long
'SAP window Name can be found on the status bar of the Portal.
'Note: This only works in when you click on R/3 and it open a portal. It will not work if it open in the internet explorer
'To make it work for internet explorer , Simply change the name of the Window to find internet explorer or any window you wish.
HWnd = FindWindow(vbNullString, "R/3 - SAP NetWeaver Portal - Internet Explorer")
If HWnd Then
SetForegroundWindow HWnd
End If
End Sub
Public Sub SAPSafeText(ID As String, OriginCell As String)
'Location of the cell you wanna copy to the field.
Worksheets("SAP Mapping").Range(OriginCell).Copy
Call ActivateSAPWindow
Session.FindByID(ID).SetFocus
SendKeys "^v"
'Important to wait for completion before next line.
Wait (5)
End Sub
To call the function , Simply use SAP script record to get the Field ID name and parse into the SAPSafeText("ID of the Field as string", "Cell Range as string").
Example of call:
Call SAPSafeText("wnd[0]/usr/ctxtBWART-LOW", Low)
Call SAPSafeText("wnd[0]/usr/ctxtBWART-HIGH", High)
This is the brute force way but it works.
Why is the error happening?
Is there a better way to handle this?
I met the same situation too. I solve it. I think that is you use the sentence like
session.findbyid (*****).text = cells(i,j)
you should try to use
session.findbyid (*****).text = cells(i,j).value
You could try the following instead of sendkeys method:
...
Application.Wait (Now + TimeValue("0:00:01"))
session.findById("wnd[0]/usr/ctxtMATNR-LOW").text = "500000000"
...
Regards,
ScriptMan
below are snips of the code that could cause the random error. There are about 7 other Reports. Here is the MRP report example.
Public SapGuiAuto As Object
Public SAPApp As SAPFEWSELib.GuiApplication
Public SAPConnection As SAPFEWSELib.GuiConnection
Public Session As SAPFEWSELib.GuiSession
Sub InitSession()
On Error GoTo InternetAutomation
ErrorCounter = ErrorCounter + 1
Set SapGuiAuto = GetObject("SAPGUI")
If Not IsObject(SapGuiAuto) Then
Exit Sub
End If
Set SAPApp = SapGuiAuto.GetScriptingEngine()
If Not IsObject(SAPApp) Then
Exit Sub
End If
Set SAPConnection = SAPApp.Connections(0)
If Not IsObject(SAPConnection) Then
Exit Sub
End If
Set Session = SAPConnection.Sessions(0)
If Not IsObject(Session) Then
Exit Sub
End If
Exit Sub
InternetAutomation:
.........
End sub
sub MRP()
Call InitSession
Call TCodeBox("/n/DS1/APO_C_")
Call PlantCode_MRP("A11")
Call Material_MRP("E3")
Call SetPath_MRP
Call Execute
Call MRPReportProcess
End Sub
Sub PlantCode_MRP(Cell As String)
session.findById("wnd[0]/usr/ctxtS_WERKS-LOW").Text = Range(Cell)
session.findById("wnd[0]/usr/btn%_S_WERKS_%_APP_%-VALU_PUSH").press
Call SAPMultiSelect(Cell)
End Sub
Sub Material_MRP(Cell As String)
Worksheets("MB52 Total").Activate
session.findById("wnd[0]/usr/btn%_S_MATNR_%_APP_%-VALU_PUSH").press
Call SAPMultiSelect(Cell)
End Sub
Sub SetPath_MRP()
session.findById("wnd[0]/usr/ctxtP_PATH").Text = Desktop
session.findById("wnd[0]/usr/txtP_NAME").Text = MRPFileName
End Sub
Sub TCodeBox(TCode As String)
session.findById("wnd[0]/tbar[0]/okcd").Text = TCode
On Error GoTo TCodeErrorHandler
session.findById("wnd[0]").sendVKey 0
TCodeErrorHandler:
session.findById("wnd[0]/tbar[0]/btn[15]").press
session.findById("wnd[0]/tbar[0]/okcd").Text = TCode
session.findById("wnd[0]").sendVKey 0
Resume Next
Exit Sub 'Enter
End Sub
Sub Execute()
session.findById("wnd[0]/tbar[1]/btn[8]").press
End Sub
Regards,Jacob.
Sometimes I could solve similar errors by restarting the transaction.
for example:
Sub PlantCode_MRP(Cell As String)
on error resume next
session.findById("wnd[0]/usr/ctxtS_WERKS-LOW").Text = Range(Cell)
if err.number <> 0 then
Call TCodeBox("/n/DS1/APO_C_")
session.findById("wnd[0]/usr/ctxtS_WERKS-LOW").Text = Range(Cell)
end if
on error goto 0
'On Error GoTo InternetAutomation
session.findById("wnd[0]/usr/btn%_S_WERKS_%_APP_%-VALU_PUSH").press
Call SAPMultiSelect(Cell)
End Sub
Regards,
ScriptMan

VB.NET Awesomium open in new window target_blank Example

Okay i tried everything searched google, tried the example in docs Awesomium and it didn't work. I have a tabbed browser. How can i make for every webcontrol to handle showcreatedwebview event.
this for window you created
Private Sub Mainwindow_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
PictureBox2.Enabled = False
TextBox1.Text = Clipboard.GetText
WebControl1.Source = New Uri(TextBox1.Text)
End Sub
this for you browser
Private Sub WebControl1_ShowCreatedWebView(ByVal sender As Object, ByVal e As Awesomium.Core.ShowCreatedWebViewEventArgs) Handles WebControl1.ShowCreatedWebView
Clipboard.SetText(e.TargetURL.ToString)
Dim webControl As Awesomium.Windows.Forms.WebControl = TryCast(sender, Awesomium.Windows.Forms.WebControl)
Form1.Tabcontrol1.TabContainer.AddTab(New Mainwindow, True, Form1.Tabcontrol1.TabContainer.TabCount)
Dim webControl11 As WebControl = TryCast(sender, WebControl)
If webControl Is Nothing Then Return
If Not webControl.IsLive Then Return
Mainwindow.Close()
If e.IsPopup AndAlso (Not e.IsUserSpecsOnly) Then
' JSWindowOpenSpecs.InitialPosition indicates screen coordinates
ElseIf (e.IsWindowOpen OrElse e.IsPost) Then
Else
e.Cancel = True
Mainwindow.TextBox1.Text = e.TargetURL.ToString
' Show the window.
Form1.Tabcontrol1.TabContainer.AddTab(New Mainwindow, True, Form1.Tabcontrol1.TabContainer.TabCount)
End If
End Sub
End Class

Resources