Example #1
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 #2
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 #3
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 #4
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 #5
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 #6
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;
        }