📄 untcomm.pas
字号:
{*******************************************************}
{ }
{ 手机遥控器 v1.0 }
{ }
{ 版权所有 (C) 2002, 2003 MyvNet }
{ }
{ 作者: 小冬[kendling] }
{ 邮件: kendling@sina.com }
{ 主页: http://www.MyvNet.com }
{ }
{*******************************************************}
unit UntComm;
interface
uses
//------------------------------------------------------------------------------
// COM管理
//------------------------------------------------------------------------------
CnRS232,// CnRS232Dialog,
//------------------------------------------------------------------------------
// Winamp控制
//------------------------------------------------------------------------------
CnWinampCtrl,
//------------------------------------------------------------------------------
// 语言管理
//------------------------------------------------------------------------------
CnHashLangStorage, CnLangMgr, CnLangTranslator,
//------------------------------------------------------------------------------
// 函数库
//------------------------------------------------------------------------------
Classes, SysUtils, Windows, Registry, IniFiles, frmHelp, ShellAPI;
//==============================================================================
// 数据类型
//==============================================================================
type
{ TKeyGroup }
TKeyGroup = class(TObject)
public
// Key,
// Description: TStrings;
Key: array [0..24] of string;
Description: array [0..24] of string;
constructor Create;
destructor Destroy; override;
end;
{ TProgram }
TProgram = class(TObject)
public
AppKGNum: Integer;
AppName,
AppPath: string;
constructor Create;
destructor Destroy; override;
end;
{ TPhoneCMD }
TPhoneCMD = class(TObject)
public
strCMD,
strParam: string;
constructor Create;
destructor Destroy; override;
end;
{ TApplicationNum }
TApplicationNum = (appOne, appTwo, appThree, appFour, appFive, appSix,
appSeven, appEight, appNine, appTen, appWinamp, appMouse, appNone);
{ TPhoneMenuStatus }
TPhoneMenuStatus = (pmsNone, pmsMain, pmsApplication, pmsWinamp, pmsMouse,
pmsAbout);
{ TPhoneKey }
TPhoneKey = (pkNone, pkCamaner, pkOnline, pkPUP, pkPDown, pkLeft, pkUP,
pkRight, pkDown, pkClick, pkFLeft, pkFRight, pkReturn, pkCancel, pk1, pk2,
pk3, pk4, pk5, pk6, pk7, pk8, pk9, pk10, pk11, pk12);
//==============================================================================
// 全局常量
//==============================================================================
const
//配置文件名
strCfgName = 'Setting.ini';
//软件版本
strAppVer = 'v1.0';
//建立日期
strBuild = '2005-02-15';
//播放列表页面大小
iPageSize = 9;
//是否使用UTF-8(调试用)
bUtf8 = False;
var
//==============================================================================
// 全局变量
//==============================================================================
//程序目录
strAppPath: string = '';
//语言目录
strLngPath: string = '';
//语言
strLanguage: string = '简体中文';
//所选程序
SelectApp: TApplicationNum = appNone;
//当前菜单
SelectMenu: TPhoneMenuStatus = pmsNone;
//鼠标移动方向
iMouse: Integer = 0;
//是否进入播放列表
bPlayList: Boolean = False;
//当前页数
iCurPage: Integer = 1;
//总页数
iCountPages: Integer = 1;
//播放列表当前页数
// iPlayListPage: Integer = 1;
//COM口
strComPort: string = 'COM4';
//鼠标移动速度
iMouseMoveSpeed: Byte = 4;
//自动连接
bAutoConnect: Boolean = False;
//退出时保存
bSaveInExit: Boolean = False;
//连接时静音
bConnInMute: Boolean = False;
//连接时进入主菜单
bConnInMenu: Boolean = False;
//按键组
KeyGroups: array [0..9] of TKeyGroup =
(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil);
//程序
Programs: array [0..9] of TProgram =
(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil);
//Winamp路径
strWinampPath: string = '';
//自动播放
bWinampAutoPlay: Boolean = False;
//自动退出
bWinampAutoExit: Boolean = False;
//播放列表控制
bWinampPlayList: Boolean = False;
//==============================================================================
// 全局对象
//==============================================================================
//语言管理对象
objLanguageManager: TCnLangManager = nil;
//语言文件对象
objLanguageFile: TCnHashLangFileStorage = nil;
//COM口对象
objComPort: TCnRS232 = nil;
//INI文件对象
objIniFile: TIniFile = nil;
//帮助窗口
FHelp: TFHelp = nil;
//Winamp控制对象
objWinamp: TCnWinampCtrl = nil;
//播放列表对象
objPlayList: TStrings = nil;
//==============================================================================
// 全局字符串
//==============================================================================
//打开对话框标题
strOpenDlgTitle: string = '打开';
//打开对话框文件过滤
strOpenDlgFilter: string = '应用程序(*.exe)|*.exe';
//软件名称
strAppName: string = '手机遥控器';
//帮助窗口字符串
strHelpMessage: string = '相机键: %s' + #13#10 +
'上网键: %s' + #13#10 +
'向上翻: %s' + #13#10 +
'向下翻: %s' + #13#10 +
'左: %s' + #13#10 +
'上: %s' + #13#10 +
'右: %s' + #13#10 +
'下: %s' + #13#10 +
'按控制杆: %s' + #13#10 +
'左功能键: %s' + #13#10 +
'右功能键: %s' + #13#10 +
'返回: %s' + #13#10 +
'取消: %s' + #13#10 +
'1键: %s' + #13#10 +
'2键: %s' + #13#10 +
'3键: %s' + #13#10 +
'4键: %s' + #13#10 +
'5键: %s' + #13#10 +
'6键: %s' + #13#10 +
'7键: %s' + #13#10 +
'8键: %s' + #13#10 +
'9键: %s' + #13#10 +
'0键: %s' + #13#10 +
'*键: %s' + #13#10 +
'#键: %s';
//菜单
//主菜单名称
strMainMenu: string = '手机遥控器';
//主菜单1
strMainMenu1: string = '应用程序';
//主菜单2
strMainMenu2: string = 'Winamp播放器';
//主菜单3
strMainMenu3: string = '移动鼠标';
//主菜单4
strMainMenu4: string = '关于本软件';
//Winamp菜单1
strWAMenu1: string = '上一首';
//Winamp菜单2
strWAMenu2: string = '播放/暂停';
//Winamp菜单3
strWAMenu3: string = '下一首';
//Winamp菜单4
strWAMenu4: string = '停止';
//Winamp菜单5
strWAMenu5: string = '播放列表';
//Winamp菜单6
strWAMenu6: string = '增加音量';
//Winamp菜单7
strWAMenu7: string = '减少音量';
//播放列表菜单1
strWAPLMenu1: string = '上一页';
//播放列表菜单2
strWAPLMenu2: string = '查找';
//播放列表菜单3
strWAPLMenu3: string = '下一页';
//其他字串
strNoApplication: string = '没有设定应用程序,请到选项里设置应用程序。';
strFileNoExists: string = '该程序文件不存在,请到选项里修改设置。';
strNoWinamp: string = 'Winamp路径没有设定,或不存在。';
strStartWinamp: string = 'Winamp正在启动 请稍后...';
strNoStartWinamp: string = 'Winamp没有启动 请返回主菜单重新进入';
//==============================================================================
// 手机状态变量
//==============================================================================
//静音状态
pMute: Boolean = False;
//编码状态
pCSCS: string = '';
//==============================================================================
// 全局函数
//==============================================================================
//鼠标事件
procedure MouseEvent(const iMove: Byte; const KeyDown: Boolean);
//发送按键事件
procedure SendKeyBoardEvent(const strKey: string; const KeyDown: Boolean);
//启动应用程序
procedure StartApplication(const appNum: string);
//显示帮助窗口
procedure ShowHelp;
//显示播放列表
procedure ShowPlayList(const iPage: Integer);
//处理播放列表
procedure ProcessPlayList(const iMenu: Integer);
//退出
procedure ExitFunction;
//退出应用程序
procedure ExitApplication;
//退出Winamp
procedure ExitWinamp;
//检测是否设置了程序
function HaveApplications: Boolean;
//发送初始化命令到端口
procedure SendInitCodeToComPort();
//发送复位命令到端口
procedure SendResetCodeToComPort();
//发送命令到端口
procedure SendCmdToComPort(const Cmd: string);
//捕获手机键盘
procedure CaptureKey(const Capture: Boolean);
//在手机上显示提示信息
procedure SendInfoToPhone(const strMessage: string; const iSec: Byte = 0);
//显示主菜单
procedure ShowMainMenu;
//显示程序菜单
procedure ShowApplicationMenu;
//显示Winamp菜单
procedure ShowWinampMenu(const iMenu: Integer);
//显示移动鼠标
procedure ShowMouseMove;
//显示关于本程序
procedure ShowAbout;
//分流处理消息
function MessageX(const objMessage: TPhoneCMD): Word;
//处理按键消息
procedure ProcessKey(const strMessage: string);
//转换键字符到键值
function StrToKey(const strKey: string): TPhoneKey;
//处理程序按键
procedure ProcessAppKey(const pkKey: TPhoneKey; const KeyDown: Boolean);
//处理Winamp按键
procedure ProcessWinampKey(const pkKey: TPhoneKey; const KeyDown: Boolean);
//处理鼠标按键
procedure ProcessMouseKey(const pkKey: TPhoneKey; const KeyDown: Boolean);
//处理菜单消息
procedure ProcessMenu(const strMessage: string);
//处理对话框
procedure ProcessDialog(const strMessage: string);
//搜索Winamp路径
function SearchWinampPath: string;
//初始化系统
procedure InitSystem();
//复位系统
procedure ResetSystem();
//创建全局对象
procedure CreateObjects();
//销毁全局对象
procedure DestroyObjects();
//加载配置
procedure LoadSetting();
//写入配置
procedure WriteSetting();
//加载按键组
procedure LoadKeyGroup;
//写入按键组
procedure WriteKeyGroup;
//加载程序设置
procedure LoadPrograms;
//写入程序设计
procedure WritePrograms;
//加载语言
procedure LoadLanguage();
//翻译字符串
procedure TranslationStrings();
//读取手机状态
procedure ReadPhoneStatus();
//写入手机状态
procedure WritePhoneStatus();
implementation
uses frmMain, sndkey32;
{-------------------------------------------------------------------------------
过程名: MouseEvent
作者: 小冬[kendling]
邮件: kendling@sina.com
主页: http://www.MyvNet.com
日期: 2005.02.25
参数: const iMove: Byte;
0 - 左
1 - 上
2 - 右
3 - 下
4 - 左键
5 - 中键
6 - 右键
const KeyDown: Boolean
返回值: 无
说明: 鼠标事件
-------------------------------------------------------------------------------}
procedure MouseEvent(const iMove: Byte; const KeyDown: Boolean);
begin
iMouse := iMove;
case iMove of
0: //LEFT
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -