zoukankan      html  css  js  c++  java
  • BossKey 转

    最简单的方法: 一、运用COOLTRAYICON之类的控件。 
    二、注册一个热键,然后用热键控制。 

    看一下我写的这个程序,它就可以实现老板键的功能(假定热键是CTRL+ALT+]),按一下这个组合键就隐藏,再按一下就显示出来:

    unit Unit1; 

    interface 

    uses 
     Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
     Dialogs, Menus, CoolTrayIcon; 

    type 
     TForm1 
    = class(TForm) 
       CoolTrayIcon1: TCoolTrayIcon; 
       
    procedure CoolTrayIcon1Click(Sender: TObject); 
       
    procedure FormCreate(Sender: TObject); 
       
    procedure FormDestroy(Sender: TObject); 
     
    private 
       
    { Private declarations } 
       id1: Integer; 
       
    procedure WMHotKey(var Msg : TWMHotKey); message WM_HOTKEY; 
       
    function ByteReserve(Value: Word):Word; 
     
    public 
       
    { Public declarations } 
     
    end

    var 
     Form1: TForm1; 
     hide_windows: boolean; 
    implementation 

    {$R *.dfm} 

    procedure do_something1; 
    begin 
     
    if hide_windows=false then 
     
    begin 
       Form1.CoolTrayIcon1.HideMainForm; 
       Form1.CoolTrayIcon1.IconVisible :
    =False; 
       hide_windows:
    =true; 
     
    end 
     
    else 
     
    begin 
       Form1.CoolTrayIcon1.ShowMainForm; 
       Form1.CoolTrayIcon1.IconVisible :
    =True; 
       hide_windows:
    =false; 
     
    end
    end

    function TForm1.ByteReserve(Value: Word):Word; 
    var 
     buf:Byte; 
     i: Integer; 
    begin 
     Result :
    = 0
     
    for i:=0 to 7 do 
     
    begin 
       buf :
    = Byte((Value shr i) and $01); 
       Result :
    = Result or (buf shl (7-i)); 
     
    end
    end

    procedure free_hotkey1; 
    begin 
     UnRegisterHotKey(form1.handle,form1.id1); 
     globalDeleteAtom(form1.id1); 
    end

    procedure set_hotkey(hotkey_name:pchar;key_name:string;var key_id:integer); 
    var 
     TheKey,Shirt: Word; 
     TheShiftState: TShiftState; 
    begin 
     
    if globalFindAtom(hotkey_name) = 0 then 
     
    begin 
       key_id:
    =globalAddAtom(hotkey_name); 
       ShortCutToKey(texttoshortcut(key_name),TheKey,TheShiftState); 
       Shirt:
    = form1.ByteReserve(Word((texttoshortcut(key_name) and $F000) shr 8)); 
       RegisterHotKey(form1.Handle,key_id,Shirt,Cardinal(Chr(TheKey))); 
     
    end
    end

    procedure Tform1.WMHotKey (var Msg : TWMHotKey); 
    begin 
     
    if msg.HotKey = form1.id1 then do_something1; 
    end


    procedure TForm1.CoolTrayIcon1Click(Sender: TObject); 
    begin 
     Form1.CoolTrayIcon1.ShowMainForm; 
    end

    procedure TForm1.FormCreate(Sender: TObject); 
    var 
     hotkey_
    1_name:string
    begin 
     hide_windows:
    =false; 
     hotkey_
    1_name:='CTRL+ALT+]'
     
    set_hotkey('MyHotkey1',hotkey_1_name,form1.id1); 
    end

    procedure TForm1.FormDestroy(Sender: TObject); 
    begin 
     free_hotkey1; 
    end

    end
  • 相关阅读:
    解决maven托管项目中pom.xml存在坐标标红的问题
    Jquery取form表单中的所有参数
    解决IntelliJ IDEA控制台输出中文乱码问题
    Maven项目打包及jar包与war包的区别
    IDEA创建Maven web项目(项目结构组织、文件编译及运行明细)
    http学习笔记--报文构成
    http报文结构
    mount: unknown filesystem type 'vboxsf'
    使用shell做过时处理以及发送邮件的事例
    fuelphp 日志文件保存路径以及日志文件名变更中遇到的问题总结
  • 原文地址:https://www.cnblogs.com/liye/p/1533711.html
Copyright © 2011-2022 走看看