📄 main.pas
字号:
cAdvVideoSWIncContrastCmd = $3128;
cAdvVideoSWBaseContrastCmd= $3129;
cAdvVideoSWDecContrastCmd = $312A;
cAudioIncVolumeCmd = $012C;
cAudioDecVolumeCmd = $012D;
cAudioMuteVolumeCmd = $012E;
cAudioDecAmpCmd = $012F;
cAudioIncAmpCmd = $0130;
cAudioUseEqulizerCmd = $0131;
cAudioEqulizerPresetMenu = $0132;
cAudioEqulizerFreqDomain = $2132; // 眠啊 2.3.905...
cAudioEqulizerTimeDomain = $2133; // 眠啊 2.3.905...
cAudioEqulizerDirectX = $2134; // 眠啊 2.3.905...
cAudioRemoveLeftChCmd = $0133;
cAudioRemoveRightChCmd = $0134;
cAudioSwapChCmd = $0135;
cAudioMergeChCmd = $0136;
cAudioVioceRemoveCmd = $0137;
cAudioViocePassCmd = $0138;
cAudioUseDynamicAmpCmd = $2138; // 眠啊 2.3.905...
cAudioUseAutoGainCmd = $3310; // 眠啊 2.3.905...
cAudioUseEchoCmd = $2139; // 眠啊 2.3.905...
cAudioSlowerEchoCmd = $0139;
cAudioFasterEchoCmd = $013A;
cAudioUseBandPassCmd = $223A; // 眠啊 2.3.905...
cAudioUseTrueBassCmd = $223B; // 眠啊 2.3.905...
cAudioUseTrebleEhnCmd = $223C; // 眠啊 2.3.905...
cAudioUseTempoCmd = $023A;
cAudioSlowerPitchCmd = $014B;
cAudioFasterPitchCmd = $014C;
cAudioUse3DEffectCmd = $014D;
cAudioDec3DEffectCmd = $014E;
cAudioInc3DEffectCmd = $014F;
cAudioIgnoreSettingCmd = $0150;
cAudioUsePluginCmd = $0151;
cCaptureAVIMovieCmd = $0152;
cCaptureAVIAutoCmd = $0153;
cCaptureCurScrFileCmd = $0154;
cCaptureCurScrTimeCmd = $0155;
cCaptureCurScrClipBoardCmd= $0156;
cCaptureSampleGrabberCmd = $0157;
cCaptureDesktopCenterCmd = $0158;
cCaptureDesktopTileCmd = $0159;
cCaptureDesktopStretchCmd = $015A;
cCaptureSelectFolderCmd = $015B;
cCaptureOpenFolderCmd = $015C;
cVisWaveFormCmd = $015D;
cVisFreqCmd = $015E;
cVisWaveFreqCmd = $015F;
cVisWinMediaVisCmd = $0160;
cVisSimpleCmd = $0161;
cVisBlackCmd = $0162;
cVisPrevVisCmd = $0163;
cVisNextVisCmd = $0164;
cBookmarkAddCmd = $0165;
cConfigureViewCmd = $0167;
cPlaylistViewCmd = $0168;
cControlBoxViewCmd = $0169;
cAdvMenuViewCmd = $016A;
cPlayInfoViewCmd = $016B;
cHelpViewCmd = $016C;
cAboutViewCmd = $016D;
cURLOpenCmd = $016E;
cSkinNormalControlSkin = $016F;
cSkinAutoHideControlSkin = $0172;
cSkinOSCControlSkin = $0170;
cSkinBothControlSkin = $0171;
cSkinChangeCmd = $1171;
cPlayListPopupMenu = $0190;
cPlayListAddFileCmd = $0191;
cPlayListAddFolderCmd = $0192;
cPlayListClearAllCmd = $0193;
cWDMChannel0Cmd = $0294;
cWDMChannel1Cmd = $0295;
cWDMChannel2Cmd = $0296;
cWDMChannel3Cmd = $0297;
cWDMChannel4Cmd = $0298;
cWDMChannel5Cmd = $0299;
cWDMChannel6Cmd = $029A;
cWDMChannel7Cmd = $029B;
cWDMChannel8Cmd = $029C;
cWDMChannel9Cmd = $029D;
cWDMChannelSetCmd = $029E;
cWinampMediaLibCmd = $029F;
cViewFileInfoCmd = $0230;
cSearchAnyFileCmd = $0231;
// cNothingDoCmd = $0232;
cColorThemeMenu = $0235;
cColorThemeRandomCmd = $0236;
cColorThemeCycleCmd = $0237;
cDVDRelativeButton = $210000;
cDVDActivateButton = $210001;
cDVDGetSelectedButton = $210002;
cGetPlayModeCmd = $220000; // 0 : Normal, 1 : DVD, 2 : WDM, 3 : Audio, 4: Video
cGetIsPopupMenu = $220001;
cCaptureClipToAVICmd = $024A;
WM_SKINBTNMESSAGE = WM_USER+1218;
sRegistryKey = '\Software\KMPlayer\';
sIdentfyString = 'KMP2.0';
sOptionArea = 'OptionArea';
sInstallPath = 'InstallPath';
function GetKMPPath : string;
var
reg : TRegistry;
begin
Result:='c:\Program Files\The KMPlayer\KMPlayer.exe';
try
reg:=TRegistry.Create;
try
reg.RootKey:=HKEY_CURRENT_USER;
if reg.OpenKey(sRegistryKey+sIdentfyString+'\'+sOptionArea,False) then begin
try
if reg.ValueExists(sInstallPath) then Result:=reg.ReadString(sInstallPath);
except
end;
reg.CloseKey;
end;
finally
reg.Free;
end;
except
end;
end;
function GetKMPHandle : THandle;
begin
with TSharedMem.Create(Application) do begin
MapName:=sIdentfyString;
Active:=True;
Result:=pInteger(Buffer+4)^;
if IsWindow(Result)=False then Result:=0;
Free;
end;
end;
{ TMainForm }
procedure Gen_KeyEvent(aa : integer);
var
dx,dy,flag : integer;
begin
dx:=(aa shr 16) and $ff;
dy:=aa; // virtual key
flag:=0;
if (aa and (1 shl 24)<>0) then flag:=KEYEVENTF_EXTENDEDKEY;
if (aa and (1 shl 31)<>0) then flag:=flag or KEYEVENTF_KEYUP;
keybd_event(dy,dx,flag,0);
end;
procedure TMainForm.HSerialPort1RxChar(Sender: TObject; ResvSize: Integer);
var
str : string;
han : THandle;
cmd,mode,selected : integer;
isActive : Boolean;
const
DVD_Relative_Upper = 1;
DVD_Relative_Lower = 2;
DVD_Relative_Left = 3;
DVD_Relative_Right = 4;
begin
HSerialPort1.ReadString(str,ResvSize);
if Pos('OK',str)>0 then FInited:=True;
han:=GetKMPHandle;
if str=#1#0#0#0#0#0 then begin
inc(FLastCnt);
if FLastCnt>=4 then str:=FLastString;
end;
if(GetTickCount-FOldTick)>200 then FLastCnt:=0;
FOldTick:=GetTickCount;
if (ResvSize=6) and (str[1]='0') then begin
if FLastString<>str then FLastCnt:=0;
FLastString:=str;
cmd:=Byte(str[3]);
mode:=SendMessage(han,WM_SKINBTNMESSAGE,cGetPlayModeCmd,0); // 0 : Normal, 1 : DVD, 2 : WDM, 3 : Audio, 4: Video
isActive:=(han=GetForegroundWindow); // 劝己拳等 芒牢瘤 八荤
if isActive then isActive:=SendMessage(han,WM_SKINBTNMESSAGE,cGetIsPopupMenu,0)=0; // 皋春啊 祁媚廉 乐绰瘤 八荤
selected:=SendMessage(han,WM_SKINBTNMESSAGE,cDVDGetSelectedButton,0); // 0焊促 农搁 DVD Menu 粮犁
case cmd of // 滚畔俊 蝶扼辑 贸府~~
0 : begin
if han=0 then begin
str:=GetKMPPath;
ShellExecute(0,'open',pchar(str),'','',SW_SHOW);
end
else PostMessage(han,WM_SKINBTNMESSAGE,cExitCmd,0);
end;
1 : if mode=2 then PostMessage(han,WM_SKINBTNMESSAGE,cWDMChannelSetCmd,0)
else if mode=0 then PostMessage(han,WM_SKINBTNMESSAGE,cOpenRecentCmd,0);
2..9 : begin
if mode=0 then begin
if cmd=2 then PostMessage(han,WM_SKINBTNMESSAGE,cOpenTVOutCmd,0)
else if cmd=3 then PostMessage(han,WM_SKINBTNMESSAGE,cOpenDVDDeviceCmd,0)
else if cmd=4 then PostMessage(han,WM_SKINBTNMESSAGE,cOpenBaseWDMCmd,0);
end
else if mode=2 then PostMessage(han,WM_SKINBTNMESSAGE,cWDMChannel1Cmd+cmd-2,0)
else Gen_KeyEvent(Byte('0')+cmd-1);
end;
16 : if mode=2 then PostMessage(han,WM_SKINBTNMESSAGE,cWDMChannel9Cmd,0)
else PostMessage(han,WM_SKINBTNMESSAGE,cControlBoxViewCmd,0);
17 : if mode=2 then PostMessage(han,WM_SKINBTNMESSAGE,cWDMChannel0Cmd,0)
else PostMessage(han,WM_SKINBTNMESSAGE,cPlaylistViewCmd,0);
18 : if selected>0 then PostMessage(han,WM_SKINBTNMESSAGE,cDVDRelativeButton,DVD_Relative_Upper)
else if (mode=2) and isActive then Gen_KeyEvent(VK_PRIOR)
else if isActive then Gen_KeyEvent(VK_RIGHT)
else Gen_KeyEvent(VK_UP);
19 : if (selected>0) then PostMessage(han,WM_SKINBTNMESSAGE,cDVDRelativeButton,DVD_Relative_Left)
else if isActive then PostMessage(han,WM_SKINBTNMESSAGE,cAudioDecVolumeCmd,0)
else Gen_KeyEvent(VK_LEFT);
20 : if selected>0 then SendMessage(han,WM_SKINBTNMESSAGE,cDVDActivateButton,0)
else Gen_KeyEvent(VK_RETURN);
21 : if selected>0 then PostMessage(han,WM_SKINBTNMESSAGE,cDVDRelativeButton,DVD_Relative_Right)
else if isActive then PostMessage(han,WM_SKINBTNMESSAGE,cAudioIncVolumeCmd,0)
else Gen_KeyEvent(VK_RIGHT);
22 : if selected>0 then SendMessage(han,WM_SKINBTNMESSAGE,cDVDRelativeButton,DVD_Relative_Lower)
else if (mode=2) and isActive then Gen_KeyEvent(VK_NEXT)
else if isActive then Gen_KeyEvent(VK_LEFT)
else Gen_KeyEvent(VK_DOWN);
23 : if mode=1 then PostMessage(han,WM_SKINBTNMESSAGE,cDVDAudioMenuCmd,0)
else PostMessage(han,WM_SKINBTNMESSAGE,cAudioMenu,0);
24 : PostMessage(han,WM_SKINBTNMESSAGE,cAudioMuteVolumeCmd,0);
25 : if (mode=1) and isActive then PostMessage(han,WM_SKINBTNMESSAGE,cDVDSubpictureMenu,0)
else Gen_KeyEvent(VK_TAB);
32 : PostMessage(han,WM_SKINBTNMESSAGE,cDVDChapterMenuCmd,0);
33 : if mode=1 then PostMessage(han,WM_SKINBTNMESSAGE,cDVDTitleMenuCmd,0)
else PostMessage(han,WM_SKINBTNMESSAGE,cMainMenu,0);
34 : if mode=1 then PostMessage(han,WM_SKINBTNMESSAGE,cDVDRestoreMenuCmd,0)
else begin
Gen_KeyEvent(VK_ESCAPE);
end;
35 : PostMessage(han,WM_SKINBTNMESSAGE,cOpenBaseWDMCmd,0);
36 : PostMessage(han,WM_SKINBTNMESSAGE,cScreenCycleRatio,0);
37 : PostMessage(han,WM_SKINBTNMESSAGE,cCaptionVisibleCmd,0);
38 : PostMessage(han,WM_SKINBTNMESSAGE,cPlayBackward2Cmd,0);
39 : PostMessage(han,WM_SKINBTNMESSAGE,cPlayPlayCmd,0);
40 : PostMessage(han,WM_SKINBTNMESSAGE,cPlayForward2Cmd,0);
41 : PostMessage(han,WM_SKINBTNMESSAGE,cPlayPrevFileCmd,0);
48 : PostMessage(han,WM_SKINBTNMESSAGE,cPlayStopCmd,0);
49 : PostMessage(han,WM_SKINBTNMESSAGE,cPlayNextFileCmd,0);
50 : PostMessage(han,WM_SKINBTNMESSAGE,cScreenMaxSize,0);
51 : if mode=2 then PostMessage(han,WM_SKINBTNMESSAGE,cCaptureAVIMovieCmd,0)
else PostMessage(han,WM_SKINBTNMESSAGE,cCaptureClipToAVICmd,0);
end;
end;
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
FLastCnt:=0;
FOldTick:=0;
HSerialPort1:=THSerialPort.Create(Self);
HSerialPort1.OnRxChar:=HSerialPort1RxChar;
InitComport;
end;
procedure TMainForm.InitComport;
var
i,j : integer;
begin
FInited:=False;
for i:=0 to 3 do begin
HSerialPort1.Close;
HSerialPort1.Port:=TPortType(i);
HSerialPort1.Open;
if HSerialPort1.GetComHandle<>INVALID_HANDLE_VALUE then begin
Sleep(200);
HSerialPort1.WriteString('I');
HSerialPort1.WriteString('R');
j:=0;
while j<100 do begin
if FInited then break;
Sleep(10);
Application.ProcessMessages;
inc(j);
end;
if FInited then break;
end;
end;
end;
procedure TMainForm.N4Click(Sender: TObject);
begin
InitComport;
end;
procedure TMainForm.N6Click(Sender: TObject);
begin
Application.Terminate;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -