lanux128, many thanks for the script! I'm having a bit of trouble with it though. As I'm using an Apple keyboard, there isn't a Win key. So I changed WIN+D to ALT+V. After that I was able to have one successful instance, but after that it wouldn't do it, even when I reload the script.
This makes me wonder if some bits of this script interfere with some other bits in my file. I don't know anything about AutoHotkey, but for example I already have this elsewhere in the file:
#Persistent ; Keep the script running until the user exits it.
#SingleInstance force
#MaxHotkeysPerInterval 200
So I'm wondering if that somehow clashes with your
#Persistent
#SingleInstance, Force
#NoEnv
I've got loads of other scripts in the file (even for remapping my Apple keyboard's keys).
@dr_andus: i cannot replicate the problem you face. i too run several AHK scripts (5 raw, 4 compiled) with a couple of clipboard extenders but the script i posted had no problems.
what happens if you copy-paste my script in to the Alt+W one? do you get a tray balloon like in the image below?
Spoiler
[ You are not allowed to view attachments ]
at this point, i suspect it has something to do with Win7's UAC which suppresses the script silently, instead of elevating the process.
i wonder if someone could try the script and post some feedback. @rjbull, do you fancy? :)
Thanks for all your help. I have UAC switched off. I've never seen that tray balloon pop up, but then I only managed to execute the script twice so far, and after both instances things got messed up.
I'm starting to think that the problem may have to do with some conflict with my Apple keyboard remapping. For example, I get different behaviour with clipboard related shortcuts depending on the types of shortcut keys I use. Also, when I tried to set up a hotkey for the ArsClip macro and hit Command, which is mapped as Win, it showed up as Win+CTRL. So I suspect a lot more is happening when I press certain keys than I'm able to see.
Anyway, here is my keyboard remapping script, in case anyone might be able to spot the culprit in there:
;---------------------------------
; Apple Keyboard remapping |
;---------------------------------
; Function Keys
+F3::Send {PrintScreen}
+F7:
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{LEFT} ; < previous
return
+F8::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, {SPACE} ; play/pause toggle
return
+F9::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{RIGHT} ; > next
return
+F10::Send {Volume_Mute}
+F11::Send {Volume_Down 3}
+F12::Send {Volume_Up}
#Left::SendInput {Home}
#Right::SendInput {End}
#+Left::sendInput +{Home}
#+Right::SendInput +{End}
!Left::SendInput ^{Left}
!Right::SendInput ^{Right}
!+Left::SendInput ^+{Left}
!+Right::SendInput ^+{Right}
^Backspace::SendInput {Del}
; copy, paste, save, select all etc
#c::^c
#x::^x
#v::^v
#s::^s
#a::^a
#z::^z
#b::^b
#i::^i
; Keyboard Characters
^3::Send {Raw}#
^2::Send {Raw}@
^'::Send {Raw}"
I also have this at the top of my main AutoHotkey script (I don't know what it does. I inherited it from someone):
SetTimer,UPDATEDSCRIPT,1000
UPDATEDSCRIPT:
FileGetAttrib,attribs,%A_ScriptFullPath%
IfInString,attribs,A
{
FileSetAttrib,-A,%A_ScriptFullPath%
SplashTextOn,,,Updated script,
Sleep,500
Reload
}
return
#Persistent ; Keep the script running until the user exits it.
#SingleInstance force
#MaxHotkeysPerInterval 200
In the meantime a kind soul who had seen the above had emailed me a script that does work within my particular setup, so my problem is solved. Thank you very much for all your help.
Here is the script, in case anyone else runs into this problem:
;----------------------------------------------
; CTRL+SHIFT+Z Replace spaces with underscores |
;----------------------------------------------
^+z::
clipboard=
Send, ^x
StringReplace, clipboard, clipboard, %A_Space%, _, All
Send, ^v
Return