unit DAstMain; interface uses Define, Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.ExtCtrls, Vcl.Menus, Vcl.Forms, Vcl.Dialogs, Vcl.Controls, FShotcutForder, Vcl.ComCtrls, Vcl.StdCtrls, Tocsg.Trace, ManagerConfig, Vcl.Graphics, DAngle, Vcl.Buttons, ManageWindowPage, CtrlWndActiveHook, KeyMonDLL; type TDlgKoAstMain = class(TForm) mMain: TMainMenu; miFile: TMenuItem; miExit: TMenuItem; rMain: TTrayIcon; popTry: TPopupMenu; miTrayExit: TMenuItem; N1: TMenuItem; miConfig: TMenuItem; tInit: TTimer; N2: TMenuItem; miOpen: TMenuItem; StatusBar1: TStatusBar; S1: TMenuItem; E1: TMenuItem; F1: TMenuItem; pnTop: TPanel; edErrorCode: TEdit; btnErrorCode: TButton; Label1: TLabel; pcMain: TPageControl; toolAddWindow: TBitBtn; popPage: TPopupMenu; miWndPage: TMenuItem; N3: TMenuItem; miWndPageClose: TMenuItem; miView: TMenuItem; miStayOnTop: TMenuItem; N4: TMenuItem; miKeylogView: TMenuItem; tbAlphaBlend: TTrackBar; chAlphaBlend: TCheckBox; N5: TMenuItem; miLockScreen: TMenuItem; H1: TMenuItem; procedure miExitClick(Sender: TObject); procedure tInitTimer(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure miConfigClick(Sender: TObject); procedure miOpenClick(Sender: TObject); procedure btnErrorCodeClick(Sender: TObject); procedure edErrorCodeKeyPress(Sender: TObject; var Key: Char); procedure toolAddWindowMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure toolAddWindowMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure toolAddWindowMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure pcMainMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure popPagePopup(Sender: TObject); procedure miWndPageCloseClick(Sender: TObject); procedure miViewClick(Sender: TObject); procedure miStayOnTopClick(Sender: TObject); procedure miKeylogViewClick(Sender: TObject); procedure chAlphaBlendClick(Sender: TObject); procedure tbAlphaBlendChange(Sender: TObject); procedure miLockScreenClick(Sender: TObject); procedure H1Click(Sender: TObject); private { Private declarations } WndHook_: TCtrlWndActiveHook; Config_: TManagerConfig; Trace_: TTgTrace; KeyMon_: TKeyMonDLL; LastWindowState_: TWindowState; // Clipboard_: TDrawClipboard; bSeeking_: Boolean; hPreTopHWND_: HWND; DlgAngle_: TDlgAngle; sSelfProcName_: String; WndPages_: TManagerWindowPage; dwCurrentProcPid_: DWORD; SysImgList: TImageList; // procedure OnDrawClipboard(Sender: TDrawClipboard); procedure VisibleMainform(bVal: Boolean); procedure SaveFormState; procedure OnClickWndPage(Sender: TObject); procedure OnActiveWindow(Sender: TCtrlWndActiveHook; aWindowEntry: TProcessEntry); procedure OnDeActiveWindow(Sender: TCtrlWndActiveHook; aWindowEntry: TProcessEntry); function IsAbleAddWindow(hWindow: HWND): Boolean; procedure ProcessDetectWindow(hWindow: HWND); public { Public declarations } Constructor Create(aOwner: TComponent); override; Destructor Destroy; override; procedure CreateWindowTab(aWndInfo: TWndInfo); procedure process_WM_HOTKEY(var msg: TMessage); Message WM_HOTKEY; procedure process_WM_SYSCOMMAND(var Msg: TWMSysCommand); Message WM_SYSCOMMAND; procedure process_WM_CATCHKEY_NOTIFY(var msg: TMessage); Message WM_CATCHKEY_NOTIFY; procedure process_WM_WNDHOOK_RELOAD(var msg: TMessage); Message WM_WNDHOOK_RELOAD; procedure process_WM_WNDHOOK_NOTIFY(var msg: TMessage); Message WM_WNDHOOK_NOTIFY; procedure process_WM_MESSAGEHOOK_NOTIFY(var msg: TMessage); Message WM_MESSAGEHOOK_NOTIFY; property KeyMon: TKeyMonDLL read KeyMon_; end; var DlgKoAstMain: TDlgKoAstMain; gMain: TDlgKoAstMain = nil; implementation uses Tocsg.Safe, DCloseQuestion, DConfig, Winapi.ShellAPI, Tocsg.Shell, Tocsg.Registry, Tocsg.Path, Winapi.ActiveX, DShowAudioVolume, Tocsg.WndUtil, Tocsg.Process, FWindowPage, DKeyInput, DLockScreen, DefineKeyMon, Vcl.Clipbrd, Tocsg.Keyboard; {$R *.dfm} const HOKEY_MAINFORM_SHOWHIDE = 1; var _DlgSystemVol: TDlgShowAudioVolume = nil; { TDlgKoAstMain } Constructor TDlgKoAstMain.Create(aOwner: TComponent); procedure InitControls; begin with gCfg do begin LastWindowState_ := wsNormal; AlphaBlend := NormalConfig.AlphaBlend; AlphaBlendValue := NormalConfig.AlphaBlendVal; chAlphaBlend.Checked := AlphaBlend; tbAlphaBlend.Position := AlphaBlendValue; if FormSizeSave then begin // Position := poDesigned; // Å©±â ¼³Á¤ ÇÒ¶© ÀÌ·¸°Ô ÇÒ Çʿ䰡 ¾ø´Ù 15_0506 23:51:39 sunk Width := FormWidth; Height := FormHeight; end; if FormPosSave then begin Position := poDesigned; Top := FormTop; Left := FormLeft; end; if gCfg.FormInitHide then WindowState := wsMinimized; if StartupExecute and not ExistsRunAppByHLM(FAMILY_NAME) then AddRunAppByHLM(FAMILY_NAME, Format('"%s%s" /exename %s', [GetRunExePathDir, APP_STARTUP, APP_EXECUTE])); end; end; procedure LoadKeyHookDLL; begin KeyMon_ := TKeyMonDLL.Create(Handle, MAP_FILENAME_KM, GetRunExePathDir + DLL_KEYMON); if KeyMon_.LastError <> ERROR_SUCCESS then begin MessageBox(Handle, PChar(Format('DLL ·Îµå ¿À·ùÀÔ´Ï´Ù. Error = %d', [KeyMon_.LastError])), APP_NAME, MB_ICONSTOP or MB_OK); end; end; begin Inherited Create(aOwner); ASSERT(gMain = nil); gMain := Self; // if (@IsProcessDPIAware <> nil) and not IsProcessDPIAware and (@SetProcessDPIAware <> nil) then // SetProcessDPIAware; SysImgList := TImageList.Create(Self); SysImgList.ShareImages := true; SysImgList.Handle := GetShellImageHandle; pcMain.Images := SysImgList; dwCurrentProcPid_ := GetCurrentProcessId; sSelfProcName_ := UpperCase(ExtractFileName(Application.ExeName)); bSeeking_ := false; hPreTopHWND_ := 0; DlgAngle_ := TDlgAngle.Create(Self); Config_ := TManagerConfig.Create; Config_.LoadConfig; Trace_ := TTgTrace.Create(Config_.LogPath, ExtractFileName(GetRunExePath) + '.log', true); Caption := Format('%s %s', [APP_NAME, APP_VER]); Trace_.T('[SunkAssister] Begin - %s', [Caption]); // ÁÖÀÇ : RegisterHotKey, LoadKeyHookDLL ÈÄ¿¡ InitControls ÀÌ°É È£ÃâÇϸé ÀÌ»óÇÏ°Ô ¸ÞÀÎ À©µµ¿ì ÇÚµéÀÌ ¹Ù²î¾î¼­ // WM_CATCHKEY_NOTIFY ¸Þ½ÃÁö¸¦ ¹ÞÀ» ¼ö¾ø´Ù. 2014-01-06 sunk InitControls; // ±âº» ´ÜÃàŰ = WinKey + ` (Űº¸µå À§ ¼ýÀÚÀÚÆÇ ¸Ç ¿ÞÂÊ¿¡ ÀÖ´Â) if not RegisterHotKey(Handle, HOKEY_MAINFORM_SHOWHIDE, MOD_WIN, $C0) then ShowMessage('ÇÁ·Î±×·¥ ¸ÞÀÎ۸¦ µî·Ï Çϴµ¥ ½ÇÆÐÇÏ¿´½À´Ï´Ù..'); {$IFDEF DEBUG} if DebugHook = 0 then {$ENDIF} LoadKeyHookDLL; _DlgSystemVol := TDlgShowAudioVolume.Create(Self); _DlgSystemVol.Caption := '½Ã½ºÅÛ º¼·ý'; WndHook_ := TCtrlWndActiveHook.Create(Handle, false, false); WndHook_.OnActive := OnActiveWindow; WndHook_.OnDeActive := OnDeActiveWindow; WndPages_ := TManagerWindowPage.Create; // DragAcceptFiles(FrmShotcutForder.Handle, true); // Clipboard_ := TDrawClipboard.Create; // Clipboard_.OnDrawClipboard := OnDrawClipboard; //DragAcceptFiles(Handle, true); //ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD); //ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD); //ChangeWindowMessageFilter($0049{WM_COPYGLOBALDATA}, MSGFLT_ADD); tInit.Enabled := true; end; Destructor TDlgKoAstMain.Destroy; begin FreeAndNil(WndHook_); FreeAndNil(WndPages_); // FreeAndNil(Clipboard_); // DragAcceptFiles(FrmShotcutForder.Handle, false); FreeAndNil(_DlgSystemVol); if Assigned(KeyMon_) then FreeAndNil(KeyMon_); Trace_.T('[SunkAssister] - End'); FreeAndNil(Trace_); FreeAndNil(Config_); FreeAndNil(DlgAngle_); gMain := nil; Inherited; end; procedure TDlgKoAstMain.CreateWindowTab(aWndInfo: TWndInfo); var WindowTab: TWndTabSheet; begin WindowTab := TWndTabSheet.Create(pcMain, aWndInfo); WindowTab.PageControl := WindowTab.Owner as TPageControl; WindowTab.PageControl.ActivePage := WindowTab; WindowTab.Caption := ExtractFileName(aWndInfo.ProcPath); //GetWindowCaption(aWndInfo.WndHandle); WindowTab.ImageIndex := GetShellImageIndex_path(aWndInfo.ProcPath); // case aTaskInfo.TaskKind of // tkDiskAnal : WindowTab.ImageIndex := 0; // tkPCInspector : WindowTab.ImageIndex := 1; // tkCollectData : WindowTab.ImageIndex := 2; // end; end; procedure TDlgKoAstMain.toolAddWindowMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin bSeeking_ := true; SetCapture(toolAddWindow.Handle); end; procedure TDlgKoAstMain.toolAddWindowMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var pt: TPoint; hTemp, hTopHWND: HWND; WndRect: TRect; sClassName, sProcName: String; begin if bSeeking_ then begin pt.X := X; pt.Y := Y; pt := ClientToScreen(pt); // OutputDebugString(PChar(Format('X=%d, Y=%d', [pt.X, pt.Y]))); hTopHWND := GetTopParentHWND(WindowFromPoint(pt)); if hTopHWND = 0 then begin hPreTopHWND_ := 0; exit; end; if (hTopHWND <> Handle) and (hTopHWND <> 0) and (hPreTopHWND_ <> hTopHWND) then begin hPreTopHWND_ := 0; DlgAngle_.Hide; if not IsAbleAddWindow(hTopHWND) then exit; hPreTopHWND_ := hTopHWND; GetWindowRect(hPreTopHWND_, WndRect); DlgAngle_.ShowAngle(WndRect); OutputDebugString(PChar(GetWindowCaption(hTopHWND))); end; end; end; procedure TDlgKoAstMain.toolAddWindowMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin DlgAngle_.Hide; ReleaseCapture; bSeeking_ := false; try if (hPreTopHWND_ <> 0) and (hPreTopHWND_ <> Handle) then begin ProcessDetectWindow(hPreTopHWND_); end; finally hPreTopHWND_ := 0; end; end; procedure TDlgKoAstMain.btnErrorCodeClick(Sender: TObject); var nCode: Integer; begin nCode := StrToIntDef(edErrorCode.Text, -1); if nCode <> -1 then ShowMessage(SysErrorMessage(nCode)); end; procedure TDlgKoAstMain.chAlphaBlendClick(Sender: TObject); begin AlphaBlend := chAlphaBlend.Checked; tbAlphaBlend.Enabled := AlphaBlend; gCfg.NormalConfig.AlphaBlend := AlphaBlend; gCfg.SaveConfig; end; procedure TDlgKoAstMain.edErrorCodeKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin Key := #0; btnErrorCode.Click; end; end; procedure TDlgKoAstMain.FormClose(Sender: TObject; var Action: TCloseAction); begin SaveFormState; end; procedure TDlgKoAstMain.H1Click(Sender: TObject); begin VisibleMainform(false); end; procedure TDlgKoAstMain.OnActiveWindow(Sender: TCtrlWndActiveHook; aWindowEntry: TProcessEntry); var WndTab: TWndTabSheet; OldFormStyle: TFormStyle; begin // Æ÷ÇÔµÈ ¿ÜºÎ À©µµ¿ì°¡ Ŭ¸¯µÇ·Ï ¸ÞÀÎ À©µµ¿ì°¡ »óÀ§·Î ¶ßµµ·Ï º¸¿Ï 14_0409 00:05:15 sunk // WndTab := WndPages_.WndTabSheet[aWindowEntry.PID]; // if Assigned(WndTab) then // begin // OldFormStyle := FormStyle; // FormStyle := fsStayOnTop; // FormStyle := OldFormStyle; // end; end; procedure TDlgKoAstMain.OnDeActiveWindow(Sender: TCtrlWndActiveHook; aWindowEntry: TProcessEntry); begin end; function TDlgKoAstMain.IsAbleAddWindow(hWindow: HWND): Boolean; var sProcName, sClassName: String; hTemp: HWND; begin Result := false; sProcName := UpperCase(GetProcessNameByPid(GetProcessPIDFromWndHandle(hWindow))); if (WndPages_.GetWndPage(hWindow) <> nil) or (sProcName = sSelfProcName_) then exit; if sProcName = 'EXPLORER.EXE' then begin sClassName := UpperCase(GetWndClassName(hWindow)); if sClassName <> 'CABINETWCLASS' then exit; hTemp := FindWindowEx(0, 0, 'Progman', 'Program Manager'); if hTemp = 0 then exit; // if GetProcessPIDFromWndHandle(hTemp) = GetProcessPIDFromWndHandle(hWindow) then // exit; end; Result := true; end; procedure TDlgKoAstMain.ProcessDetectWindow(hWindow: HWND); var sTitle, sProcName: String; dwPid: DWORD; WndInfo: TWndInfo; begin sTitle := GetWindowCaption(hWindow); dwPid := GetProcessPIDFromWndHandle(hWindow); sProcName := GetProcessNameByPid(dwPid); if MessageBox(Handle, PChar(Format('"%s" (%s) À©µµ¿ì°¡ °¨Áö µÇ¾ú½À´Ï´Ù.', [sTitle, sProcName])+#13+#10+ 'ÆäÀÌÁö·Î Æ÷ÇÔ ÇϽðڽÀ´Ï±î?'), PChar(Caption), MB_ICONINFORMATION or MB_YESNO) = IDNO then exit; // if WndPages_.WndTabSheet[dwPid] <> nil then // begin // MessageBox(Handle, 'ÀÌ¹Ì µî·ÏµÇ¾î ÀÖ´Â ÇÁ·Î¼¼½º ÀÔ´Ï´Ù.', PChar(Caption), MB_ICONWARNING or MB_OK); // exit; // end; ZeroMemory(@WndInfo, SizeOf(WndInfo)); WndInfo.ProcInfo := TTgProcessInfo.Create(dwPid); ASSERT((WndInfo.ProcInfo.ModulePath <> '') and (WndInfo.ProcInfo.ModuleName <> '')); WndInfo.WndKind := wkNormal; WndInfo.ProcPath := WndInfo.ProcInfo.ModulePath; WndInfo.ProcID := dwPid; WndInfo.WndHandle := hWindow; WndInfo.WndFrameClass := TFrmWindowPage; CreateWindowTab(WndInfo); gWndPage.AddWndPage(WndInfo); end; //procedure TDlgKoAstMain.OnDrawClipboard(Sender: TDrawClipboard); //var // i: Integer; //begin ////CF_TEXT // Trace_.T('OnDrawClipboard() - FormatCount : %d', [Sender.FormatCount]); // for i := 0 to Sender.FormatCount - 1 do // Trace_.T('OnDrawClipboard() - Format(%d) : %d', [i, Sender.Formats[i]]); //end; procedure TDlgKoAstMain.VisibleMainform(bVal: Boolean); var OldFormStyle: TFormStyle; begin if bVal then begin WindowState := LastWindowState_; Show; OldFormStyle := FormStyle; FormStyle := fsStayOnTop; FormStyle := OldFormStyle; SetForegroundWindow(Handle); end else begin LastWindowState_ := WindowState; WindowState := wsMinimized; Hide; end; end; procedure TDlgKoAstMain.SaveFormState; begin if gCfg.FormSizeSave then begin gCfg.FormWidth := Width; gCfg.FormHeight := Height; end; if gCfg.FormPosSave then begin gCfg.FormLeft := Left; gCfg.FormTop := Top; end; if gCfg.FormSizeSave or gCfg.FormPosSave or gCfg.NormalConfig.AlphaBlend then gCfg.SaveConfig; end; procedure TDlgKoAstMain.tbAlphaBlendChange(Sender: TObject); begin AlphaBlendValue := tbAlphaBlend.Position; gCfg.NormalConfig.AlphaBlendVal := AlphaBlendValue; end; procedure TDlgKoAstMain.tInitTimer(Sender: TObject); var enum: TWndInfoEnumerator; sProcess: String; begin tInit.Enabled := false; if WindowState = wsMinimized then Hide; sProcess := ''; Guard(enum, gWndPage.GetWndInfoEnumerator); while enum.MoveNext do sProcess := sProcess + ExtractFileName(enum.Current.ProcPath) + #13#10; if sProcess <> '' then if MessageBox(Handle, PChar(Format('ºñÁ¤»óÀûÀ¸·Î Á¾·á µÇ¾î¼­ ½ÇÇàÁßÀÎ ÇÁ·Î¼¼½º°¡ ÀÖ½À´Ï´Ù.'+ #13+#10+#13+#10+'%s'+#13+#10+ '¸ðµÎ °­Á¦ Á¾·áÇϽðڽÀ´Ï±î?', [sProcess])), PChar(Caption), MB_ICONQUESTION or MB_YESNO) = IDYES then begin Guard(enum, gWndPage.GetWndInfoEnumerator); while enum.MoveNext do TerminateProcessByPid(enum.Current.ProcID); end; WndPages_.ClearPages; end; procedure TDlgKoAstMain.miConfigClick(Sender: TObject); var dlg: TDlgConfig; begin // SwitchNormalFormstyle(Self); Guard(dlg, TDlgConfig.Create(self)); dlg.ShowModal; end; procedure TDlgKoAstMain.miExitClick(Sender: TObject); begin if MessageBox(Handle, 'ÇÁ·Î±×·¥À» Á¾·áÇϽðڽÀ´Ï±î?', PChar(Caption), MB_ICONQUESTION or MB_YESNO) = IDNO then exit; Close; end; procedure TDlgKoAstMain.miKeylogViewClick(Sender: TObject); begin if gKeyInput = nil then TDlgKeyInput.Create(Self).Show else gKeyInput.Close; end; procedure TDlgKoAstMain.miLockScreenClick(Sender: TObject); begin TDlgLockScreen.Create(Self).DoLockScreen; end; procedure TDlgKoAstMain.miOpenClick(Sender: TObject); begin VisibleMainform(true); end; procedure TDlgKoAstMain.miStayOnTopClick(Sender: TObject); begin if FormStyle = fsStayOnTop then FormStyle := fsNormal else FormStyle := fsStayOnTop; end; procedure TDlgKoAstMain.miViewClick(Sender: TObject); begin miStayOnTop.Checked := FormStyle = fsStayOnTop; miKeylogView.Checked := gKeyInput <> nil; end; procedure TDlgKoAstMain.miWndPageCloseClick(Sender: TObject); var WndTab: TWndTabSheet; begin if pcMain.PageCount > 0 then begin if MessageBox(Handle, 'ÇöÀç ¼±ÅÃÇÑ À©µµ¿ì ÆäÀÌÁö¸¦ ´ÝÀ¸½Ã°Ú½À´Ï±î?', PChar(miWndPageClose.Caption), MB_ICONQUESTION or MB_YESNO) = IDNO then exit; WndTab := TWndTabSheet(pcMain.ActivePage); if IsWindow(WndTab.WndInfo.WndHandle) and // (GetProcessPathFromPID(WndInfo_.ProcID) <> '') and (MessageBox(Handle, 'ÆäÀÌÁöÀÇ À©µµ¿ìµµ ÇÔ²² Á¾·áÇϽðڽÀ´Ï±î?', APP_NAME, MB_ICONQUESTION or MB_YESNO) = IDYES) then begin PostMessage(WndTab.WndInfo.WndHandle, WM_CLOSE, 0, 0); // WndInfo_.ProcID := 0; end; WndTab.Free; end; end; procedure TDlgKoAstMain.process_WM_HOTKEY(var msg: TMessage); begin case msg.WParam of HOKEY_MAINFORM_SHOWHIDE : VisibleMainform(not Visible); end; end; procedure TDlgKoAstMain.process_WM_SYSCOMMAND(var Msg: TWMSysCommand); var dlg: TDlgCloseQuestion; begin if Msg.CmdType = SC_CLOSE then begin SaveFormState; case gCfg.CloseBtnEvent of cbeHide : VisibleMainform(false); cbeExit : miExit.Click; cbeQuestion : begin // SwitchNormalFormstyle(Self); Guard(dlg, TDlgCloseQuestion.Create(self)); case dlg.ShowModal of mrOk : VisibleMainform(false); mrClose : Close;//miExit.Click; end; end; end; exit; end; Inherited; end; procedure TDlgKoAstMain.pcMainMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Button = mbRight then begin mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); end; end; procedure TDlgKoAstMain.OnClickWndPage(Sender: TObject); var MenuItem: TMenuItem; begin if Sender is TMenuItem then begin MenuItem := TMenuItem(Sender); pcMain.ActivePageIndex := MenuItem.Tag; end; end; procedure TDlgKoAstMain.popPagePopup(Sender: TObject); var i: Integer; MenuItem: TMenuItem; WndTab: TWndTabSheet; begin miWndPage.Clear; if pcMain.PageCount > 0 then for i := 0 to pcMain.PageCount - 1 do begin WndTab := TWndTabSheet(pcMain.Pages[i]); MenuItem := TMenuItem.Create(popPage); MenuItem.Caption := ExtractFileName(WndTab.WndInfo.ProcPath); MenuItem.OnClick := OnClickWndPage; MenuItem.Tag := i; miWndPage.Add(MenuItem); if WndTab.TabIndex = pcMain.ActivePageIndex then MenuItem.Checked := true; end; end; procedure TDlgKoAstMain.process_WM_CATCHKEY_NOTIFY(var msg: TMessage); var ShiftState: TShiftState; sKey: String; hWindow: HWND; begin ShiftState := KeyDataToShiftState(0); if GetKeyState(VK_LMENU) < 0 then Include(ShiftState, ssAlt); if (ssShift in ShiftState) and (ssCtrl in ShiftState) and (ssAlt in ShiftState) then begin case msg.WParam of 38 : // À§ È­»ìÇ¥ ¡è begin // SetUpSystemAudioVolume; // _DlgSystemVol.SetVolume(GetSystemAudioVolume); end; 40 : // ¾Æ·¡ È­»ìÇ¥ ¡é begin // SetDownSystemAudioVolume; // _DlgSystemVol.SetVolume(GetSystemAudioVolume); end; 45 : // Àμ­Æ®(Insert) begin hWindow := GetForegroundWindow; if IsAbleAddWindow(hWindow) then begin VisibleMainform(true); ProcessDetectWindow(hWindow); end; end; 88 : // x // 90 : // z, ¿¡¹ö³ëÆ® ½Å¹öÀü¿¡¼­ x°¡ ¼±ÅÃÇÑ ÅØ½ºÆ® ¾Ïȣȭ ´ÜÃßŰ·Î ÁöÁ¤µÇ¼­ º¯°æ begin var CB: TClipboard; Guard(CB, TClipboard.Create); CB.AsText := FormatDateTime('yyyy-mm-dd', Now) + ' : [BSOne] '; // Sleep(500); // PressKeys('v', true); // Ŭ¸³º¸µå ³Ö°í ·çÇÁ Çϳª ³Ñ¾î°¡¾ß ÀνÄÇϳªº¸´Ù end; 90 : // z begin var CB: TClipboard; Guard(CB, TClipboard.Create); var sText: String := CB.AsText; if (sText.Length < 2) or (sText[2] <> ':') then exit; var sHead: String := Format('/mnt/%s/', [LowerCase(sText[1])]); sText := StringReplace(sText, Format('%s:\', [sText[1]]), sHead, [rfReplaceAll]); sText := '"' + StringReplace(sText, '\', '/', [rfReplaceAll]) + '"'; CB.AsText := sText; end; end; end; // else // if (ssShift in ShiftState) and // (ssCtrl in ShiftState) then // begin // case msg.WParam of // // end; // end; // msg.LParam ÀÇ PID´Â DLL ·Îµå ÇѳðÀÇ PID ÀÌ´Ù.. 14_0423 23:52:13 sunk if gKeyInput <> nil then gKeyInput.ProcessKeyInput(msg.WParam, ShiftState); end; procedure TDlgKoAstMain.process_WM_WNDHOOK_RELOAD(var msg: TMessage); function CheckUnHook(dwPID: DWORD): Boolean; var dwTick: DWORD; sOld, sCur: String; begin // TTgTrace.t('TDlgKoAstMain >> process_WM_WNDHOOK_RELOAD >> CheckUnHook()'); Result := true; dwTick := GetTickCount; while (GetTickCount - dwTick) < 1000 do begin sOld := GetProcessNameByPid(dwPID); Sleep(100); sCur := GetProcessNameByPid(dwPID); if (sCur = '') or (sCur <> sOld) then begin Result := false; exit; end; Application.ProcessMessages; end; end; begin if Assigned(WndHook_) then begin // TTgTrace.t('TDlgKoAstMain >> process_WM_WNDHOOK_RELOAD >> PID = %d', [msg.WParam]); if CheckUnHook(msg.WParam) then begin TTgTrace.t('TDlgKoAstMain >> process_WM_WNDHOOK_RELOAD >> CheckUnHook() >> UnHook!!!, pid=%d', [msg.WParam]); WndHook_.LoadHookDll; end; end; end; procedure TDlgKoAstMain.process_WM_WNDHOOK_NOTIFY(var msg: TMessage); var WndLogEntry: TWindowLogEntry; ProcEntry: TProcessEntry; WndTab: TWndTabSheet; begin if msg.WParamLo = WND_STATE_DETACH_HOOK then begin // ÀÌ °æ¿ì´Â UIÀû¿ë ¶§¹®¿¡ Ư¼ö »óȲÀÌ´Ù. ProcEntry := WndHook_[msg.WParamHi]; if Assigned(ProcEntry) then begin WndLogEntry := ProcEntry.AddWindowLog(msg.LParam, wlDetach); // if WndLogEntry.dtLog <> 0 then // AddWndLog(WndLogEntry); TTgTrace.T('(%s:%d) ÇÁ·Î¼¼½º Á¾·á (Begin = %s, End = %s)', [ProcEntry.ModuleName, ProcEntry.PID, DateTimeToStr({ProcEntry.CreateDateTime}0), DateTimeToStr(now)]); WndPages_.DeleteWndTabSheetFromPid(ProcEntry.PID); end; ProcEntry := WndHook_.DeleteWindowEntry(msg.WParamHi); // if Assigned(ProcEntry) then // AddWndEntry(ProcEntry, true); end else begin WndLogEntry := WndHook_.ProcessHookNotify(msg); if WndLogEntry.dtLog <> 0 then begin // AddWndLog(WndLogEntry); case msg.WParamLo of WND_STATE_ACTIVATE : TTgTrace.T('(%s:%d) Ȱ¼ºÈ­ - %s', [WndLogEntry.OwnerWindow.ModuleName, WndLogEntry.OwnerWindow.PID, WndLogEntry.sTitle]); WND_STATE_WINDOW_MIN : TTgTrace.T('(%s:%d) ÃÖ¼ÒÈ­ - %s', [WndLogEntry.OwnerWindow.ModuleName, WndLogEntry.OwnerWindow.PID, WndLogEntry.sTitle]); WND_STATE_WINDOW_MAX : TTgTrace.T('(%s:%d) ÃÖ´ëÈ­ - %s', [WndLogEntry.OwnerWindow.ModuleName, WndLogEntry.OwnerWindow.PID, WndLogEntry.sTitle]); WND_STATE_WINDOW_MOVESIZE : TTgTrace.T('(%s:%d) À̵¿ / Å©±âÁ¶Àý - %s', [WndLogEntry.OwnerWindow.ModuleName, WndLogEntry.OwnerWindow.PID, WndLogEntry.sTitle]); WND_STATE_REDRAW_TITLE : TTgTrace.T('(%s:%d) ĸ¼Çº¯°æ - %s', [WndLogEntry.OwnerWindow.ModuleName, WndLogEntry.OwnerWindow.PID, WndLogEntry.sTitle]); WND_STATE_CREATE_MAIN : TTgTrace.T('(%s:%d) ¸ÞÀÎÆû »ý¼º - %s', [WndLogEntry.OwnerWindow.ModuleName, WndLogEntry.OwnerWindow.PID, WndLogEntry.sTitle]); WND_STATE_DESTROY_MAIN : TTgTrace.T('(%s:%d) ¸ÞÀÎÆû Á¾·á - %s', [WndLogEntry.OwnerWindow.ModuleName, WndLogEntry.OwnerWindow.PID, WndLogEntry.sTitle]); WND_STATE_WINDOW_NORMAL : TTgTrace.T('(%s:%d) ÃÖ¼Ò / ÃÖ´ëÈ­ º¹±Í - %s', [WndLogEntry.OwnerWindow.ModuleName, WndLogEntry.OwnerWindow.PID, WndLogEntry.sTitle]); WND_STATE_ACTIVATE2 : TTgTrace.T('(%s:%d) Ȱ¼ºÈ­2 - %s', [WndLogEntry.OwnerWindow.ModuleName, WndLogEntry.OwnerWindow.PID, WndLogEntry.sTitle]); end; end else if msg.WParamLo = WND_STATE_ATTACH_HOOK then begin // AddWndEntry(WndHook_[msg.WParamHi]); end; end; end; procedure TDlgKoAstMain.process_WM_MESSAGEHOOK_NOTIFY(var msg: TMessage); var WndTabSheet: TWndTabSheet; begin case msg.WParam of MSG_WM_DESTROY : WndPages_.DeleteWndTabSheetFromHWND(msg.LParam); MSG_WM_SETTEXT : begin WndTabSheet := WndPages_.GetWndTabSheet(msg.LParam); if WndTabSheet <> nil then begin WndTabSheet.Caption := GetWindowCaption(msg.LParam); end; end; end; end; end.