Example #1
0
        public bool IsBlackTarget(IntPtr hwnd)
        {
            var title = ThreadWindowHandles.GetWindowText(hwnd);

            if (title == string.Empty)
            {
                return(true);
            }
            return(HasTarget(IgnoreTargetList, hwnd));
        }
Example #2
0
        public bool MatchRule(IntPtr hwnd)
        {
            var title     = ThreadWindowHandles.GetWindowText(hwnd);
            var className = ThreadWindowHandles.GetClassText(hwnd);

            if (WindowName.Contains(title))
            {
                return(true);
            }
            return(false);
        }
Example #3
0
 private static Client CreateClient( IntPtr hwnd )
 {
     var title = ThreadWindowHandles.GetWindowText( hwnd );
     if ( title == string.Empty )
     {
         title = ThreadWindowHandles.GetClassText( hwnd );
     }
     Client client = Types.createClient(
         hwnd , ThreadWindowHandles.GetParent( hwnd ) ,
         ( int )User32Methods.GetWindowThreadProcessId( hwnd , IntPtr.Zero ) ,
          WindowStyle( hwnd ) , title );
     return client;
 }
Example #4
0
        private void OtherWindow( System.Windows.Forms.Message m , WM param , Client client )
        {
            //Trace.WriteLine( client?.Title + " " + param );
            switch ( param )
            {
                case WM.HSHELL_WINDOWCREATED:
                    TileMode tileMode = IsManageable( m.LParam );
                    if ( tileMode == TileMode.Tile )
                    {
                        var newClient = Manage( m.LParam , tileMode );
                        // とりあえず子ウィンドウはスルー
                        WindowManager.Tile( );
                    }
                    Trace.WriteLine( "created :" + ThreadWindowHandles.GetWindowText( m.LParam ) );

                    break;
                case WM.HSHELL_WINDOWDESTROYED:
                    if ( client != null )
                    {

                        Trace.WriteLine( "destroyed : " + ThreadWindowHandles.GetWindowText( m.LParam ) );
                        // タグ移動で隠された時にも来るので、その場合無視
                        if ( !client.Ignore )
                        {

                            Unmanage( client );
                            WindowManager.Tile( );
                        }
                        else
                        {
                            client.Ignore = false;
                        }
                    }
                    break;
                case WM.HSHELL_WINDOWACTIVATED:
                case WM.HSHELL_RUDEAPPACTIVATED:
                    if ( client != null )
                    {
                        WindowManager.ActiveClient = client;
                        Trace.WriteLine( "active : " + ThreadWindowHandles.GetWindowText( m.LParam ) );
                    }
                    break;

                default:
                    break;
            }

        }
Example #5
0
        private static bool HasTarget(List <string> list, IntPtr hwnd)
        {
            var title     = ThreadWindowHandles.GetWindowText(hwnd);
            var classText = ThreadWindowHandles.GetClassText(hwnd);

            foreach (var item in list)
            {
                bool titleCont = title.Contains(item);
                bool classCont = classText.Contains(item);
                if (titleCont || classCont)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #6
0
        // タイル化対象
        public bool IsTilingTarget(IntPtr hwnd)
        {
            var title     = ThreadWindowHandles.GetWindowText(hwnd);
            var classText = ThreadWindowHandles.GetClassText(hwnd);

            // 一部分で
            foreach (var item in NoTilingList)
            {
                bool titleCont = title.Contains(item);
                bool classCont = classText.Contains(item);
                if (titleCont || classCont)
                {
                    return(false);
                }
            }
            return(true);
        }
Example #7
0
        private void QuitWindowManager( )
        {
            List<string> TitleAndClass = new List<string>();
            foreach ( var screen in WindowManager.ScreenList )
            {
                foreach ( var tagMan in screen.TagList )
                {
                    foreach ( var client in tagMan.ClientList )
                    {

                        var hwnd = client.Hwnd;
                        var title = ThreadWindowHandles.GetWindowText( hwnd );
                        var klass = ThreadWindowHandles.GetClassText( hwnd );
                        TitleAndClass.Add( "title : " + title + " class : " + klass );
                    }
                    //tagMan.DumpIcon( );
                }
            }
            System.IO.File.WriteAllLines( "dumpedTitleAndClass.txt" , TitleAndClass.ToArray( ) );
            CleanUp( );
            Close( );
        }
Example #8
0
        TileMode IsManageable( IntPtr hwnd )
        {
            if ( ContainClient( hwnd ) )
            {
                return TileMode.NoHandle;
            }
            if ( hwnd == Handle )
            {
                return TileMode.NoHandle;
            }
            String windowText = ThreadWindowHandles.GetWindowText( hwnd );
            String classText = ThreadWindowHandles.GetClassText( hwnd );
            bool isFloatListName = false;
            if ( !_TileSetting.IsTilingTarget( hwnd ) )
            {
                isFloatListName = true;
            }
            if ( _TileSetting.IsBlackTarget( hwnd ) )
            {
                return TileMode.NoHandle;
            }
            Trace.WriteLine( windowText + " : className = " + classText );
#if RECOVER
            if ( 
                windowText.Contains( "Chrome" ) ||
                windowText.Contains( "Avast Secure" ) ||
                windowText.Contains( "Visual" ) ||
                windowText.Contains( "VIM" ) ||
                classText.Contains( "CabinetWClass" ) ||
                windowText.Contains("pmx") ||
                windowText.Contains("Blender")
                )
            {
                DWM.setVisibility( hwnd , true );
                return TileMode.Tile;
            }
#endif
            if ( User32Methods.GetWindowPlacement( hwnd , out WindowPlacement windowPlacement ) )
            {
                if ( ( windowPlacement.ShowCmd & ShowWindowCommands.SW_HIDE ) != 0 )
                {
                    return TileMode.NoHandle;
                }
            }

            var parent = ThreadWindowHandles.GetParent( hwnd );
            var owner = User32Helpers.GetWindow( hwnd , GetWindowFlag.GW_OWNER );
            WindowStyles style = WindowStyle( hwnd );
            //tosafeがほしいけど別ライブラリ内
            var exStyle = ( WindowExStyles )( User32Helpers.GetWindowLongPtr( hwnd , WindowLongFlags.GWL_EXSTYLE ).ToInt32( ) );
            bool isParentOK = parent != IntPtr.Zero && IsManageable( parent ) == TileMode.Tile;
            bool isTool = ( exStyle & WindowExStyles.WS_EX_TOOLWINDOW ) != 0;
            bool isApp = ( exStyle & WindowExStyles.WS_EX_APPWINDOW ) != 0;
            if ( isParentOK && !ContainClient( parent ) )
            {
                // なんか見えないウィンドウをmanageするので
                //Manage( hwnd );
            }

            if ( ( style & WindowStyles.WS_DISABLED ) != 0 )
            {
                return TileMode.NoHandle;
            }
            // WS_POPUPWINDOW も含んでいる
            if ( ( style & WindowStyles.WS_POPUP ) != 0 )
            {
                return TileMode.NoHandle;
            }
            bool hasParent = parent != IntPtr.Zero;
            var winIsVisibleAndNoParent = !hasParent && User32Methods.IsWindowVisible( hwnd );
            if ( winIsVisibleAndNoParent || isParentOK )
            {
                if ( ( !isTool && !hasParent ) || ( isTool && isParentOK ) || ( isApp && hasParent ) )
                {
                    if ( windowText != null )
                    {

                        Trace.Write( windowText );
                        Trace.WriteLine( " isTool : " + isTool + " isApp : " + isApp + " style : " + style );
                    }
                    if ( isFloatListName )
                    {
                        return TileMode.Float;
                    }
                    return TileMode.Tile;
                }
            }
            return TileMode.NoHandle;
        }