Sign in to follow this  
Followers 0
zilexa

How to check greyed out buttons

12 posts in this topic

#1 ·  Posted (edited)

AutoIt Window Info shows me on tab "Control", the value of 'Style' of a button (like the "Apply" button you have on many windows where you can change settings and then apply them) changes when it has been pressed and greyed out (since you can only press Apply once, and if you change something in the window, it becomes un-greyed so you can Apply the changes again).

I want to press the OK button but only after Apply has been greyed out (since applying changes might take some time). I could use sleep(2000), but I want to use the Style. I know the style value becomes 0x58010000.

ControlClick doesn't support Style. I can't find a function that does..

Edited by zilexa

Share this post


Link to post
Share on other sites



Hi, and wellcome to the forums!

Try ControlConmand($Title, "", $CtrlID, "IsEnabled").


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Or if it's your GUI, you can do something like this:

#include <GuiConstantsEx.au3>

$GUI = GUICreate("Apply Test", 300, 200)

$CheckBox = GUICtrlCreateCheckbox("Option", 20, 20)

$Apply_Button = GUICtrlCreateButton("Apply", 20, 170, 60, 20)
GUICtrlSetState(-1, $GUI_DISABLE)

$OK_Button = GUICtrlCreateButton("OK", 160, 170, 60, 20)
GUICtrlSetState(-1, $GUI_DISABLE)

$Cancel_Button = GUICtrlCreateButton("Cancel", 230, 170, 60, 20)

GUISetState(@SW_SHOW, $GUI)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $OK_Button, $Cancel_Button
            Exit
        Case $CheckBox
            GUICtrlSetState($Apply_Button, $GUI_ENABLE)
            GUICtrlSetState($OK_Button, $GUI_DISABLE)
        Case $Apply_Button
            GUICtrlSetState($Apply_Button, $GUI_DISABLE)
            GUICtrlSetState($OK_Button, $GUI_ENABLE)
    EndSwitch
WEnd

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks!

It's not GUI, just script. Goal:

(1) trying to automatically launch Media Player Classic HC,

(2)go to Options, go to Format,

(3) then select "file(s)", "With Icons", "Video" (check the screenshot)

(4) Press Apply (takes a second) and then OK (also takes a second) and then close MPC.

Actually I am still stuck with step 3. This is what I tried:

ControlCommand ( "Options", "", "File(s)", "Check", "")

ControlCommand ( "Options", "", "With icons", "Check", "")

ControlCommand ( "Options", "", "&Video", "Check", "")

Here I am using the ControlID TEXT, but I also tried with the ID. And even with CLASS; TEXT; and INSTANCE. But the buttons won't be selected.

Also tried using ControlClick. Not working. Only other thing I know would absolutely work is to simulate the keyboard using Send("{TAB}") a lot of times and the SPACE etc. But that's not very efficient.

See the uploaded screenshot for an idea of the window I am dealing with..

post-45210-1232544544_thumb.jpg

Edited by zilexa

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I now also tried:

Run("C:\Program Files\Media Player Classic HomeCinema\mplayerc.exe")
WinWaitActive("[CLASS:MediaPlayerClassicW]", "")
Send("o")
Send("f")
ControlClick ( "Options", "", "[CLASS:Button; TEXT:File(s); INSTANCE:20]")
ControlClick ( "Options", "", "[CLASS:Button; TEXT:With icons; INSTANCE:22]")
ControlClick ( "Options", "", "[CLASS:Button; TEXT:Video; INSTANCE:13]")

and

Run("C:\Program Files\Media Player Classic HomeCinema\mplayerc.exe")
WinWaitActive("[CLASS:MediaPlayerClassicW]", "")
Send("o")
Send("f")
ControlClick ( "Options", "", "Button20")
ControlClick ( "Options", "", "Button22")
ControlClick ( "Options", "", "Button13")

Both work up to Send("f") wich will show the window in the screenshot, but the checkboxes and the video button are not being checked/clicked.

Edited by zilexa

Share this post


Link to post
Share on other sites

Both work up to Send("f") wich will show the window in the screenshot, but the checkboxes and the video button are not being checked/clicked.

Have you tried to wait also for the «Options» window?

Run("C:\Program Files\Media Player Classic HomeCinema\mplayerc.exe")
WinWaitActive("[CLASS:MediaPlayerClassicW]", "")
Send("o")
Send("f")
WinWaitActive("Options")
ControlCommand("Options", "", "Button20", "Check")
ControlCommand("Options", "", "Button22", "Check")
ControlCommand("Options", "", "Button13", "Check")

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

I tried this to be sure and I didn't get the error message :S

Run("C:\Program Files\Media Player Classic HomeCinema\mplayerc.exe")
WinWaitActive("[CLASS:MediaPlayerClassicW]", "")
Send("o")
Send("f")
If WinExists("Options") Then
ControlClick ( "Options", "", "Button20")
ControlClick ( "Options", "", "Button22")
ControlClick ( "Options", "", "Button13")
Else
    MsgBox(48, "Error", "The window does not exists, check the title (you can use [REGEXPTITLE:...] for such case).")
EndIf

&

Run("C:\Program Files\Media Player Classic HomeCinema\mplayerc.exe")
WinWaitActive("[CLASS:MediaPlayerClassicW]", "")
Send("o")
Send("f")
If WinExists("Options") Then
ControlClick ( "Options", "", "[CLASS:Button; TEXT:File(s); INSTANCE:20]")
ControlClick ( "Options", "", "[CLASS:Button; TEXT:With icons; INSTANCE:22]")
ControlClick ( "Options", "", "[CLASS:Button; TEXT:Video; INSTANCE:13]")
Else
    MsgBox(48, "Error", "The window does not exists, check the title (you can use [REGEXPTITLE:...] for such case).")
EndIf

Share this post


Link to post
Share on other sites

I tried this to be sure and I didn't get the error message

To be sure in what, that the window exists? Well, it can be created at very first step, when you launch the WMP. But it's hidden, therfore the WinExists() return True, just try to wait for window to be active, or at leaset visible (BitAND(WinGetState("Options"), 2) = 2).

P.S

But in some cases, ControlCommand can work even with hidden windows.


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

@MrCreatoR: Well, when I test it, by running the script, I am staring at the Options window... and it's active. If I add a few Send("{TAB}") I can see the selected part changes in the window. So the window is active.. But I will try both your suggestions.

@Volly, Media Player Classic HomeCinema has a switch, /regvid. But this only registers the file assocations. The icons of videofiles will have unrecognizable Windows icons.

There is no commandline to apply the associations with icons. I did post this in the forum but I did that before and I doubt that the /regvid switch will ever be updated or a new switch will be added.

I am going to try the suggestions and some more.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

MrCreatoR was 100% correct. I should have waited for the Options window to be active. The code in post #6 worked and when I removed WinWaitActive("Options") again it did not work.

Now I understand, AutoIt would simply press those buttons immediately after the options window command was given. Although it looks to me as if that window also opens immediately, there is ofcourse a mini pause..

Sorry for this, I created a few small simple AutoIt scripts and I always used WinWaitActive for everything. Should have done that or at least thought about it!

Thanks for the suggestions.

One small question, how come this code works:

Run("C:\Program Files\Media Player Classic HomeCinema\mplayerc.exe")
WinWaitActive("[CLASS:MediaPlayerClassicW]", "")
Send("o")
Send("f")
WinWaitActive("Options")
ControlCommand("Options", "", "[TEXT:File(s)]", "Check")
ControlCommand("Options", "", "[TEXT:With icons]", "Check")
ControlCommand("Options", "", "[TEXT:&Video]", "Check")
ControlCommand("Options", "", "[TEXT:&Apply]", "Check")


If ControlCommand("Options", "", "[TEXT:&Apply]", "IsEnabled") < 1 Then 
    ControlClick("Options", "", "OK")
EndIf

But when I use = 0 instead of <1, OK is never pressed? I want OK to be pressed only when IsEnabled returns 0 (after Applying is finished).

Btw, I doubt IsEnabled is actually useful in my case. My laptop is too fast to test, applying takes very little time. But what if applying takes more time, will the IF statement wait until IsEnabled returns 0 before executing the ControlClick?

I don't think so... It is nice to learn more this way.

Edited by zilexa

Share this post


Link to post
Share on other sites

MrCreatoR was 100% correct. I should have waited for the Options window to be active

It's a lesson for some guys here on the forum: “Check first what people suggested/posted to your question, and only then answer back” :)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
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
Sign in to follow this  
Followers 0