Change soundcard sample rate from command prompt (or macro) - batch-file

I have a situation where I often need to change the sample rate of my sound card. I need to be able to do this quickly. Now I have to go in to the soundcard settings and then the Advanced tab and switch.
My first idea was to write a C# or C++ program to do this, but I want to see if there are any simpler way to do this.
Is is possible to do this via the command prompt (and then put it in a bat-file)?
Or could I map a macro to do this?

If the steps you have to perform are always the same* and you don't find any other more elegant solution, you could automate the clicking/typing tasks with AutoHotkey: http://www.autohotkey.com/
* Dynamic content like InputBoxes for the SampleRate are easily possible.

Related

howto to use/configure win10 explorer's "search" to actually let me find programming artefacts?

I find the default behaviour of Exporer's search funtionality so annoying that I cannot help but wondering what this punishment is meant for.
My typical usecase is that I want to find all the files that some literal text appears in (considering filenames as well as content). One would think that it cannot get any simpler than that! I want NO restriction on the file types and just search for a bloody text like "foo.h" or "sin(". I do NOT want to use extra prefixes (like "name:=foo.h" which works for filename but not for the content).
Is there a way to configure Explorer's default behavior to do just that (I'd prefer to completely turn off the "smart" garbage and put it in a simple full text search mode - I don't care about what useless indexing windows may or may not have done.. my SSD is fast enough to rescan all the raw data that I want to search)? (or do I have to keep using 3rd party tools that actually know what a bloody plain text search is supposed to do?! what would be the best tool to use as a workaround - if necessarry?)

How to continually hold a keyboard key or mouse key using at least batch files?

In my fascination of the knowledge i learned about jscript (see here and here and here) to press keyboard keys and mouse keys within a batch file. However i want to take this to a more practical application.
There are certain games, such as minecraft, that require constant feedback that a button is being pressed. With the current links i provided, there does not seem to be any way of having the buttons pressed down for an extended period of time as to simulate movement or something within a game.
I get that it would be easier to install software to do this automatically but at the same time it is much more efficient to manipulate what is already installed on ones computers as it saves a significant amount of memory and processing power when compared to getting additional software. I do not care what language or how deep the programming must go, all i ask is that i can easily manipulate it through batch files like i could do with the SendKeys method in jscript.
Dug this out of the grave recently...
http://www.vbforums.com/showthread.php?705791-SendKeys-Hold-Down-a-Key
Here, users are using a VB script to hold a key down. However i do not have the time to verse myself in this yet, nor how to properly manipulate it into a batch script
ARG, its for html pages. JavaScript also follows suite with keydown,keypress,and keyup responses to handle user input, but never actually get the thing to be imitated on the local system. If only the games I want to play (tf2 in this case) could handle an environment in Linux then I could use xdotool. In this case I may just give up and revert to using a program that can do this faster than I can. If that's the case, can anyone give me some pointers? I know of autolt and hotkeys, but can they do what I desire?

What is the simplest way for my C program to receive some file paths from configuration?

I have an application that is currently configurable via command line arguments
myprog -fooFile 'foo.txt' -barFile 'bar.txt'
Command line parameters are a bit cumbersome so I want to allow for other avenues for these configurations but I am a bit disappointed that its looking more complicated then it taught it should be.
Solution 1: Use environment variables
I could make my program look for MYPROG_FOO_FILE and MYPROG_BAR_FILE envorinment variables. The implementation is just a getenv but env variables are global and add clutter and are also hard to configure. Specially for GUI apps because many window managers don't source ".profile" during initialization.
Solution 2: Use a configuration file
Since the fooFile and progFile are kind of static configuration values, it seems like its better to put those in a configuration file somewhere:
fooFile = /home/hugomg/foo.txt
barFile = /home/hugomg/bar.txt
But afaik there is no easy way in C to read an arbitrarily long string from a file. Do I really need to make a loop that keeps reallocing a buffer just for this?
Alternatively, since all my values are file names, is there some #define somewhere specifying the maximum size of a path string?
Your configuration file approach with a simple syntax looks good to me.
Since you are on Linux, you could use getline to read the file. It can handle lines of arbitrary length and manages the memory allocation for you.
If your application has a GUI, you may want your user to configure it from within the application. In this case, you may want to use a database to store your configuration; that way you can validate your data on it's way in, so your user can't write a bad config file. I would suggest using SQLite for this: it provides a full database in a file, and is pretty easy to use.
http://www.sqlite.org/

How to retrieve graphic adapter & monitor name that is attached to a Xorg screen, programmatically?

Obviously, this information is available in xorg.conf so I could try to parse this file. But is there a way to achieve this using Xlib calls (+ extensions) only?
Thanks,
PMJ
It must be possible, because I know the program xdpyinfo can do it. At first, I was going to suggest executing that from within your program and parsing the output. That shouldn't be necessary, though, since the source of xdpyinfo is freely available.
It looks like if you have a (Display*) variable (and you will, because pretty much every X11 function call requires one), you can call these wonderful macros to get interesting data, including ServerVendor and VendorRelease. That should cover the "graphic adapter" portion of your quest.
As for the monitor name, according to xdpyinfo.c, this is governed by XF86VidModeGetMonitor() which is part of an X11 extension. This returns a XF86VidModeMonitor structure which will reveal vendor, model, and other juicy data.
Run xdpyinfo-- if that program can query the data, so can your program.

how to add controls for a game using batch files?

I am attempting to make a platform game using batch files. I know this seems like a waste of time and there are better tools out there but I just wanted try it out. How do you set up controls so my character moves, jump, gravity and collision? Here's a link to a vid that shows a platform game made in batch file: http://www.youtube.com/watch?v=O_Egqa0Gqhc
You could start with reading Batch Minesweeper and pacman to learn a bit about batch gaming.
But to handle the arrow keys you need always an external program, as choice can't handle them.
With choice you could use "normal" letters, so you could use ASDW to move instead of the arrow keys, but choice is not available in XP.
And you should know how to start and communicate between multiple batch processes.
What you can do is try useing the bscript engine that way you will already the stuff that you need to make ur game but, consider the manual is extreme not like hugh extreme ment a bit confusing and take time to settle . Considering theyre trying to make the engine very fliud in batch script which is hugh lol

Resources