Jump to content

Winsetstate problem


kantaki
 Share

Recommended Posts

Hello,

i have a big problem with winsetstate, it doesnt work safe with some programs.

if i use my program =>

$WinList = WinList("[CLASS:#32770]")

it permantly closes all windows and my screen begins to flicker.

if i use it with

$WinList = WinList("[CLASS:Notepad]")

everything is fine.

do you have an idea how i can make the winsetstate safer ?

or do you have an alternative that might work for me ?

#include <WinAPI.au3>
    Global $WinList, $WinGetPos, $hLast, $Pos1, $Pos2, $Pos3, $Pos4, $Pos5
    Global $Struct = DllStructCreate($tagPoint)
    
    
    
    
    Func Refresh()
            $WinList = WinList("[CLASS:#32770]")
            
    EndFunc
    
    Func StartUp()
            Refresh()
                   For $i = 1 To $WinList[0][0]
                    WinSetState($WinList[$i][0],"",@SW_MINIMIZE)
                    Next
                
                
                

                  
EndFunc
                    
    
while 1
    sleep(2000)
StartUp()
WEnd
Link to comment
Share on other sites

  • Moderators

kantaki,

When I run WinList("[CLASS:#32770]") on my machine all I get are the available (but hidden) dialogs from the apps I have in the system tray - why on earth would I want to minimize them every 2 secs? :)

What exactly are you trying to do? If you explain we might be able to help, but at the moment there is little clue in that code. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

kantaki,

When I run WinList("[CLASS:#32770]") on my machine all I get are the available (but hidden) dialogs from the apps I have in the system tray - why on earth would I want to minimize them every 2 secs? :)

What exactly are you trying to do? If you explain we might be able to help, but at the moment there is little clue in that code. ;)

M23

hey thank you for the fast answer.

its a window arranger. i have a main window and 10 subwindows. i want to filter the windows based on a visible button class. i implelemted this in csharp with autoitX.

if the button is visible => maximize the window if not minimize them.

i got it all ready but i still have big problems with the minimize function, because it permanently minimizes all applications on my computer.

autoit window info tells me that the main class is

#32770

and the button class

AfxWnd90u22

if i only run the WinList("[CLASS:#32770]") the output of my $WinList[0][0] is 0. ( without any open applications )

but the main application has a lot of different windows (like sliders etc) with the same name as the mainclass but with a instance number

for example the main class is #32770

but some buttons have a basic control info => #327702 ( 2 is the instance )

maybe thats causing problems ?

-----------------------------------

i dont know if this helps but i could post my csharp code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoItX3Lib;
using System.Collections;
using System.Runtime.InteropServices;

namespace pokerautoit
{

    class WindowControl
    {
        
        AutoItX3 au3 = new AutoItX3();
        public List<string> windowPos = new List<string>();
        public dynamic[,] winlist;
        
        public WindowControl()
        {
           winlist = au3.WinList("[CLASS:#32770]");
            
           windowPos.Add("");
           windowPos.Add("");
           windowPos.Add("");
           windowPos.Add("");
           windowPos.Add("");
           windowPos.Add("");
          
        }
        public Boolean isMinimized(string title)
        {
            if ((this.au3.WinGetPosX(title, "")) == -32000)
            {
                return true;
            }
            return false;
        }

        public Boolean isButtonVisible(string title)
        {
            dynamic button = au3.ControlCommand(title, "", "AfxWnd90u21", "IsVisible", "");
            if (button == "1")
            {
                return true;
            }
            return false;
        }

        public void winMove(string title,int i)
        {
            if (this.isButtonVisible(this.winlist[0, i]) == true)
            {

                if (this.isMinimized(title) == true)
                {
                    this.winMax(title);
                    
                }

                if (windowPos[0]=="" && 1 <= this.sizeOfButton() && !(windowPos.Contains(title)))
                {
                    au3.WinMove(title, "", 0, 0, 640, 463);
                    windowPos[0] = title;
                    
                }
                else if (windowPos[1] == "" && 2 <= this.sizeOfButton() && !(windowPos.Contains(title)))
                {
                    au3.WinMove(title, "", 640, 0, 640, 463);
                    windowPos[1] = title;
                }
                else if (windowPos[2] == "" && 3 <= this.sizeOfButton() && !(windowPos.Contains(title)))
                {
                    au3.WinMove(title, "", 1280, 0, 640, 463);
                    windowPos[2] = title;
                }
                else if (windowPos[3] == "" && 4 <= this.sizeOfButton() && !(windowPos.Contains(title)))
                {
                    au3.WinMove(title, "", 0, 463, 640, 463);
                    windowPos[3] = title;
                }
                else if (windowPos[4] == "" && 5 <= this.sizeOfButton() && !(windowPos.Contains(title)))
                {
                    au3.WinMove(title, "", 640, 463, 640, 463);
                    windowPos[4] = title;
                }
                else if (windowPos[5] == "" && 6 <= this.sizeOfButton() && !(windowPos.Contains(title)))
                {
                    au3.WinMove(title, "", 1280, 463, 640, 463);
                    windowPos[5] = title;
                }
            }
           
        }
        public void winMax(string title)
        {
            au3.WinSetState(title, "", 1);
        }
        public void winMin(string title)
        {
            if (this.isButtonVisible(title) == false)
            {
                if (this.isMinimized(title) == false)
                {


                    if (windowPos.Contains(title))
                    {
                        windowPos[windowPos.IndexOf(title)] = "";
                        
                        
                    }
                    au3.WinSetState(title, "", 6);
                }
            }
        }
        public int size()
        {
            return this.winlist[0, 0];
        }
        public int sizeOfButton()
        {
            int count = 0;
            for (int i = 1; i <= this.size(); ++i)
            {
                if (this.isButtonVisible(this.winlist[0, i]) == true)
                    ++count;

            }
            return count;
        }

    }
}
Edited by kantaki
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...