Autor Tema: Mover .gif con Teclado, HTML, JScript, Activex MSComm, Celular con Android  (Leído 3231 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado IAO

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 702
Mover un .gif con el teclado en HTML + JScript + Activex MSComm + Celular con Android + Bluetooh.

Decidí colocar esta publicación aquí, porque igual se puede hacer con VBScript, pero utilicé JScript.
Además el programa de android esta elaborado en rfo-Basic!.


Hola para todos....

Ni se imaginan lo difícil para mi que fue todo esto.
Yo sabía que si se podía hacer, el problema era como hacerlo.
Se puede hacer con .HTML, pero es más complicado, se puede hacer practicamente de todo.
Existe hasta una dynawrap.dll que te permite cargar .dll externas como inpout32.dll.

El objetivo principal era mover ese objeto .gif desde el celular,
con SO Android y el puerto bluetooth.

También hice pruebas con: "Virtual Serial Port Driver". El HTML y "HyperTerminal" con diferente
puerto serial en cada programa, funcionó todo bien.

Ok. Trataré de ser puntual en el asunto.

Problema:
MSComm ya no trabaja en el Internet Explorer 7 y superiores.
Hay un "Kill Bit" en un servispack que al actualizar windows xp lo coloca en el Registry key.
Leer Aquí: En Inglés kill bit
o buscar en internet : Tony's Microsoft Access Blog
(An older version of MSCOMM32.OCX has had the "kill bit" flag set.)

Solución:
ACM.exe (ActiveX Compatibility Manager v1.00) de NirSoft
ACM en inglés
http://www.nirsoft.net/utils/acm.zip
Deberías leer la página de como utilizarlo.

Una vez que activas el componente MSCOMM ya puedes utilizarlo en Internet Explorer.

Perdí mucho tiempo tratando de recibir y enviar algo con HTML o JScript. Hasta encontrar la solución.
El código estaba bueno. Era ese "kill bit" lo que me estaba trancando todo.
No lo he probado en Windows 7, solo en Win XP.

Aquí les dejo el código necesario en HTML, JScript y Basic! para el celular con android.
Todo trabajando perfecto, según mis pruebas.
Debes tener Bluetooth en el computador.
Activar Bluetooth en el celular.

HTML puedes darle cualquier nombre con extención .html
Tambien debes darle los dos permisos que te solicita el .HTML para que ejecute correctamente.

JScript debes darle este nombre obligatoriamente. ex09-08.js o cambiarlo dentro del .html

Celuler con Android. Debes tener instalado RFO-Basic! en tu celular v1.58
puedes darle cualquier nombre con extención .bas
Bajar Basic! android V1.58


Todos los códigos no son mios, solo el .bas de android. Pero los otros tienen
mucho código puesto por mi. Los .gif hechos por mi, no son de calidad :)

Espero les sea útil en su momento.

Saludos para todos.

 Luego lo subo box.net  Ya cambiado
« Última modificación: 17 de Julio de 2012, 23:48:33 por IAO »
"No hay caminos para lograr la PAZ. La PAZ es el camino"... (Mahatma Gandhi).
Mentes Superiores discuten Ideas, Proyectos. Mentes Promedio discuten Acontecimientos y Sucesos. Mentes Pobres discuten sobre Personas.

Desconectado todopic

  • Administrador
  • DsPIC30
  • *******
  • Mensajes: 3495
    • http://www.todopicelectronica.com.ar
Re: Mover .gif con Teclado, HTML, JScript, Activex MSComm, Celular con Android
« Respuesta #1 en: 19 de Julio de 2012, 21:03:42 »
 :-/ buenisima informacion!!!, hay bastante para masticar je je
Firmat - Santa Fe - Argentina

www.TodoPic.net

Solo se tiran piedras, al arbol que tiene frutos...

Desconectado IAO

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 702
Re: Mover .gif con Teclado, HTML, JScript, Activex MSComm, Celular con Android
« Respuesta #2 en: 05 de Agosto de 2012, 12:41:01 »
Hola para todos...

Gracias jefazo Norbert....

Bueno para terminar esto les dejo el código de dos .html, uno hecho en VBScript y el mismo pero en JavaScript el cual modifiqué del anterior.

El código del .html combinado con VBScript.
Código: [Seleccionar]
<div>Below is the code I found that will allow you to instantiate a client-side</div>
<div>Serial session. I will be using this implementation as my base for a </div>
<div>Serial Barcode Printer Control Module. If anyone cares to clean this up or offer suggestions of any kind, I am all eyes. thanks KD</div>
<div> </div> <div> </div> <div> </div> <div><HTML>

<HEAD>
<TITLE>Html con VBScript y MSCOMM32</TITLE>
<SCRIPT LANGUAGE="VBScript">
<!--
Dim Rec
Const comEventBreak = 1001
Const ComEventCDTO = 1007
Const ComEventCTSTO = 1002
Const ComEventDSRTO = 1003
Const ComEventFrame = 1004
Const ComEventOverrun = 1006
Const ComEventRxOver = 1008
Const ComEventRxParity = 1009
Const ComEventTxFull = 1010
Const ComEventDCB = 1011
Const ComEvCD = 5
Const ComEvCTS = 3
Const ComEvDSR = 4
Const ComEvRing = 6
Const ComEvReceive = 2
Const ComEvSend = 1
Const ComEvEOF = 7
-->
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="X">

<SCRIPT LANGUAGE="VBScript">
<!--
Sub MSComm1_OnComm()   
Dim Z
   Select Case document.X.MSComm1.CommEvent   
   Case comEventBreak     ' A Break was received.
   Case comEventCDTO      ' CD (RLSD) Timeout.
   Case comEventCTSTO     ' CTS Timeout.
   Case comEventDSRTO     ' DSR Timeout.
   Case comEventFrame     ' Framing Error
   Case comEventOverrun   ' Data Lost.
   Case comEventRxOver    ' Receive buffer overflow.
   Case comEventRxParity  ' Parity Error.
   Case comEventTxFull    ' Transmit buffer full.
   Case comEventDCB       ' Unexpected error retrieving DCB] 
   Case comEvCD           ' Change in the CD line.
   Case comEvCTS          ' Change in the CTS line.
   Case comEvDSR          ' Change in the DSR line.
   Case comEvRing         ' Change in the Ring Indicator.
   Case comEvReceive      ' Received RThreshold # of  chars.
   
   While document.X.MsComm1.InbufferCount > 0
      Z = document.X.MsComm1.Input
      Rec = Rec & Z
   WEnd
   
   Document.X.REC.value = Rec 
   Case comEvSend        ' There are SThreshold number of  characters in the transmit buffer.
   Case comEvEof         ' An EOF charater was found in the input stream 
   End Select
End sub


Sub SendData()
   If Not document.X.MSComm1.PortOpen Then
      MsgBox "The Port is not open. Please open the port before sending data.",vbCritical
      Exit Sub
   End If

   If Len(document.X.SEND.value) = 0 Then
      MsgBox "There is nothing to send. Please enter a send string first.",vbCritical
      Exit Sub
   End If
   document.X.MsComm1.Output = document.X.SEND.value
End Sub


Sub OpenPort()
On Error Resume Next
Dim S
Err = 0
   If document.X.MsComm1.PortOpen Then
      document.X.MsComm1.PortOpen = False
      document.X.Open.value = "Open Port"
      Exit Sub
   End If
   document.X.MSComm1.CommPort = document.X.PORT.options(document.X.PORT.selectedIndex).value
   document.X.MSComm1.Settings = document.X.SPEED.options(document.X.SPEED.selectedIndex).text & ",n,8,1"
   document.X.MSComm1.PortOpen = True

   if Err<> 0 Then
      MsgBox "The Port could not be opened (" & Err.Description & "). Please try again.",vbCritical
      Exit Sub
   end if
   document.X.Open.value = "Close Port"
   
   document.X.PORT.enabled = False
   document.X.SPEED.enabled = False
   S = "The Port has been opened. The Settings are:" & vbcrlf
   S = S & "CommPort : " & document.X.MSComm1.CommPort & vbcrlf
   S = S & "Settings : " & document.X.MSComm1.Settings
   MsgBox S,vbInformation
     
End Sub

-->
</SCRIPT>


<OBJECT ID="MSComm1" WIDTH=39 HEIGHT=39
 CLASSID="CLSID:648A5600-2C6E-101B-82B6-000000000014" CODEBASE="mscomm32.ocx">

 
 <PARAM NAME="_ExtentX" VALUE="1005">
 <PARAM NAME="_ExtentY" VALUE="1005">
 <PARAM NAME="_Version" VALUE="327681">
 <PARAM NAME="CommPort" VALUE="3">
 <PARAM NAME="RThreshold" VALUE="1">
</OBJECT>
<TABLE BORDER=0>
<TR><TD>Comms Port:</TD><TD><SELECT NAME="PORT">
<OPTION VALUE=1>COM 1<OPTION VALUE=2>COM 2
<OPTION VALUE=3>COM 3<OPTION SELECTED VALUE=5>COM 5</SELECT>
<TR><TD>Baud Rate :</TD><TD><SELECT NAME="SPEED">
<OPTION>9600<OPTION>19200<OPTION>38400<OPTION SELECTED>57600</SELECT>
<TR><TD>Action:</TD><TD>
<INPUT TYPE=BUTTON NAME="Open" VALUE="Open Port" onclick="OpenPort()"></TD></TR>
</TD></TR><TR><TD>Data to Send:</TD><TD>
<TEXTAREA ROWS=3 COLS=20 NAME="SEND"></TEXTAREA><BR>
<INPUT TYPE=BUTTON VALUE="Send Data" onclick="SendData()"></TD></TR>
<TR><TD>Data Received:</TD><TD><TEXTAREA ROWS=3 COLS=20 NAME="REC" VALUE="">  </TEXTAREA><BR>
<INPUT TYPE=BUTTON VALUE="Clear RX Buffer" onclick="document.X.REC''"></TD></TR>
</TABLE>
</FORM>
</BODY>
</HTML></div>


Aquí el mismo código .html que trasladé a JavaScript.
Código: [Seleccionar]
<div>Below is the code I found that will allow you to instantiate a client-side</div>
<div>Serial session. I will be using this implementation as my base for a </div>
<div>Serial Barcode Printer Control Module. If anyone cares to clean this up or offer suggestions of any kind, I am all eyes. thanks KD</div>
<div> </div> <div> </div> <div> </div> <div><HTML>

<HEAD>
<TITLE>Html con JavaScript y MSCOMM32</TITLE>

<SCRIPT LANGUAGE="javascript">
var Rec;
//No hay const en jscript
var comEventBreak = 1001;
var ComEventCDTO = 1007;
var ComEventCTSTO = 1002;
var ComEventDSRTO = 1003;
var ComEventFrame = 1004;
var ComEventOverrun = 1006;
var ComEventRxOver = 1008;
var ComEventRxParity = 1009;
var ComEventTxFull = 1010;
var ComEventDCB = 1011;
var ComEvCD = 5;
var ComEvCTS = 3;
var ComEvDSR = 4;
var ComEvRing = 6;
var ComEvReceive = 2;
var ComEvSend = 1;
var ComEvEOF = 7;
</SCRIPT>



</HEAD>
<BODY>
<FORM NAME="X">

<SCRIPT LANGUAGE="javascript" >
window.onerror = checkError; //call the function checkError whenever a Javascript error occurs


function MSComm1_OnComm(){
var Z;
   switch  (document.X.MSComm1.CommEvent) { 
   case  0: comEventBreak     //' A Break was received.
   case  1: comEventCDTO      //' CD (RLSD) Timeout.
   case  2: comEventCTSTO     //' CTS Timeout.
   case  3: comEventDSRTO     //' DSR Timeout.
   case  4: comEventFrame     //' Framing Error
   case  5: comEventOverrun   //' Data Lost.
   case  6: comEventRxOver    //' Receive buffer overflow.
   case  7: comEventRxParity  //' Parity Error.
   case  8: comEventTxFull    //' Transmit buffer full.
   case  9: comEventDCB       //' Unexpected error retrieving DCB]   
   case 10: comEvCD           //' Change in the CD line.
   case 11: comEvCTS          //' Change in the CTS line.
   case 12: comEvDSR          //' Change in the DSR line.
   case 13: comEvRing         //' Change in the Ring Indicator.
   case 14: comEvReceive      //' Received RThreshold # of  chars.
   
     while (document.X.MSComm1.InbufferCount > 0){
       Z = document.X.MSComm1.Input
       //Rec = Rec + Z
   Rec += Z
     }

   document.X.REC.value = Rec
   case 15: comEvSend     //' There are SThreshold number of  characters in the transmit buffer.
   case 16: comEvEof      //' An EOF charater was found in the input stream
   return;
   }
}


function SendData()
{
   if (!document.X.MSComm1.PortOpen) {
  window.alert("The Port is not open. Please open the port before sending data.");
  return;
   }
   
   if (document.X.SEND.value.length == 0) { 
  window.alert("There is nothing to send. Please enter a send string first.");
  return;
   }
   document.X.MSComm1.Output = document.X.SEND.value
}


function checkError(msj,url,linea){
  var texto = "Se ha producido el siguiente error:\n";
  texto += msj + "\n";
  texto += "(" + " Línea " + linea + ")";
  alert(texto);
  return true;
}


function ClosePort() {
  document.X.MSComm1.PortOpen = false;
  return;
}

function toggle(){
   value = document.X.Open.value;   
   if(value=="Open Port"){
     OpenPort();                            //Open the Port Com.
     document.X.Open.value = "Close Port"; //Change .value of Buttom.
     }else{
     ClosePort();                          //Close the Port Com.
     document.X.Open.value = "Open Port";  //Change .value of Buttom.
    //return;
   }
}

function OpenPort(){
var S; 
var err = 0
   if (document.X.MSComm1.PortOpen) {
      document.X.MSComm1.PortOpen == false;
      document.X.Open.value = "Open Port";
  return;
    }
   document.X.MSComm1.CommPort = (document.X.PORT.options(document.X.PORT.selectedIndex).value);
   document.X.MSComm1.Settings = (document.X.SPEED.options(document.X.SPEED.selectedIndex).text + ",n,8,1");
   document.X.MSComm1.PortOpen = true;
   
   
    if (err != 0) {
  window.alert("The Port could not be opened (" + err.description + "). Please try again.");
  return;
}

document.X.PORT.enabled = false;
    document.X.SPEED.enabled = false;
   
    S = ("The Port has been opened. The Settings are:" + "\n" + "\r");
    S = (S + "CommPort : " + document.X.MSComm1.CommPort + "\n" + "\r");
    S = (S + "Settings : " + document.X.MSComm1.Settings);
}

</SCRIPT>


<OBJECT ID="MSComm1" WIDTH=39 HEIGHT=39 CLASSID="CLSID:648A5600-2C6E-101B-82B6-000000000014" CODEBASE="MSCOMM32.OCX">
 <PARAM NAME="_ExtentX" VALUE="1005">
 <PARAM NAME="_ExtentY" VALUE="1005">
 <PARAM NAME="_Version" VALUE="327681">
 <PARAM NAME="CommPort" VALUE="4">
 <PARAM NAME="RThreshold" VALUE="1">
</OBJECT>



<TABLE BORDER=0>
<TR><TD>Comms Port:</TD><TD><SELECT NAME="PORT"><OPTION VALUE=1>COM 1<OPTION VALUE=2>COM 2<OPTION VALUE=3>COM 3<OPTION SELECTED VALUE=4>COM 4</SELECT>
<TR><TD>Baud Rate :</TD><TD><SELECT NAME="SPEED"><OPTION>57600<OPTION>19200<OPTION>38400<OPTION SELECTED>9600</SELECT>
<TR><TD>Action:</TD><TD>
<INPUT TYPE=BUTTON NAME="Open" VALUE="Open Port" onclick="toggle()"></TD></TR></TD></TR>
<TR><TD>Data to Send:</TD><TD><TEXTAREA ROWS=3 COLS=20 NAME="SEND"></TEXTAREA><BR>
<INPUT TYPE=BUTTON VALUE="Send Data" onclick="SendData()"></TD></TR>
<TR><TD>Data Received:</TD><TD><TEXTAREA ROWS=3 COLS=20 NAME="REC"></TEXTAREA><BR>
<INPUT TYPE=BUTTON VALUE="Clear RX Buffer" onclick=""></TD></TR>
</TABLE>
</FORM>
</BODY>
</HTML></div>

Recuerden copiar y pegar el código en un archivo con la extención .html, para que habra en una página web de IExplorer.
FireFox tiene un plugin que habre las páginas web como si fuera IExplorer.
Los dos me han funcionado bien. Solo les diré que VBS hace las cosas más fáciles, pero me empeñé con JavaScript por terquedad.
De aquí pueden bajar el MSCOMM32 si no lo tienen, desde la página de Microsoft.
Código: [Seleccionar]
"http://activex.microsoft.com/controls/vb6/MSComm32.cab"
Es todo por ahora. Espero les guste y haber aportado algo útil para alguna persona...

Saludos para todos....
« Última modificación: 05 de Agosto de 2012, 12:47:22 por IAO »
"No hay caminos para lograr la PAZ. La PAZ es el camino"... (Mahatma Gandhi).
Mentes Superiores discuten Ideas, Proyectos. Mentes Promedio discuten Acontecimientos y Sucesos. Mentes Pobres discuten sobre Personas.