Keyboard shortcut sequences (ala Emacs)
-
- Posts: 91
- Joined: 19 Mar 2008 18:15
Keyboard shortcut sequences (ala Emacs)
Hi all,
I was wondering if it was possible to define keyboard shortcut sequences, like Emacs (and other one-true-editor-wanabee) does Eg. Ctrl-x Ctrl-f.
I guess this means composite keymaps and all that--so the question is, can it be done? If no, any chance to get it sometime later?
Cheers,
I was wondering if it was possible to define keyboard shortcut sequences, like Emacs (and other one-true-editor-wanabee) does Eg. Ctrl-x Ctrl-f.
I guess this means composite keymaps and all that--so the question is, can it be done? If no, any chance to get it sometime later?
Cheers,
Re: Keyboard shortcut sequences (ala Emacs)
Currently no, but I'm really glad that I'm no longer the only "fool" that wants this.
Today the best you can do is to use UDC to execute a script, which displays a menu, and then use access keys in the captions as the second part of the sequence.
Today the best you can do is to use UDC to execute a script, which displays a menu, and then use access keys in the captions as the second part of the sequence.
Re: Keyboard shortcut sequences (ala Emacs)
You could write an .ahk script, that sends the necessary commands to XY. Would work, as long as all the functions are accessible via script commands...
One of my scripts helped you out? Please donate via Paypal
-
- Posts: 91
- Joined: 19 Mar 2008 18:15
Re: Keyboard shortcut sequences (ala Emacs)
Yeah, but this means global hooks to capture the key events. I know you can filter by application class and likes, but this messes up with some apps nonetheless.
Re: Keyboard shortcut sequences (ala Emacs)
This doesn't mess with anything apart from XYplorer^^
You either restrict the keypresses to ahk_id or ahk_class (sufficient, if you don't have any other apps that use ThunderRT6FormDC)...
You either restrict the keypresses to ahk_id or ahk_class (sufficient, if you don't have any other apps that use ThunderRT6FormDC)...
One of my scripts helped you out? Please donate via Paypal
-
- Posts: 91
- Joined: 19 Mar 2008 18:15
Re: Keyboard shortcut sequences (ala Emacs)
I know this works in theory, but in practice the AHK hooks can break some applications that watch for the same keystrokes at a low level.
I already have AHK on my machine btw, and I keep it loaded in startup scripts because it works pretty well, but it is often not totally seamless.
I appreciate the suggestion anyway!
I already have AHK on my machine btw, and I keep it loaded in startup scripts because it works pretty well, but it is often not totally seamless.
I appreciate the suggestion anyway!
-
- Posts: 1416
- Joined: 04 Nov 2008 05:35
- Location: Hanoi, Vietnam
Re: Keyboard shortcut sequences (ala Emacs)
in AHK:I cannot imagine how it can messup with other window.
P.S: If you want to send/receive message to/from XYplorer, then try my AHK script here:http://www.xyplorer.com/xyfc/viewtopic. ... 233#p82412
Code: Select all
SetTitleMatchMode, 2
ControlSend,, {Ctrl}f, XYplorer ahk_class ThunderRT6FormDC
P.S: If you want to send/receive message to/from XYplorer, then try my AHK script here:http://www.xyplorer.com/xyfc/viewtopic. ... 233#p82412
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
Re: Keyboard shortcut sequences (ala Emacs)
Code: Select all
#SingleInstance force
SendMode Input
GroupAdd, XYplorerGroup, ahk_class ThunderRT6FormDC ; XYplorerGroup
alphabet := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Loop, parse, alphabet ;
Transform, Ctrl%A_LoopField%, Chr, %A_Index%
return
#IfWinActive, ahk_group XYplorerGroup
^x:: ; Ctrl + X
Input, x, L1 M
if x = %CtrlF%
{
xyscript =
( LTrim Join
::focus "PI";
tab("new");
)
CallXYplorerScript(xyscript)
return
}
else if x = %CtrlH%
CallXYplorerScript("::#156")
return
#IfWinActive
CallXYplorerScript(script)
{
hwnd := WinExist("ahk_class ThunderRT6FormDC")
if (hwnd)
WinActivate, ahk_class ThunderRT6FormDC
size := StrLen(script)
if !(A_IsUnicode) {
VarSetCapacity(data, size * 2, 0)
StrPut(script, &data, "UTF-16")
} else {
data := script
}
VarSetCapacity(COPYDATA, A_PtrSize * 3, 0)
NumPut(4194305, COPYDATA, 0, "Ptr")
NumPut(Size * 2, COPYDATA, A_PtrSize, "UInt")
NumPut(&Data, COPYDATA, A_PtrSize * 2, "Ptr")
result := DllCall("User32.dll\SendMessageW", "Ptr", hwnd, "UInt", 74, "Ptr", 0, "Ptr", ©DATA, "Ptr")
return
}
CallXYplorerScript("::#156")
or whole scripts via:
CallXYplorerScript(<name of variable that contains a script>)
Example included.
One of my scripts helped you out? Please donate via Paypal
-
- Posts: 91
- Joined: 19 Mar 2008 18:15
Re: Keyboard shortcut sequences (ala Emacs)
Interesting, thank you for the effort!
How would you make a key binding for "copy current file selection to folder A:/b/c" ?
The mix of VB-ish code and win32 API makes my head reel :/
How would you make a key binding for "copy current file selection to folder A:/b/c" ?
The mix of VB-ish code and win32 API makes my head reel :/
Re: Keyboard shortcut sequences (ala Emacs)
Hi highend,
I was testing out your code above and I finally had success inputting a full working script. I read up on the input and transform command after seeing your code. This small modification worked for me. I may modify it slightly to open XY is it's not already as I did with earlier with code from binocular222. Though it's usually open, but maybe not "active".I noticed you used the variable "xyscript" in some places and "scripts" in other places so I made them all the same, "scripts". I also noticed it wouldn't work if I quoted the script. It worked fine unquoted.
Edit: I think what confused me initially was the use of "Ctrl" in the variable (e.g., CtrlF). Until I really understood what was happening with the transform and input commands, I thought it had something to do with the use of the control key. "Ctrl" could have been "pizza" and it would still work. The "x" used in the "input" variable also confused me coming right after hotkey assignment of "^x". The "x" could have been "pasta" and then the line below becomes:Nice touch on the use of transform and input. It works great. Thanks, I hope all is well.
Ken
I was testing out your code above and I finally had success inputting a full working script. I read up on the input and transform command after seeing your code. This small modification worked for me. I may modify it slightly to open XY is it's not already as I did with earlier with code from binocular222. Though it's usually open, but maybe not "active".
Code: Select all
Input, x, L1 M
if x = %CtrlF%
{
script = D:\Tools\Xyplorer\Scripts\ThumbnailViewer_exec.xys
CallXYplorerScript(script)
return
}
else if x = %CtrlH%
CallXYplorerScript("::#156")
Edit: I think what confused me initially was the use of "Ctrl" in the variable (e.g., CtrlF). Until I really understood what was happening with the transform and input commands, I thought it had something to do with the use of the control key. "Ctrl" could have been "pizza" and it would still work. The "x" used in the "input" variable also confused me coming right after hotkey assignment of "^x". The "x" could have been "pasta" and then the line below becomes:
Code: Select all
if pasta = %pizzaF%
Ken
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
Re: Keyboard shortcut sequences (ala Emacs)
Just use regular XY scripting...Reve_Etrange wrote:Interesting, thank you for the effort!
How would you make a key binding for "copy current file selection to folder A:/b/c" ?
The mix of VB-ish code and win32 API makes my head reel :/
E.g.:
Code: Select all
xyscript =
( LTrim Join
::copyto "D:\b\c", , , 2;
)
One of my scripts helped you out? Please donate via Paypal
Re: Keyboard shortcut sequences (ala Emacs)
Hi Ken,
Just add an else statement in the function.
Possible, but I wouldn't recommend this.
You would have to use:
IfWinExist and you should make sure that e.g. emacs isn't the active window *g*
Regards,
Highend
You mean you'll start XY?klownboy wrote:I may modify it slightly to open XY is it's not already
Just add an else statement in the function.
Code: Select all
if (hwnd)
WinActivate, ahk_class ThunderRT6FormDC
else
RunWait, <path to your xyplorer.exe>
You mean these hotkeys should be global because XY doesn't have to be the active window?Though it's usually open, but maybe not "active".
Possible, but I wouldn't recommend this.
You would have to use:
IfWinExist and you should make sure that e.g. emacs isn't the active window *g*
Sure, can be done that way because "scripts" is local in the context of the function but I found it more confusing if I use the same variable name in the autorun context and in the function parameter.I noticed you used the variable "xyscript" in some places and "scripts" in other places so I made them all the same, "scripts".
Ctrl is just the first part of the variable name. Ofc you can name it anything you like. "x" was just ... short Normally I wouldn't use single character variable names but the script is so short, it doesn't matter."Ctrl" could have been "pizza" and it would still work.
Regards,
Highend
One of my scripts helped you out? Please donate via Paypal
Re: Keyboard shortcut sequences (ala Emacs)
Hi highend,
Thanks for the explanations. I'm not going to modify the script to start XY if it's not already. As you alluded to, this script suits the purpose of providing an Emacs style method of performing shortcuts within XY. There are so many other ways, which I already have defined, for starting XY (if it's not already) and performing numerous tasks or running scripts, etc. I did learn some by "playing" with it (i.e., learning from it ) using different keystrokes, scripts, and setting up a message box to indicate the ASCII code indicated by Value1. I also attempted to use "numbers" (i.e., 123456789) in lieu of the alphabet in the transform loop, but I guess the "CHR" cmd for transform doesn't work for numbers (ASCII code equivalent character code for a numbers).
Thanks again,
Ken
Thanks for the explanations. I'm not going to modify the script to start XY if it's not already. As you alluded to, this script suits the purpose of providing an Emacs style method of performing shortcuts within XY. There are so many other ways, which I already have defined, for starting XY (if it's not already) and performing numerous tasks or running scripts, etc. I did learn some by "playing" with it (i.e., learning from it ) using different keystrokes, scripts, and setting up a message box to indicate the ASCII code indicated by Value1. I also attempted to use "numbers" (i.e., 123456789) in lieu of the alphabet in the transform loop, but I guess the "CHR" cmd for transform doesn't work for numbers (ASCII code equivalent character code for a numbers).
Thanks again,
Ken
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440