1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62:
| unit Unitapm;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, APM, ExtCtrls;
const PBT_APMQUERYSUSPEND = 0; PBT_APMQUERYSUSPENDFAILED = 2; PBT_APMSUSPEND = 4; PBT_APMRESUMECRITICAL = 6; PBT_APMRESUMESUSPEND = 7; PBT_APMBATTERYLOW = 9; PBT_APMPOWERSTATUSCHANGE = 10; PBT_APMOEMEVENT = 11;
type TForm1 = class(TForm) procedure WMPOWER( var Message: TMessage); message WM_POWER; private
public end;
var Form1: TForm1;
implementation
{$R *.DFM}
procedure doWinampCommand( const i1: integer); var h: integer; begin h := FindWindow('Winamp v1.x', nil); sendMessage(h, WM_COMMAND, i1, 0); end;
procedure SysFoucs(hWnd:integer); begin setfocus(hWnd); SetwindowPos(hwnd,HWND_BOTTOM,0,0,0,0,0); end;
procedure TForm1.WMPOWER( var Message: TMessage); var hWnd:integer; begin case Message.WParam of PWR_SUSPENDREQUEST: Message.Result := PWR_FAIL; else defaultHandler( Message); end; doWinampCommand(40048); hWnd:=FindWindow(pchar('#32770'),nil); SysFoucs(hWnd); keybd_event(Ord(13), 0, 0, 0); end; end. |