In Inno Setup, how can I simulate moving the mouse

2019-08-31 09:05发布

问题:

I need to get an icon to disappear out of the system tray. When I move the mouse over it, it does disappear. Can I get Inno Setup to simulate the mouse movements? I found some Pascal code online but can't get it to run in Inno. Maybe I'm missing something easy.

uses 
.... probably not all of these are necessary, but jwawinuser is at least....
  JwaTlHelp32 {for running processes},
  JwaWinType {for processes declarations},
  JwaWinBase {just a guess: for closing process handles},
  JwaWinSvc {for services declarations, always required},
  jwawinuser {for clearing tray icon/notification area},
....
procedure CleanSystemTray;
  {description Clean dead icons from system tray/notification area}
var
  hNotificationArea: HWND;
  r: RECT;
  x: integer;
  y: integer;
begin
  hNotificationArea:=FindWindowEx(
    FindWindowEx(FindWindowEx(FindWindowEx
    (0,0,'Shell_TrayWnd', ''),0,'TrayNotifyWnd', ''),0,'SysPager',''),
    0,
    'ToolbarWindow32',
    'Notification Area');
  GetClientRect(hNotificationArea,r);

  //Now we've got the area, force it to update
  //by sending mouse messages to it.
  x:=0;
  y:=0;
  while x < r.Right do begin
    while y < r.Bottom do begin
      SendMessage(hNotificationArea, WM_MOUSEMOVE, 0, (y shl 16) + x);
      y:=y+5;
    end;
    x:=x+5;
  end;
end;