首页  编辑  

Taskbar AutoHide

Tags: /超级猛料/OS.操作系统/任务栏/   Date Created:

taskbar options are stored somewhere around

 \Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Desktop

in the registry as a large block of binary data. Also, AFAIK,

Microsoft provide no APIs to manipulate this data.

下面用模拟Windows任务栏属性操作的方法来做到,方法很笨,但是有效(Windows XP Prof 中文版,其他版本可能需要相应修改):

procedure KeyAutoHide ;

var

  Shell_TrayWnd : HWND ;

  P_Wnd : HWND ;

  R : TRect ;

  iCount : integer ;

begin

  Shell_TrayWnd := FindWindow ( 'Shell_TrayWnd' , nil );

  SetForegroundWindow ( Shell_TrayWnd );

  GetWindowRect ( Shell_TrayWnd , r );

  setcursorpos ( r . Right - 1 , r . Bottom - 1 );

  Mouse_Event ( MOUSEEVENTF_RIGHTDOWN , r . Right - 1 , r . Bottom - 1 , 0 , 0 );

  Mouse_Event ( MOUSEEVENTF_RIGHTUP , r . Right - 1 , r . Bottom - 1 , 0 , 0 );

  keybd_event ( ord ( 'R' ), 0 , KEYEVENTF_EXTENDEDKEY , 0 ); //KEYDOWN£¬

  keybd_event ( ord ( 'R' ), 0 , KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP , 0 ); //KEYUP

  P_Wnd := 0 ;

  iCount := 0 ;

  while P_Wnd = 0 do

  begin

    P_Wnd := FindWindow ( '#32770' , ' 任务栏和「开始」菜单属性 ' );

    Sleep ( 0 );

    Inc ( iCount );

    if iCount > 65535 then Exit ;

  end ;

  SetWindowPos ( P_Wnd , HWND_TOP , 0 , 0 , 1 , 1 , SWP_NOMOVE );

  keybd_event ( ord ( 'U' ), 0 , KEYEVENTF_EXTENDEDKEY , 0 ); //KEYDOWN£¬

  keybd_event ( ord ( 'U' ), 0 , KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP , 0 ); //KEYUP

  //  { Under WinXP:1102:Control ID of 'Auto Hide' }

  //  CheckDlgButton(FindWindowEx(P_Wnd,0,'SysTabControl32',nil), 1102, BST_CHECKED);

  PostMessage ( P_Wnd , WM_KEYDOWN , VK_RETURN , 0 );

  PostMessage ( P_Wnd , WM_KEYUP , VK_RETURN , 0 );

end ;