Sign in to follow this  
Followers 0
Johnny79

Buttons With If/Then Statments Involving Windows Mixer

10 posts in this topic

Hi,

I want to creat a set of buttons that will open

C:\windows\system32\sndvol32.exe

and then switch the source to the Mic Input (the select button's ID is 4000). That is simple enough, but what I can't figure out how to do is some sort of an If/Then function(or anything else that will work) that will not do anything if the mic input is selected, only if it is not selected. I tried a few different things, but I don't seem to be able to get the syntax right. I am sure there is some explination somewhere I overlooked, but I can't seem to find it easily enough. Any help will be greatly appreciated. Thanks!

-Johnny

Share this post


Link to post
Share on other sites



It's easier to help you if you post your code. That way folk can see what you have tried, spot obvious errors, etc.

It also shows that you have actually done something, and don't just want others to do it for you.

I don't suspect that's true, but it's good to show it, anyway.

;o)

(or


nothing is foolproof to the sufficiently talented fool..

Share this post


Link to post
Share on other sites

I guess pasting the script would help huh? heh, Well, I have changed it quite a bit, and I stole the template from one of the function refferences. I am not sure if this was the best template to steal, but all I want is a window that has 3 buttons. 1 button swithces the windows volume control to "Line In" and if "Line In" is already checked, I want it to do nothing. I want a button to do the same thing for the "Microphone Input", and I want a button to cancel another program (I can take care of that part). Also, I dont' want the script to close after you switch the source in windows mixer. I need the script window up all the time. Any help would be greatly appreciated! Thanks

#include <GUIConstants.au3>

Opt("GUICoordMode",2)

Opt("GUIOnEventMode", 1)

$parent1 = GUICreate("Streaming Control Pannel")

GUISetOnEvent($GUI_EVENT_CLOSE, "Topbar")

$LineIn1 = GUICtrlCreateButton ("Line In", 10, 30, 50)

GUICtrlSetOnEvent(-1, "LineIn1")

$Mic1 = GUICtrlCreateButton ( "Mic", 0, -1)

GUICtrlSetOnEvent(-1, "Mic1")

GUISetState(@SW_SHOW)

while 1

Sleep(10)

wend

func LineIn1()

Run("C:\WINDOWS\system32\sndvol32.exe")

if ("Volume Control", 7000 = 1) then winclose("Volume Control")

endfunc

func Mic1()

endfunc

func topbar()

select

case @GUI_CTRLID = $GUI_EVENT_CLOSE

Exit

endselect

endfunc

Share this post


Link to post
Share on other sites

There's also..

proper autoit tags

Hey, I didn't say I could help you! <_<

I'll prolly pop back later, though, see how yer getting on..

;o)

(or


nothing is foolproof to the sufficiently talented fool..

Share this post


Link to post
Share on other sites

In line

If ("Volume Control", 7000 = 1) Then WinClose("Volume Control")
("Volume Control", 7000 = 1) is NOT the proper way to define a condition.

Share this post


Link to post
Share on other sites

Ok, lets try this again, I know that was not the proper way to phrase that condition, if it was, then I wouldn't be here, would I? I guess the question I should be asking is, HOW should I word it? Or What would YOU do to make this happen? Answers to either of those would be much appreciated. Thanks.

Share this post


Link to post
Share on other sites

Ok, lets try this again, I know that was not the proper way to phrase that condition, if it was, then I wouldn't be here, would I? I guess the question I should be asking is, HOW should I word it? Or What would YOU do to make this happen? Answers to either of those would be much appreciated. Thanks.

What you have is never going to work.

Where are you getting the ("Volume Control", 7000) from?

Are you aware that there is a UDF to perform these function?

See this thread

Audio UDF


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

And the question that others might be asking is, what have YOU done to find out what IS the correct way query the window control. Which methods have YOU tried? As my business manager used to say to me; "A desire is a not a plan!"

Firstly, I'm no expert in automating outside windows, I just don't use AutoIt for those kinds of things (for controlling system volumes, I use a mix of Macro Express (always resident) and "quickmix".. I do Ctrl+ALT+Keypad* to set any one of ten preset mixer settings. The quickmix filetype also has commands for "udpdate with current settings", etc (at least on my system, it does). All very simple to implement; I've been running it this way since before AutoIt was even created, and it works great to this day. I do a lot of audio work, so having instant HotKey access to multiple audio setups is essential, for me.

But if you still want to make a GUI for this sort of thing..

The reason it closes, is because there's an error. Didn't you get some kind of error message informing you that your script is wonky? My console spewed out..

---------- RUN ----------
I:\work\dev\autoit\soundvolproblem.au3 (26) : ==> Missing right bracket ')' in expression.: 
if ("Volume Control", 7000 = 1) then WinClose("Volume Control") 
if ^ ERROR

Output completed (2 sec consumed) - Normal Termination

You just made up that line, didn't you! That's not code! <_<

Have you seen this?

Second post.

;o)

(or


nothing is foolproof to the sufficiently talented fool..

Share this post


Link to post
Share on other sites

Hey guys, thanks for the help, I appreciate it. That UDF thread didn't quite have what I needed, but it pointed me in the right direction. Thanks Geo! That's all I needed. Have a good one guys.

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