Jump to content

Recommended Posts

Posted

It has been a minute since I have uploaded one of my scripts. This is a very simple one!

In a nutshell this program opens the MS Sound Window,  Selects a Playback Device and

Check its Mute status.  If it finds that it is Muted then the appropriate Button is clicked

on to UnMute it.   That's it!   If you want the Program to check and UnMute (if needed)

ALL of the Playback Devices in the list then use a For/Next Loop. I have made that very

simple to implement within my script.   Just open it up to see what I am talking about,

I used Windows 11 NotePad  v11.2410.21.0 / Font: Consolas / Regular / 12   as an Editor.

I am somewhat "OCD" when it comes to lining up my script. I also find it easier to read

when I look at my code sometime later!  Having it line up helps me to read it better.

Anyway, Script is attached.... Any feedback would be much appreciated... 

 

MuteCheckerV100.au3

Posted (edited)

My desktop is Windows 11 v24H2 Korean version. After a couple of localization changes, it works as intended. I was thinking of doing something similar for my zPlayer.

ControlCommand($CWHandle, "", "SysTabControl321", "TabRight")
changed to:
$tabHandle = ControlGetHandle($CWHandle, "", 12320)
ControlClick($CWHandle, "", $tabHandle, "left", 1, 25 + ($TabsLoop - 1) * 50, 12)

If $IconBnTx = "&Mute" Then
changed to:
If $IconBnTx = "음소거(&M)" Then

 

Edited by CYCho
Posted

Thanks for your feedback! I can see that you are a much better coder then me

Anyway I do have a few questions....

ControlCommand($CWHandle, "", "SysTabControl321", "TabRight")
changed to:
$tabHandle = ControlGetHandle($CWHandle, "", 12320)
ControlClick($CWHandle, "", $tabHandle, "left", 1, 25 + ($TabsLoop - 1) * 50, 12)

If $IconBnTx = "&Mute" Then
changed to:
If $IconBnTx = "음소거(&M)" Then

1. From what I understand per  AutoIt Help... ControlGetHandle returns:  the handle (HWND) value

    So I don't understand how $tabHandle  can be used as a controlID number in ControlClick

2.  I don't fully understand how you are calculating the X/Y position (25 + ($TabsLoop - 1) * 50, 12)

3.  If $IconBnTx = "&Mute" Then
        changed to:
       If $IconBnTx = "음소거(&M)" Then

Here I am guessing that your change to my code has something do with Version of Windows that you are using.

Again THANKS for you feedback...

Posted (edited)
9 hours ago, TreatJ said:

So I don't understand how $tabHandle  can be used as a controlID number in ControlClick

$CWHandle is a window handle and $tabHandle is the handle of the tab control. ControlClick() requires both.

9 hours ago, TreatJ said:

I don't fully understand how you are calculating the X/Y position (25 + ($TabsLoop - 1) * 50, 12)

It would be better to use a control handle if it is easy to get and is applicable worldwide. I used AutoIt v3 Info Tool (Au3Info.exe in AutoIt installation folder) to find the coordinates of tabs.

 

9 hours ago, TreatJ said:

I am guessing that your change to my code has something do with Version of Windows

Yes, you are right.

Please refer to the following link for another post of mine. This code does the same thing as your code does and more. _MasterVolume() function takes approximately 10 milliseconds for each cycle.

 

Edited by CYCho
Posted

WOW... Like I said before.... you look to me to be a Pro Coder! Me? I'm  just a Rookie! LOL

I have never coded a var like this before...

$sMsg = ($bMute = 1) ? ('muted!') : ('not muted!')

I ran your program (very cool by the way) and the way you coded

the $sMsg var  works (and is also very cool by the way!)... I looked in Autoit Help but did not come across (or missed it)

how this works... could you please help me to better understand how it works? thanks

Posted

If you consider yourself a "Rookie" Then I would say that I'm really pushing it to call

myself a "beginner" ! LOL Thanks for all your feedback so far!! You are right about

this Autoit community! I have been working with Autoit for years now (So you would think

that I would be a better coder by now) and have seen the capability of Autoit improve

many times over on what it can do...and how it does it!   I will have a look at that

'Ternary operator' . Thanks again for your help... 

Posted

Back in 2019 I posted and uploaded one of my bigger AutoIt Programs (Bigger for me anyway).

that I named 'TxtFinderV475' and sometime later I unloaded my latest Version of it:  'TxtFinderV512'.

I wrote this for my wife and decide to share it on AutoIt.  In a nutshell my program searches through

many Text Files for user specified text. My wife likes to store information in many (very many) different

NotePad Files. So I wrote this to help her find that info. The script is zipped up with other files that it

needs to work with.  Once you unzip it you will see what I mean. Hope it works on your Version of

Windows! Please let me know if it did or not.... Anyway take a look inside my script.  Do a search for

the following function...

;Func: _FindTxInFile()    (Note that I have the ( ; ) in front of "Func" This will take you to the Remarks first)

In this Function you will find the heart of how it works.... I just wrote my program around it... I found this code

in the Autoit script examples forum.  As you can see in my remarks I have noted the Author of it. I am

not one to take credit for other people's work.  Anyway just go to AutoIt's  Browse / Forum,,, and Enter this into Search:

TxtFinderV512       Hopefully you will have no problem finding it. Last time I searched for it this way (02/08/25) only 

one result came up.... If you need help finding it just let me know... and if you do find it please run it... have a look

inside the script... and as before your feedback would be much appropriated!

P.S.  If you open up the script in Windows (11)  NotePad  v11.2410.21.0 / Font: Consolas / Regular / 12

the code should line up good... and at least for me... should be easier to read through. Your Version

of Window may not... but I hope it does....

 

Posted

By the way.... found it:

Conditional operator

? : Select conditionally an expression. e.g. $condition ? $expression1 : $expression2

i did not even know that AutoIt had this capability! Thanks for the Info

 

Posted (edited)

I am not sure if others may have the same question about how to

Code using the 'Ternary operators' method... but if they do... send

them this little script that I just put together....

Sometimes (at least for me) coding it out like I just did can be very

helpful towards giving one a better understanding of how it works

Maybe others too!

 

TernaryOpv100.au3

Edited by TreatJ
Updated code

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
  • Recently Browsing   0 members

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