Jump to content
Macro Express Forums

Cycling macro menu?


Recommended Posts

Having created a couple of cool gaming macros, I can't help but wonder if there isn't a way to cycle through them up with a single key bind?

 

For example; say I had three different macros, intended for three different scenarios(modes), would it be possible to assign a key, to cycle through those macros, so that one single activation key could invoke each respective macro according to the chosen mode?

I was thinking something alone the lines of; [F12] as a mode(macro) switcher.

Then CTRL + [F4] to launch each respective macro; 1, 2, or 3 (depending on the chosen mode)?

PS, I would apologize in advance, if this is an obvious script function, as my understanding of scripting and macros is quite limited to say the least 

 

 

Link to comment
Share on other sites

Here's a way to switch between three modes: 1 --> 2 --> 3 --> 1 --> and so on.

 

The macro saves the value of %Mode%, which is remembered the next time the macro is run.

 

I tried to create a second macro to make decisions based on the current value of %Mode% but I couldn't make it work.

 

Variable Restore: Restore Integer Variables
Switch( %Mode% )
 
Case: 1
  Variable Set Integer %Mode% to 2
End Case
 
Case: 2
  Variable Set Integer %Mode% to 3
End Case
 
Case: 3
  Variable Set Integer %Mode% to 1
End Case
 
Default Case
  Variable Set Integer %Mode% to 1
End Case
 
End Switch
 
Text Box Display: Current Mode = %Mode%
Variable Save: Save Integer Variables

 

<VARIABLE RESTORE Option="\x02"/>
<SWITCH Variable="%Mode%"/>
<COMMENT/>
<CASE Value="1"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="2"/>
<END CASE/>
<COMMENT/>
<CASE Value="2"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="3"/>
<END CASE/>
<COMMENT/>
<CASE Value="3"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="1"/>
<END CASE/>
<COMMENT/>
<DEFAULT CASE/>
<VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="1"/>
<END CASE/>
<COMMENT/>
<END SWITCH/>
<COMMENT/>
<TEXT BOX DISPLAY Title="Current Mode = %Mode%" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs14 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<VARIABLE SAVE Option="\x02"/>

 

  • Like 1
Link to comment
Share on other sites

Okay, so I've tried it and it seems to work great!

With that said, any idea why the following wouldn't work?

<SOUND FILE File="C:\\working\\Audio\\_MODES\\%Mode%" Wait="FALSE" _PROMPT="0x0007"/>

 

The sound files(waves) are called 1,2,3 respectively.

I can get the sound byte to play, by pressing the sample button in the Sound File context menu, but I get a 'cannot find file' error when running the script, as though the %Mode% variable isn't accepted in the entry. 

 

 

 

Link to comment
Share on other sites

2 hours ago, acantor said:

The names of the sound files are missing their extensions.

 

1.xxx

2.xxx

3.xxx

 

You'll need to check the files themselves to discover what the extensions are. Maybe look at their properties.

 

The extensions will probably be three or four characters.

Hi, and thanks for the suggestions

To further interrogate this, I tried the following and found it to be functioning without issue;

<SOUND FILE File="C:\\working\\Audio\\_MODES\\1" Wait="FALSE" _PROMPT="0x0007"/>

 

Therefore and as the sound byte are successfully rendered, I'm left questioning if this has something to do with variable(%Mode% ) being used within the " " marks?

Link to comment
Share on other sites

The question I now have, is how do we control activations from script?
For example;  Mode 1 selected, calls for Macro 1 assigned to F4, whereas Mode 2, calls for Macro 2 to F4, and so-on and so-forth...


I was not able to find a command to accomplish this, or is my approach entirely wrong in thinking this way?
 

Link to comment
Share on other sites

There must be a more elegant solution than this -- I'm bothered by the apparent need to convert an integer variable to a string variable -- but it seems to work. Perhaps someone else can refine it.

 

The first script saves the Mode in a file on the hard drive.

The second script reads the file, and then decides what to do based on whether the Mode is 1, 2, or 3.

 

Script to switch modes and save current Mode in a file:

 

Variable Restore: Restore Integer Variables
Switch( %Mode% )
 
Case: 1
  Variable Set Integer %Mode% to 2
End Case
 
Case: 2
  Variable Set Integer %Mode% to 3
End Case
 
Case: 3
  Variable Set Integer %Mode% to 1
End Case
 
Default Case
  Variable Set Integer %Mode% to 1
End Case
 
End Switch
 
Variable Modify Integer %Mode%: Convert to Text String (%ModeString%)
Variable Modify String: Save %ModeString% to "C:\tmp\ModeFile.txt"
 
Text Box Display: Current Mode = %Mode%
Variable Save: Save Integer Variables

 

<VARIABLE RESTORE Option="\x02"/>
<SWITCH Variable="%Mode%"/>
<COMMENT/>
<CASE Value="1"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="2"/>
<END CASE/>
<COMMENT/>
<CASE Value="2"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="3"/>
<END CASE/>
<COMMENT/>
<CASE Value="3"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="1"/>
<END CASE/>
<COMMENT/>
<DEFAULT CASE/>
<VARIABLE SET INTEGER Option="\x00" Destination="%Mode%" Value="1"/>
<END CASE/>
<COMMENT/>
<END SWITCH/>
<COMMENT/>
<VARIABLE MODIFY INTEGER Option="\x04" Destination="%Mode%" Variable="%ModeString%"/>
<VARIABLE MODIFY STRING Option="\x11" Destination="%ModeString%" Filename="C:\\tmp\\ModeFile.txt" Strip="FALSE" NoEmbeddedVars="FALSE"/>
<COMMENT/>
<TEXT BOX DISPLAY Title="Current Mode = %Mode%" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs14 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<VARIABLE SAVE Option="\x02"/>

 

Script to perform different tasks depending the current Mode:

 

Variable Set String set %Mode% to the contents of C:\tmp\ModeFile.txt
 
Switch( %Mode% )
 
Case: 1
// Insert instructions for Mode 1
  Text Box Display: Mode 1
End Case
 
Case: 2
// Insert instructions for Mode 2
  Text Box Display: Mode 2
End Case
 
Case: 3
// Insert instructions for Mode 3
  Text Box Display: Mode 3
End Case
 
End Switch
 

<VARIABLE SET STRING Option="\x03" Destination="%Mode%" Filename="C:\\tmp\\ModeFile.txt" Strip="FALSE" NoEmbeddedVars="FALSE"/>
<COMMENT/>
<SWITCH Variable="%Mode%"/>
<COMMENT/>
<CASE Value="1"/>
<COMMENT Value="Insert instructions for Mode 1"/>
<TEXT BOX DISPLAY Title="Mode 1" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs14 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<END CASE/>
<COMMENT/>
<CASE Value="2"/>
<COMMENT Value="Insert instructions for Mode 2"/>
<TEXT BOX DISPLAY Title="Mode 2" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs14 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<END CASE/>
<COMMENT/>
<CASE Value="3"/>
<COMMENT Value="Insert instructions for Mode 3"/>
<TEXT BOX DISPLAY Title="Mode 3" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs14 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<END CASE/>
<COMMENT/>
<END SWITCH/>
 

  • Like 1
Link to comment
Share on other sites

24 minutes ago, acantor said:

There must be a more elegant solution than this ... The first script saves the Mode in a file on the hard drive.

The second script reads the file, and then decides what to do based on whether the Mode is 1, 2, or 3.

That is a very interesting approach, and a far better one than I managed to conjure-up, which was that of mix-matching keyboard macros with Macro Express - and nowhere near elegant 🤪

That said, I will try to implement this and see how it goes

PS. I was surprised to find that there is no command to drive macro activation from a variable, though here again, it is most likely my own limited understanding of programming that leads me to think this way - thanks again for your very helpful contribution btw, I truly appreciated it 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...