GARANTIR DESCONTO

Fórum Capturar mensagens vindas do Net Send? #319441

18/04/2006

0

tem como fazer isso?
quero criar um log, pois, aqui na empresa usamos muito esse recurso de enviar mensagens através do Net Send e gostaria de que. quando o usuário recebesse uma mesagem essa mensagem fosse jogado em um memo que tenho no meu aplicativo, pq, ai ele poderia tirar o aviso da tela e ler outra hora... :roll:


Paullsoftware

Paullsoftware

Responder

Posts

19/04/2006

Paullsoftware

será que usando findwindow funciona?
e como eu faço pra copiar o conteúdo da janela?
alguém tem uma ideia?


Responder

Gostei + 0

26/04/2006

Paulocesar1301

Óbvio que reinventar a roda nem sempre é uma boa prática, mas já pensou em fazer o ´seu´ próprio NETSend ?
Um Client/Server resolveria facilmente seu problema.


Responder

Gostei + 0

26/04/2006

Paullsoftware

certo, mais na o intuito da empresa onde trabalho é, capturar as mensagens enviadas e recebidas para saber pq está ocorrendo tantos erros nos cadastros, foi detectado que era devido ao uso abusivo desse recurso, que é usado pelos administradores para manter contato com os usuários, porém a sempre os que sabem usar e aproveitam o recurso para ficarem vamos dizer assim ´batendo papo´ e os administradores da empresa me pediram para fazer algo q capture essas mensagens... entendeu agora pq tenho q capturar?


Responder

Gostei + 0

26/04/2006

Paulocesar1301

Tens que capturar a msg dentro da janela... tentei cap um lagel ou coisa do gênero, mas não é não !!


Responder

Gostei + 0

11/10/2007

Hlino

import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.text.*;
import java.util.regex.*;

/****/
public class NetSendGUI extends JFrame implements ActionListener{
/****/
private JComboBox to = new JComboBox();
private JTextArea message = new JTextArea(10,30);
private JButton btnRefresh = new JButton("Refresh");
private JButton btnSend = new JButton("Send");
private JLabel lblStatus = new JLabel();


/* remove trailing whitespace */
    public static String rtrim(String source) {
        return source.replaceAll("\\s+$", "");
    }
    
    public void showException(Exception e){
    JOptionPane.showMessageDialog(null,e.toString());
}
    
/****/
public void loadTo(){
//
setTitle("NetSendGUI by HLINO");

//clean
to.removeAll();
    try {
        // Execute command
        String command = "cmd /c net view";
        Process child = Runtime.getRuntime().exec(command);
    
        // Get the input stream and read from it
        InputStream in = child.getInputStream();
        int c;
        String line = new String();
        //
        while ((c = in.read()) != -1) {
        //enter
        if((char)c == ´\n´){
        //startsWith
        if(line.indexOf("\\") != -1){
        rtrim(line);
        line = line.replaceAll("\n","");
        line = line.replace("\\","");
        to.addItem(line); 
        }
        //
        line = "";
        }
        //
            line = line + (char)c;
         }
        in.close();
    } catch (IOException e) {
    showException(e);
    }
}

/****/
public String netSend(){
    String line = new String();
try{
String ip = to.getSelectedItem().toString();
        String command = "cmd /c net send " + ip + " \"" +  message.getText() +"\"";
        System.out.println(command);
        Process child = Runtime.getRuntime().exec(command);

        // Get the input stream and read from it
        InputStream in = child.getInputStream();
        int c;
        //
        while ((c = in.read()) != -1) {
        //
            line = line + (char)c;
         }
        in.close();
        
}catch(IOException e){
showException(e);
}
return line;
    }

    /****/
public NetSendGUI(){
//
setLayout( new BorderLayout() );
//
add(to, BorderLayout.NORTH);
add(new JScrollPane(message), BorderLayout.CENTER);
JPanel pSouth = new JPanel();
pSouth.setLayout( new BorderLayout() );

JPanel pButton = new JPanel();
//
pButton.add(btnRefresh);
pButton.add(btnSend);
//
btnSend.setMnemonic(´s´);
btnRefresh.setMnemonic(´r´);

pSouth.add(lblStatus, BorderLayout.NORTH);
pSouth.add(pButton, BorderLayout.CENTER);

//
add(pSouth, BorderLayout.SOUTH);
//
loadTo();
//
to.addActionListener(this);
btnRefresh.addActionListener(this);
btnSend.addActionListener(this);
//
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
//pack
pack();
//center
setLocationRelativeTo(null);
//visible
setVisible(true);
}

/****/
public void refresh(){
loadTo();
this.lblStatus.setText("");
this.to.requestFocus(true);
}

/**
  * @param message
  **/
public void setStatus(String message){
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat ("HH:mm:ss");

this.lblStatus.setText( "[" + sdf.format( d ) + "] : " + message);
}

/**
  * @param e
  **/
public void actionPerformed(ActionEvent e){
if(e.getSource() == to){
message.requestFocus(true);
}
else if(e.getSource() == btnSend){
String sReturn = netSend();
setStatus(sReturn);
message.requestFocus(true);

}
else if(e.getSource() == btnRefresh){
refresh();
}
}
/**
  * @param args
  **/
public static void main(String args[]){
//
new NetSendGUI();
}
}



Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar