QScreenShot
::QScreenShot(QWidget *parent
) : ui(new Ui::QScreenShot)
{
ui->setupUi(this);
c=0;
bool ok=false;
QString dateTimeString
= dateTime.
toString();
QDir().
mkdir("D:\\QtImages\\");
QDir().
setCurrent("D:\\QtImages\\");
QDir().
mkdir("ScreenShots");
QDir().
setCurrent("ScreenShots");
QDir().
mkdir(dateTimeString
);
for(int i=0;i<list.length();i++)
{
driveList += list[i];
}
//QMessageBox::warning(NULL,"DriveList",driveList,QMessageBox::Ok);
db.setDatabaseName("DRIVER={MYSQL ODBC 3.51 Driver};FIL={MYSQL};DBQ=screengrabber");
db.setHostName("localhost");
db.setConnectOptions("CLIENT_ODBC");
//db.setDatabaseName("screengrabber");
db.setUserName("root");
db.setPassword("1");
ok = db.open();
for(;;)
{
strfname.sprintf("%d",c);
originalPixmap.save("D:\\image"+strfname+".jpeg","jpeg");
c++;
char Data;
QFile file("D:\\image"+strfname
+".jpeg");
file.seek(0);
buf=file.read(250000);
query.prepare("INSERT INTO log VALUES('grab_date='2011-04-26 15:55:09',ip_address='172.16.0.51',image=:val');");
query.bindValue ( ":val", buf);
strquery = "INSERT INTO log (grab_date,ip_address,image) VALUES ( '";
strquery += '2011-04-26 15:55:09';
strquery += "' , '";
strquery += '172.16.0.51';
strquery += "' , ";
strquery += buf;
strquery += " );";
//QMessageBox::warning(NULL,"DriveList",strquery,QMessageBox::Ok);
bool done = insertQuery.exec();
QFile newfile
("D:\\img.txt");
newfile.write(buf);
int iSecret, iRandom;
iSecret = rand() % 20 + 1;
iRandom=iSecret*60000;
mutex.lock();
waitCondition.wait(&mutex, iRandom);
mutex.unlock();
}
}
QScreenShot::QScreenShot(QWidget *parent) :
QDialog(parent),
ui(new Ui::QScreenShot)
{
ui->setupUi(this);
c=0;
bool ok=false;
QDateTime dateTime = QDateTime::currentDateTime();
QString dateTimeString = dateTime.toString();
QDir().mkdir("D:\\QtImages\\");
QDir().setCurrent("D:\\QtImages\\");
QDir().mkdir("ScreenShots");
QDir().setCurrent("ScreenShots");
QDir().mkdir(dateTimeString);
QMessageBox::warning(NULL,"DriveList",dateTimeString,QMessageBox::Ok);
QStringList list=QSqlDatabase::drivers();
QString driveList;
for(int i=0;i<list.length();i++)
{
driveList += list[i];
}
//QMessageBox::warning(NULL,"DriveList",driveList,QMessageBox::Ok);
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DRIVER={MYSQL ODBC 3.51 Driver};FIL={MYSQL};DBQ=screengrabber");
db.setHostName("localhost");
db.setConnectOptions("CLIENT_ODBC");
//db.setDatabaseName("screengrabber");
db.setUserName("root");
db.setPassword("1");
ok = db.open();
for(;;)
{
originalPixmap =QPixmap();
originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId());
QString strfname;
strfname.sprintf("%d",c);
originalPixmap.save("D:\\image"+strfname+".jpeg","jpeg");
c++;
char Data;
QFile file("D:\\image"+strfname+".jpeg");
file.open(QIODevice::ReadOnly);
file.seek(0);
QByteArray buf;
buf=file.read(250000);
QSqlQuery query;
query.prepare("INSERT INTO log VALUES('grab_date='2011-04-26 15:55:09',ip_address='172.16.0.51',image=:val');");
query.bindValue ( ":val", buf);
QString strquery;
strquery = "INSERT INTO log (grab_date,ip_address,image) VALUES ( '";
strquery += '2011-04-26 15:55:09';
strquery += "' , '";
strquery += '172.16.0.51';
strquery += "' , ";
strquery += buf;
strquery += " );";
//QMessageBox::warning(NULL,"DriveList",strquery,QMessageBox::Ok);
QSqlQuery insertQuery( strquery, db);
bool done = insertQuery.exec();
QFile newfile("D:\\img.txt");
newfile.open(QIODevice::WriteOnly);
newfile.write(buf);
int iSecret, iRandom;
iSecret = rand() % 20 + 1;
iRandom=iSecret*60000;
QMutex mutex;
mutex.lock();
QWaitCondition waitCondition;
waitCondition.wait(&mutex, iRandom);
mutex.unlock();
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks