Jump to content

How to keep toggling between two keyboard shortcuts each time a script runs


Recommended Posts

Is there a command to keep toggling between two keyboard shortcuts each time a script runs? For example, when I run the script it will send Ctrl+1, and then the next time I run the script it will send Ctrl+2, and then the next time I run the script it will send Ctrl+1 again, and keep toggling between the two.
 
Send ("^{1}",0)
Send ("^{2}",0)
 
What about the TripleTapKeys command, can that be used to send keyboard shortcuts or is it limited to single keys?
Link to comment
Share on other sites

Well, you can do it either per registry, or per ini file (at least the two of which i know of). The 3rd could be environmental variables, but ...  

Anyway here is an example over the ini file:

Local $inipath
Local $nr

$inipath=@ScriptDir & "\myfile.ini"

$nr=IniRead($inipath,"config","switch","1")
$nr=$nr+1
If $nr>2 then $nr=1
IniWrite($inipath,"config","switch",$nr)

Switch $nr
    case 1
        ConsoleWrite ("Send key 1" & @crlf)
    Case 2
        ConsoleWrite ("Send key 2" & @crlf)
    ;Case 3
EndSwitch

I like to use ini files, as they are easier to delete and to modify, and do not blow up the registry.

Edited by Dan_555

Some of my script sourcecode

Link to comment
Share on other sites

Thanks Nine for letting me know that.
 
Thanks Dan_555 for the info , but I can only use AutoIt scripts because I'm using the script editor in the UI of a program called Intelliremote (it let you assign AutoIt scripts to buttons on a remote control), I tried your script though, but I couldn't get the ini file to run. How do you run it?
Link to comment
Share on other sites

Ahem, 
you said: you asked for a way to run a script, which will flip between commands, each time that one script is run.

The ini file does not run. The ini file holds the state of the button. (you can rename the ini file from the script, to something meaningful with the scrip which you will compile.)

 

The switching happens here:

Switch $nr
    case 1
        ConsoleWrite ("Send key 1" & @crlf)
    Case 2
        ConsoleWrite ("Send key 2" & @crlf)
    ;Case 3
EndSwitch

But you have to replace the console write lines with your own commands or send keys, as you know which one to use.

I have written the example script in that way, so that you can test the script before inserting the send keys. (well, at least, when i test my scripts, i do it in this way.)

When you run it, (and you should run it from the autoit scite editor first (if you have installed it)) the console part of the scite editor will show you a text.

The first time it is run, it will be "Send key 1". 
The second time, the text "Send key 2" will appear.

The 3rd time, it should switch back to 1.

If it does that, then you can replace the consolewrite with the send keys.

Yes you can use "Ctrl alt shift p" (which is ^!+p ) with the send command, read Here (autoit send help) on how to do it.

 

And i do not understand what this means:

Quote

but I can only use AutoIt scripts because I'm using the script editor in the UI of a program called Intelliremote

I do not have the intelliremote software and therefore i do not know how it works.

Edited by Dan_555

Some of my script sourcecode

Link to comment
Share on other sites

I would rather do it like this:

Local $inipath=@ScriptDir & "\myfile.ini"
Local $nr=IniRead($inipath,"config","switch","1")
If $nr = 1 Then
    ConsoleWrite ("Send key 1" & @crlf)
    IniWrite($inipath,"config","switch",'2')
Else
    ConsoleWrite ("Send key 2" & @crlf)
    IniWrite($inipath,"config","switch",'1')
EndIf

 

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

  • 3 weeks later...
Thanks Dan_555 and careca for your help. I am so confused you wouldn't believe.
 
Here is a screenshot of Intelliremote's UI which has the built in AutoIt script editor.
 
598369502_2020-07-2615_09_12-Intelliremote-WMP.jpg.a86dbf158f86824a1755b93ee1837215.jpg

What I meant by:

Quote

"I can only use AutoIt scripts because I'm using the script editor in the UI of a program called Intelliremote"

...is I can only add AutoIt commands to the Script Event section in Intelliremote's UI.

In the screenshot I have added the following commands to the Intelliremote script editor as an example:

Send ("^1", 0)
Send ("^2", 0)

I added these commands to the Record button on the remote control. So now every time I press the Record button it sends Ctrl+1, followed by Ctrl+2.

I want to make it so that each time I push the record button it toggles between Ctrl+1 and Ctrl+2. For example, the first time I press the record button it will send the Ctrl+1 command, and then the next time I push the record button it will send the Ctrl+2 command, and then keep toggling between the two commands there after.
 
With the details you have given I don't understand how to implement the ini file to use with Intelliremote.
 
Link to comment
Share on other sites

Hi, i never used this intelliremote, not sure what it is or what it does, no time atm to investigate about it, but if it runs autoit scripts, you could place the code i gave you there.

The code does all by itself, creating the ini, writing to it, and reading from it.

At each run it writes the last state, either first or second command, and the next run, it reads the ini, and runs the other command.

So try placing the code there, all of it, see it the thing works with it.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

I can't test it either, because i do not have the IR, too. But, the problem is that it does not run autoIT scripts but AutoItX scripts.

The X script does not have while, if, wend. It has only some functional commands, because it is meant to provide functions, which autoit has, and the other scripting language doesn't.

And unless the IR software provides a way to make if then else statements, that script with the ini would not work. 

But, you can compile an autoit script into an executable, which would, when ran,  switch the states between 1 and 2.

And i saw that the IR software can be made to start an external app.

Edited by Dan_555

Some of my script sourcecode

Link to comment
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
 Share

  • Recently Browsing   0 members

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