Delphi Hint - How to Programmatically press the "Start" Button

'

This sample source code shows you how to show the Start menu using Delphi

procedure TForm1.PressStart(Sender: TObject);
var
 hTaskBar, hButton : HWND;
 hDCScreen : HDC;
 ScreenHeight : DWORD;
begin
  //find "Start" button
  hDCScreen := GetDC(0);
  ScreenHeight :=GetDeviceCaps(hDCScreen,VERTRES);
  ReleaseDC(0, hDCScreen);
  hTaskBar := FindWindow('Shell_TrayWnd', nil);
  hButton := GetWindow(hTaskBar, GW_CHILD);

  //press "Start" button
  SendMessage(hButton, WM_LBUTTONDOWN,MK_LBUTTON,LOWORD(5)+
    HIWORD(ScreenHeight-20));

  //hide "Start" button
  ShowWindow(hButton, SW_HIDE);
  Sleep(2000);
  //show "Start" button
  ShowWindow(hButton, SW_NORMAL);
end;

Google
Web www.Delphi-Central.com
Delphi Central - Delphi Programming Tutorials, Hints and Tips