Guest User

Untitled

a guest
Sep 24th, 2011
157
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "mainwindow.h"
  2.  
  3. BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lp)
  4.   {
  5.     WCHAR str[256];
  6.     GetWindowText(hWnd,str,256);
  7.  
  8.     QString s(QString::fromWCharArray(str));
  9.     if ( s.size() && s.contains("loopbe") )
  10.       {
  11.         //qDebug() << s;
  12.  
  13.         HWND wnd = GetWindow(hWnd,GW_CHILD);
  14.         while ( wnd != NULL )
  15.           {
  16.             WCHAR wndName[1024];
  17.             WCHAR wndClassName[1024];
  18.  
  19.             GetWindowText(wnd,wndName,1024);
  20.             GetClassName(wnd,wndClassName,1024);
  21.  
  22.             //qDebug() << GetWindowLong(wnd,GWL_STYLE) << QString::fromWCharArray(wndClassName) << QString::fromWCharArray(wndName);
  23.  
  24.             if ( QString::fromWCharArray(wndName) == "Mute" )
  25.               {
  26.                 // LRESULT state = SendMessage(wnd,BM_GETSTATE,0,0);
  27.                 //qDebug() << state;
  28.                 //if (  )
  29.                   {
  30.                     SendMessage(wnd,BM_SETCHECK,BST_CHECKED,0);
  31.                     SendMessage(wnd,BM_CLICK,0,0);
  32.                   }
  33.               }
  34.  
  35.             wnd = GetWindow(wnd,GW_HWNDNEXT);
  36.           }
  37.  
  38.         return false;
  39.       }
  40.     return true;
  41.   }
  42.  
  43. void MainWindow::editChanged(QString str)
  44.   {
  45.     timer->setInterval(str.toInt());
  46.   }
  47.  
  48. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
  49.   {
  50.     timer = new QTimer(this);
  51.     connect ( timer,SIGNAL(timeout()),this,SLOT(checkstate()) );
  52.     le = new QLineEdit( "10" );
  53.     connect ( le,SIGNAL(textChanged(QString)),this, SLOT(editChanged(QString)) );
  54.     setCentralWidget ( le );
  55.  
  56.  
  57.  
  58.     timer->start(10);
  59.  
  60.   }
  61.  
  62. void MainWindow::checkstate()
  63.   {
  64.     while (EnumWindows(EnumWindowsProc,1L));
  65.   }
  66.  
  67. MainWindow::~MainWindow()
  68. {
  69.  
  70. }
RAW Paste Data