Date: 02/02/07 (Code WTF) Keywords: no keywords http://www.gamedev.ru/flame/forum/?id=6 procedure TForm1.Button1Click(Sender: TObject); var hCalc, hCalcEdit: HWND; hCalcMenu, hCalcSubMenu: HMENU; hCalcSubMenuID0, hCalcSubMenuID1: DWORD; ClipBoard: TClipboard; begin if Not FileExists('C:\Windows\system32\calc.exe') then begin ShowMessage('Error!'); Exit; end; hCalc := FindWindow('SciCalc', 0); if hCalc = 0 then begin ShellExecute(0, 'Open', 'C:\Windows\system32\calc.exe', Nil, Nil, SW_SHOWNORMAL); repeat hCalc := FindWindow('SciCalc', HWND(Nil)); until hCalc <> 0; end; hCalcEdit := FindWindowEx(hCalc, 0, 'Edit', ''); ClipBoard := TClipboard.Create; ClipBoard.SetTextBuf(PChar(Edit1.Text)); hCalcMenu := GetMenu(hCalc); hCalcSubMenu := GetSubMenu(hCalcMenu, 0); hCalcSubMenuID0 := GetMenuItemID(hCalcSubMenu, 0); hCalcSubMenuID1 := GetMenuItemID(hCalcSubMenu, 1); PostMessage(hCalc, WM_COMMAND, hCalcSubMenuID1, 0); repeat PostMessage(hCalc, WM_COMMAND, hCalcSubMenuID0, 0); RichEdit1.Clear; RichEdit1.PasteFromClipboard; until (StrComp(PChar(RichEdit1.Text), PChar(Edit1.Text)) <> 0) And (StrLen(PChar(RichEdit1.Text)) <> 0); end; Source: http://community.livejournal.com/code_wtf/66997.html
|