Help! AutoHotKey script to swap Ctrl+V and Ctrl+Shift+V

User avatar
krastev
Posts: 347
Joined: Fri Feb 05, 2016 5:21 am
Platform: Windows
Contact:

Fri Sep 20, 2019 3:53 pm Post

Since Scrivener b23 does not allow the user to swap the shortcuts for Paste and Paste and Match the Style, I was advised to use AutoHotKey or something similar swap the functions for now. For more info about the problem see this thread.

I installed AutoHotKey, thinking it would be easy to use, but for me, it's overwhelming. I don't even know where to begin. What I want the script to do is to swap Ctrl+V and Ctrl+Shift+V but only in Scrivener latest beta.

I'll be grateful if somebody can share a script that can do that, or point me to a place where I can find one.

Thank you,
M
Krastev
Windows 10 Home 64-bit
Scrivener for Windows Version 1.9.13.0
Testing Scrivener Beta for Windows

User avatar
jasonb
Posts: 7
Joined: Sun Dec 24, 2017 11:23 pm
Platform: Windows

Fri Sep 20, 2019 5:40 pm Post

Something like the following should work:

Code: Select all

#IfWinActive, ahk_exe scrivener.exe
^v::^+v
#IfWinActive, ahk_exe scrivener.exe
^+v::^v


I don't like the inelegance of the multiple entries, but when I tried a block of code with send commands, it resulted in an infinite loop of key presses.

Note that I tested the above by swapping the A and B keys in Notepad and it worked without a problem. My beta version of Scrivener expired on the 15th, so I can't actually test this on a working version of the application myself. (Oddly, nobody else has complained about this. Maybe the initial version of the beta I installed had an earlier expiry date for some reason.)

User avatar
devinganger
Posts: 1565
Joined: Sat Nov 06, 2010 1:55 pm
Platform: Mac, Win + iOS
Location: Monroe, WA 98272 (CN97au)
Contact:

Fri Sep 20, 2019 5:44 pm Post

jasonb wrote:My beta version of Scrivener expired on the 15th, so I can't actually test this on a working version of the application myself. (Oddly, nobody else has complained about this. Maybe the initial version of the beta I installed had an earlier expiry date for some reason.)


Are you actually on beta 23?
--
Devin L. Ganger, WA7DLG
Not a L&L employee; opinions are those of my cat
Winner "Best in Class", 2018 My First Supervillain Photo Shoot

User avatar
jasonb
Posts: 7
Joined: Sun Dec 24, 2017 11:23 pm
Platform: Windows

Fri Sep 20, 2019 5:54 pm Post

devinganger wrote:Are you actually on beta 23?

I could have sworn I was. I always install the version on the site on the first of each month. But the version I had installed on the first of September said "This Scrivener for Windows Beta expired after September 15, 2019." So, I assumed it had been given a shorter expiry cycle for some reason.

The version of 23 I just installed now gives me the more expected message of it expiring after "September 30."

JJ
JJSlote
Posts: 526
Joined: Tue Oct 26, 2010 5:44 pm
Platform: Windows
Location: NY, USA              Docs in Binder: 10,500+

Fri Sep 20, 2019 5:59 pm Post

jasonb wrote:I don't like the inelegance of the multiple entries, but when I tried a block of code with send commands, it resulted in an infinite loop of key presses.

Found this in AutoHotKey's Help, under #MaxHotkeysPerInterval .
As an oversimplified example, the hotkey ^c::Send ^c would produce an infinite loop of keystrokes. To avoid this, add the $ prefix to the hotkey definition (e.g. $^c::) so that the hotkey cannot be triggered by the Send command.

Rgds - Jerome

rw
rwfranz
Posts: 681
Joined: Thu May 28, 2015 9:41 pm
Platform: Windows

Fri Sep 20, 2019 8:22 pm Post

JJSlote wrote:
jasonb wrote:I don't like the inelegance of the multiple entries, but when I tried a block of code with send commands, it resulted in an infinite loop of key presses.

Found this in AutoHotKey's Help, under #MaxHotkeysPerInterval .
As an oversimplified example, the hotkey ^c::Send ^c would produce an infinite loop of keystrokes. To avoid this, add the $ prefix to the hotkey definition (e.g. $^c::) so that the hotkey cannot be triggered by the Send command.

Rgds - Jerome

Tried that -- caused another issue in Scrivener. Shouldn't, I know, but it did. I'm working with double-spaced text, and when I used ^V to produce ^+V to paste and match style, I got single-spaced text in a double-spaced set of paragraphs. Not sure why, exactly.

However,

Code: Select all

#IfWinActive, ahk_exe scrivener.exe
^v::Send ^+v
#IfWinActive, ahk_exe scrivener.exe
^+v::Send ^v


seems to work just fine on my machine.

User avatar
krastev
Posts: 347
Joined: Fri Feb 05, 2016 5:21 am
Platform: Windows
Contact:

Sat Sep 21, 2019 1:01 pm Post

Thank you all. The code:

rwfranz wrote:

Code: Select all

#IfWinActive, ahk_exe scrivener.exe
^v::Send ^+v
#IfWinActive, ahk_exe scrivener.exe
^+v::Send ^v




does exactly what I needed. I'm grateful for your help.

Regards,
M
Krastev
Windows 10 Home 64-bit
Scrivener for Windows Version 1.9.13.0
Testing Scrivener Beta for Windows