EDITED SCRIPTS! Activate your PTT with a mouse click or key stroke

A place to discuss and exchange ideas on all types of control surfaces for PowerSDR and Thetis.
ea3aqr
Posts: 270
Joined: Mon Mar 04, 2019 10:50 pm
Location: BCN

EDITED SCRIPTS! Activate your PTT with a mouse click or key stroke

Postby ea3aqr » Thu May 19, 2022 5:54 pm

I've edited my scripts to return focus back to my previous active window

Hi,

I was frustatated for having to click on Thetis to recover my "space bar" PTT when focus was in another Window in my screen (for example when typing callsigns in my log book).

After 2 days of search I've found a solution and now I can use a key stroke or a click in my mouse to get focus on Thetis, automatically start transmiting and set focus back to my previous window.

1) Download and install AutoHotKey: https://www.autohotkey.com/
2) Right click on your desktop, select "new" and create 2 new AHK scripts (one for your keyboard and one for your mouse)
3) For your keyboard script copy and paste the following lines:

f12:: ; Sets the key that you will use for PTT (I use f12 but you can assign any other key)
{
ActWin := WinActive("A") WinActivate, ahk_id %ActWin% ; Detects active window
WinActivate, ahk_exe Thetis.exe ; Sets focus to Thetis
SendInput, {SPACE} ; Sends (space bar) to Thetis to activate/release PTT
Sleep 200 ; Waits x miliseconds before setting focus back to previous window (if you want you can delete this line)
WinActivate, ahk_id %ActWin% ; Returns focus to previous active window
}
return


4) For your mouse's script copy and paste the following lines into the second blank script you created:

XButton1:: ; Detects the click on your 4th mouse button
{
ActWin := WinActive("A") WinActivate, ahk_id %ActWin% ; Detects active window
WinActivate, ahk_exe Thetis.exe ; Sets focus to Thetis
SendInput, {SPACE} ; Sends (space bar) to Thetis to activate/release PTT
Sleep 200 ; Waits x miliseconds before setting focus back to previous window (if you want you can delete this line)
WinActivate, ahk_id %ActWin% ; Returns focus to previous active window
}
return


You can use other mouse buttons, just change it in first line of the script:
LButton (left button)
RButton (Right button)
MButton (Middle or wheel mouse button)
XButton1 (4th mouse button)
XButton2 (5th mouse button)


5) Save your scripts and make a shortcut for each
6) To launch the scripts at Windows startup, move both shortcuts to C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
7) Restart Windows

If you don't want to run your scripts automatically on startup skip step 6, right click on the script and select "run script" to launch it when you want.

EDIT: If you run Thetis as administrator you must also run script as administrator

That's it!
Now you can use a key stroke or a single mouse click to transmit from anywhere in your windows.

Hope it helps someone!

73
Jordi
EA3CL
Last edited by ea3aqr on Fri May 20, 2022 3:55 pm, edited 16 times in total.
New call sign EA3CL
User avatar
w-u-2-o
Posts: 5525
Joined: Fri Mar 10, 2017 1:47 pm

Re: Activate your PTT with a mouse click or key stroke

Postby w-u-2-o » Thu May 19, 2022 7:06 pm

Jordi,

Will this also return focus to the Window you were in after sending the space character, or does it leave focus with Thetis?

73,

Scott
ea3aqr
Posts: 270
Joined: Mon Mar 04, 2019 10:50 pm
Location: BCN

Re: Activate your PTT with a mouse click or key stroke

Postby ea3aqr » Thu May 19, 2022 9:01 pm

w-u-2-o wrote:Jordi,

Will this also return focus to the Window you were in after sending the space character, or does it leave focus with Thetis?

73,

Scott


Hi Scott,

I've edited my scripts and now they will return focus to the previous window after x miliseconds
Last edited by ea3aqr on Fri May 20, 2022 7:51 am, edited 1 time in total.
New call sign EA3CL
User avatar
w-u-2-o
Posts: 5525
Joined: Fri Mar 10, 2017 1:47 pm

Re: EDITED SCRIPTS! Activate your PTT with a mouse click or key stroke

Postby w-u-2-o » Fri May 20, 2022 10:15 am

Is that working a lot better and more naturally for you?

No need to shout, BTW. You might consider editing the ALL CAPS in your posts back to upper and lower case.

Just curious: have you considered adding a serial port PTT switch, or a MIDI controller, to achieve focus-less control of the radio? And there is also the Focusmaster feature built into Thetis that is expressly designed to maintain focus on the logger.
ea3aqr
Posts: 270
Joined: Mon Mar 04, 2019 10:50 pm
Location: BCN

Re: EDITED SCRIPTS! Activate your PTT with a mouse click or key stroke

Postby ea3aqr » Fri May 20, 2022 10:58 am

w-u-2-o wrote:Is that working a lot better and more naturally for you?

No need to shout, BTW. You might consider editing the ALL CAPS in your posts back to upper and lower case.

Just curious: have you considered adding a serial port PTT switch, or a MIDI controller, to achieve focus-less control of the radio? And there is also the Focusmaster feature built into Thetis that is expressly designed to maintain focus on the logger.



Now it runs perfect for me, I can open a browser or an app on top of Thetis and PTT in a QSO without any issue just clicking one button.

I was considering a Stream deck, but right now I don't want any thing else on top of my desktop.
Using AutoHotKey you can also run external programs from the script, so it is possible to launch Ernst's app to send cat commands.
New call sign EA3CL
User avatar
w-u-2-o
Posts: 5525
Joined: Fri Mar 10, 2017 1:47 pm

Re: EDITED SCRIPTS! Activate your PTT with a mouse click or key stroke

Postby w-u-2-o » Fri May 20, 2022 11:25 am

In addition to Ernst's fine work, you can also use ncat.
ea3aqr
Posts: 270
Joined: Mon Mar 04, 2019 10:50 pm
Location: BCN

Re: EDITED SCRIPTS! Activate your PTT with a mouse click or key stroke

Postby ea3aqr » Fri May 20, 2022 2:03 pm

Yes I know, I was playing with ncat just before Ernst released his tool.

My idea was toggle PTT using just one CAT command, but unfortunately I didn't found a command to do that.
And there was another problem... when PTT is activated via a ZZTX1 command, pressing "space" or clicking on "mox" doesn't do anything and you must send ZZTX0 to switch off PTT.

I know my solution is not "nice" but it works great for my purposes, specialy the mouse's one.
Last edited by ea3aqr on Fri May 20, 2022 2:37 pm, edited 1 time in total.
New call sign EA3CL
User avatar
w-u-2-o
Posts: 5525
Joined: Fri Mar 10, 2017 1:47 pm

Re: EDITED SCRIPTS! Activate your PTT with a mouse click or key stroke

Postby w-u-2-o » Fri May 20, 2022 2:30 pm

ea3aqr wrote:Yes I know, I was playing with ncat just before Ernst released his tool.

My idea was togle PTT using just one CAT command, but unfortunately I didn't found a command to do that.
Yes, that's typical of the entire command structure. Two different commands for enable and disable of any function. Luckily most of the extant macro software allows for the definition of "toggle" button actions with different commands allowed for each button state.
And there was another problem... when PTT is activated via a ZZTX1 command, pressing "space" or clicking on "mox" doesn't do anything and you must send ZZTX0 to switch off PTT.
I just tested this with both ZZTXx; and the Kenwood TX; and RX; commands and they all act like that. That seems to be a dangerous design approach that is a borderline bug. If control software misbehaves taking over manual control of the radio is problematic. Even cycling the "Power" button does not fix this. I'm going to put this on Richie's bug list.
I know my solution is not "nice" but it works great for my purposes, specialy the mouse's one.
It's absolutely "nice". It's no different than using any other macro or control surface method, all of which would require a toggle button of some sort, or a button that can transmit the TX command on button down and the RX command on button up.

I'm assuming that you are remote from the ANAN. If that's the case, adding serial port PTT can make things much more traditional. I have a footswitch wired across pins 6 and 7 (DTS and CTS on a standard PC DE9 serial connector) and use the built-in serial PTT facility of Thetis to work with this. It works great.
ea3aqr
Posts: 270
Joined: Mon Mar 04, 2019 10:50 pm
Location: BCN

Re: EDITED SCRIPTS! Activate your PTT with a mouse click or key stroke

Postby ea3aqr » Fri May 20, 2022 2:49 pm

w-u-2-o wrote:
ea3aqr wrote:Yes I know, I was playing with ncat just before Ernst released his tool.

My idea was togle PTT using just one CAT command, but unfortunately I didn't found a command to do that.
Yes, that's typical of the entire command structure. Two different commands for enable and disable of any function. Luckily most of the extant macro software allows for the definition of "toggle" button actions with different commands allowed for each button state.
And there was another problem... when PTT is activated via a ZZTX1 command, pressing "space" or clicking on "mox" doesn't do anything and you must send ZZTX0 to switch off PTT.
I just tested this with both ZZTXx; and the Kenwood TX; and RX; commands and they all act like that. That seems to be a dangerous design approach that is a borderline bug. If control software misbehaves taking over manual control of the radio is problematic. Even cycling the "Power" button does not fix this. I'm going to put this on Richie's bug list.
I know my solution is not "nice" but it works great for my purposes, specialy the mouse's one.
It's absolutely "nice". It's no different than using any other macro or control surface method, all of which would require a toggle button of some sort, or a button that can transmit the TX command on button down and the RX command on button up.

I'm assuming that you are remote from the ANAN. If that's the case, adding serial port PTT can make things much more traditional. I have a footswitch wired across pins 6 and 7 (DTS and CTS on a standard PC DE9 serial connector) and use the built-in serial PTT facility of Thetis to work with this. It works great.


Yes, TX CAT command could be very dangerous. Will be very nice if Richie can solve it!

And yes, you are right , I always use my radio "remotely", in my main QTH my shack is 20m away from my operating position. I also use very often my setup remotely from my mountain QTH that is about 200 km away from Barcelona city.
New call sign EA3CL

Return to “Macro & MIDI Controller Software, Hardware & Scripts”