rotate commands - one button three things (1 Viewer)

teststrips

Portal Member
March 2, 2008
10
0
My goal is to accomplish the following - I'd like to remap a button to work my lighting system.
On my first press of the button my movie lights turn on + main lights off
Second press - all lights off
third press - main lights on

I've accomplished this previously via a batch file, which works great until I use it through translator - it works fine when I manually run it via command prompt, or via double clicking it, but it does not run fine with the built in launcher for some reason. It runs the same command over and over again - batch file code below

Code:
@echo off
goto option%lights%

:option1:
echo Main lights on
"C:\Program Files\Common Files\X10\Common\ahcmd.exe" sendrf c2 on
c:\windows\system32\setx lights 2
exit

:option2:
echo movie lights ON
"C:\Program Files\Common Files\X10\Common\ahcmd.exe" sendrf c1 on
echo main lights off
"C:\Program Files\Common Files\X10\Common\ahcmd.exe" sendrf c2 off
c:\windows\system32\setx lights 3
exit

:option3:
echo movie lights off
"C:\Program Files\Common Files\X10\Common\ahcmd.exe" sendrf c1 off
c:\windows\system32\setx lights 1
exit

The Ahcmd.exe is a dos command tool to send X10 commands through my USB X10 Controller CM19a
Setx is a microsoft tool for setting environmental variables that are persistant (rather than the regular set command, which only sets the variable for the current window) - for some reason the setx command is unable to set the environmental variable for the whole system when run from inside Translator. (operating system = XP pro)

I'm not stuck on making my batch file work. If you have an alternate solution to accomplish the same goal, I'm game to try something else.
 

teststrips

Portal Member
March 2, 2008
10
0
I figured out another way to do this - i modified my batch file to use temporary files to remember what was done last instead of using environmental variables. I created a folder called batch under c:\ and have my script create and delete files lights1.txt, lights2.txt, and lights3.txt

Code:
@echo off
if exist c:\batch\lights1.txt goto option1
if exist c:\batch\lights2.txt goto option2
if exist c:\batch\lights3.txt goto option3
echo NO FILE EXISTS
pause

:option1:
echo Main lights on
"C:\Program Files\Common Files\X10\Common\ahcmd.exe" sendrf c2 on
echo 2>c:\batch\lights2.txt
del c:\batch\lights1.txt
exit

:option2:
echo movie lights ON
"C:\Program Files\Common Files\X10\Common\ahcmd.exe" sendrf c1 on
echo main lights off
"C:\Program Files\Common Files\X10\Common\ahcmd.exe" sendrf c2 off
echo 3>c:\batch\lights3.txt
del c:\batch\lights2.txt
exit

:option3:
echo movie lights off
"C:\Program Files\Common Files\X10\Common\ahcmd.exe" sendrf c1 off
echo 1>c:\batch\lights1.txt
del c:\batch\lights3.txt
exit

hooray for DOS :)
 

and-81

Retired Team Member
  • Premium Supporter
  • March 7, 2005
    2,257
    183
    Melbourne
    Home Country
    Australia Australia
    excellent!

    In a future version you will be able to put all that logic into a macro. I've already written most of the code to do this, but I'm not putting it in yet because it will break existing macros. It's part of a big overhaul to the way commands work in IRSS which should be coming in around version 1.5.0.

    Good to hear you've got it working for you in the meantime.

    Cheers,
     

    teststrips

    Portal Member
    March 2, 2008
    10
    0
    For anyone who is interested what else you can do with this rotating method - I've found another use for it. My PC acts double duty - its a PC most of the time, but it is also my HTPC. I generally only use one of my screens at a time... my monitor for PC duty and my projector for watching TV and Movies. It got REALLY old manually switching displays via Microsoft's tools, but I eventually found UltraMon. Ultramon allows you to set profiles, and save them as files with the extension .umprofile. I set one up for my monitor and one for my Projector. I originally mapped each display its own dedicated key on my remote, but now that I figured this out, I combined them and now have an extra button (which I now used to open WinAmp with my wife's favorite play list).

    Exact code below - its nearly the same as above, except I used different names for the temp .txt files, and simply link the .umprofile files I set up for my monitor and projector.

    Code:
    @echo off
    if exist c:\batch\projector.txt goto projector
    if exist c:\batch\monitor.txt goto monitor
    
    :projector:
    "C:\Documents and Settings\Joel\Application Data\Realtime Soft\UltraMon\Profiles\Projector.umprofile"
    echo monitor>c:\batch\monitor.txt
    del projector.txt
    exit
    
    :monitor:
    "C:\Documents and Settings\Joel\Application Data\Realtime Soft\UltraMon\Profiles\Monitor Only.umprofile"
    echo projector>projector.txt
    del monitor.txt
    exit

    I may get a bit more fancy and have IR blasted to turn on my projector when switching to it, and turning it off when switching back, but I'm hesitant due to the length of time it takes for my projector to "warm up"... I can do some valuable email, facebook, or ebay checking during that time.
     

    Users who are viewing this thread

    Top Bottom