Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

OSX style command keys in Windows


  • Please log in to reply
4 replies to this topic
johnwalkr
  • Members
  • 1 posts
  • Last active: Nov 25 2010 12:56 PM
  • Joined: 25 Nov 2010
Thought this might be useful to some people. I posted the code to my blog too.

Basically I want to get all of my "command" shortcuts to work in OSX. I started by just remapping the command key (it's the windows key in windows) to the more useful control key. Then I went farther:

-kept win-L, win-tab and win-D because I use them
-remapped all other command-X keys to control-X
-except remapped command-q to alt-F4
-except remapped command-w to control-F4
-changed behavior of alt-arrow keys to match OSX text navigation
-changed behavior of command-arrow keys to match OSX text navigation
-changed behavior of alt-del and command/alt-backspace to match OSX for deleting whole words and lines

I hope this is useful for others, I've been enjoying boot camp a lot more since making this.



;Autohotkey script
;John Walker, 2010-11-25
;walkerj@gmail.com
;http://www.inertreactants.com
;Feel free to reuse, edit and redistribute
;Key remaps for Apple users using boot camp
;(with an Apple notebook or Keyboard)

;following section remaps alt-delete keys to mimic OSX
;command-delete deletes whole line
#BS::Send {LShift down}{Home}{LShift Up}{Del}

;alt-function-delete deletes next word
!Delete::Send {LShift down}{LCtrl down}{Right}{LShift Up}{Lctrl up}{Del}

;alt-delete deletes previous word
!BS::Send {LShift down}{LCtrl down}{Left}{LShift Up}{Lctrl up}{Del}

;following section mimics command-q and command-w
;behaviour to close windows
;note these had to be disabled below for the
;command to ctrl key remaps
#w::^F4
#q::!F4

;following section remaps alt-arrow and command-arrow
;keys to mimic OSX behaviour
#Up::Send {Lctrl down}{Home}{Lctrl up}
#Down::Send {Lctrl down}{End}{Lctrl up}
#Left::Send {Home}
#Right::Send {End}
!Up::Send {Home}
!Down::Send {End}
!Left::^Left
!Right::^Right

;following section remaps command key to control key
;affects all number and letter keys
;note that some keys, like winkey-l and winkey-d
;need to be remapped a differeny way
;otherwise autohotkey will not take over 
#a::^a
#b::^b
#c::^c
#d::^d 
#e::^e
;following won't remap using the normal method
#f::Send {LCtrl down}{f}{LCtrl up}
#g::^g
#h::^h
#i::^i
#j::^j
#k::^k
;#l::Send {LCtrl down}{l}{LCtrl up} ;disabled, I like winkey-L
#m::^m
#n::^n
#o::^o
#p::^p
;#q::^q ;disabled --remapped to alt-F4 instead
#r::^r
#s::^s
#t::^t
#u::^u
#v::^v
;#w::^w ;disabled --remapped to ctrl-F4 instead
#x::^x
#y::^y
#z::^z
#1::^1
#2::^2
#3::^3
#4::^4
#5::^5
#6::^6
#7::^7
#8::^8
#9::^9
#0::^0


oldmankit
  • Members
  • 2 posts
  • Last active: Feb 25 2014 07:09 AM
  • Joined: 25 Feb 2014

Thanks for posting this. I certainly found it helpful for me. I'm using a Logitech K810 keyboard for my Windows laptop and my iPad, and swapping shortcut keys between the two was slowing me down a lot.  I've taken your work and modified it slightly, notably keeping the default Windows+Arrow Keys which have significantly functionality in Windows 7 onwards.

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; OSX style keys;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Command-backspace deletes whole line
#BS::Send {LShift down}{Home}{LShift Up}{Del}

;alt-delete deletes previous word
!BS::Send {LShift down}{LCtrl down}{Left}{LShift Up}{Lctrl up}{Del}

; Navigation of smaller chunks (skip word)
<!Left::Send {ctrl down}{Left}{ctrl up}
<!Right::Send {ctrl down}{Right}{ctrl up}


; Navigation using of bigger chunks (Skip to start/end of line/paragraph/document)
^Left::Send {Home}
^Right::Send {End}
!Up::Send {ctrl down}{Up}{ctrl up}
!Down::Send {ctrl down}{Down}{ctrl up}
^Up::Send {Lctrl down}{Home}{Lctrl up}
^Down::Send {Lctrl down}{End}{Lctrl up}


; Selection (uses a combination of the above with shift)
<!+Left::Send {ctrl down}{shift down}{Left}{shift up}{ctrl up}
<!+Right::Send {ctrl down}{shift down}{Right}{shift up}{ctrl up}
^+Left::Send {shift down}{Home}}{shift up}
^+Right::Send {shift down}{End}}{shift up}
!+Up::Send {ctrl down}{shift down}{Up}}{shift up}{ctrl up}
!+Down::Send {ctrl down}{shift down}{Down}}{shift up}{ctrl up}
^+Up::Send {Lctrl down}{shift down}{Home}}{shift up}{Lctrl up}
^+Down::Send {Lctrl down}{shift down}{End}}{shift up}{Lctrl up}


;Closing windows and programs (using the Win Key)
#w::^F4
#q::!F4


;The following section replaces Ctrl+Key with  Win+Key
#a::^a
#b::^b
#c::^c
#d::^d 
#e::^e
;following won't remap using the normal method
#f::Send {LCtrl down}{f}{LCtrl up}
#g::^g
#h::^h
#i::^i
#j::^j
#k::^k
;#l::Send {LCtrl down}{l}{LCtrl up} ;disabled, I like winkey-L
#m::^m
#n::^n
#o::^o
#p::^p
;#q::^q ;disabled --remapped to alt-F4 instead
#r::^r
#s::^s
#t::^t
#u::^u
#v::^v
;#w::^w ;disabled --remapped to ctrl-F4 instead
#x::^x
#y::^y
#z::^z
#1::^1
#2::^2
#3::^3
#4::^4
#5::^5
#6::^6
#7::^7
#8::^8
#9::^9
#0::^0

 



SharjeelAhmed09
  • Members
  • 2 posts
  • Last active: Mar 28 2014 05:01 PM
  • Joined: 28 Mar 2014

i want to change the shortcut win + q to alt+space key! please help! 



skalpin
  • Members
  • 1 posts
  • Last active: Jun 19 2015 01:02 PM
  • Joined: 19 Jun 2015

Try !Space::send #q



bean_drew
  • New members
  • 2 posts
  • Last active: Nov 03 2015 02:29 AM
  • Joined: 14 Sep 2015

Thanks to johnwalkr and oldmankit for working this up - I use Windows virtualized for work on my Macbook and switching between the different shortcut sets was getting very confusing.  I retooled things a bit to my liking, mostly by disabling the old shortcuts in Windows to force me to cut my reliance on them, and by adding in a few other specific shortcuts that I use frequently in Office.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WINDOSX                             ;
; MODIFIED AND REORGANIZED FORK FROM  ;
; ______________________, WITH THANKS ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;WIN-P cannot be remapped, but can be disabled.  WIN-L cannot be changed at all.
#p::return


; OSX "DELETE" MODIFIERS
#BS::Send {LShift down}{Home}{LShift Up}{Del}
!BS::Send {LCtrl down}{BS}{LCtrl up}


; OSX NAVIGATION AND SELECTION WITH CMD
#Up::Send {ctrl down}{Home}{ctrl up}
#Down::Send {ctrl down}{End}{ctrl up}
#+Up::Send {ctrl down}{shift down}{Home}{shift up}{ctrl up}
#+Down::Send {ctrl down}{shift down}{End}{shift up}{ctrl up}
#Left::Home
#Right::End
#+Left::Send {shift down}{Home}{shift up}
#+Right::Send {shift down}{End}{shift up}


; OSX NAVIGATION AND SELECTION WITH ALT
!Left::Send {ctrl down}{Left}{ctrl up}
!Right::Send {ctrl down}{Right}{ctrl up}
!+Left::Send {ctrl down}{shift down}{Left}{shift up}{ctrl up}
!+Right::Send {ctrl down}{shift down}{Right}{shift up}{ctrl up}


; DISABLES UNMODIFIED WIN-KEY IN FAVOR OF OSX SPOTLIGHT-LIKE BEHAVIOR
LWin::return
RWin::return
#Space::LWin


; REPLACES ALT-TAB APPLICATION SWITCHING WITH OSX CMD-TAB
<#Tab::AltTab
!Tab::return


; REMAPS CTRL-LEFT-CLICK TO CMD AND REPLICATES OSX CTRL-CLICK RIGHT-CLICK
LWIN & LBUTTON::send {ctrl down}{LButton}{ctrl up}
RWIN & LBUTTON::send {ctrl down}{LButton}{ctrl up}
CTRL & LBUTTON::send {RButton}


; SIMULATE OSX CLOSE WINDOW AND QUIT APPLICATION BEHAVIOR
#w::^F4
^w::return
;The following will be picked off by OSX, if employed in a virtualized environment.
;It should however work to mimic OSX functionality if employed in native Win.
;#q::!F4


; SUPPORT FOR BROWSER BEHAVIOR
#+n::^+n


; THIS HOTKEY PRESERVES MS WORD INDENT FUNCTIONALITY FROM OSX
^+Left::Send {shift down}{alt down}{Left}{shift up}{alt up}
^+Right::Send {shift down}{alt down}{Right}{shift up}{alt up}


; PRESERVES ADDITIONAL MS WORD FORMATTING FUNCTIONALITY FROM OSX
#+=::^+=
#=::^=


; SWAP CTRL-ALPHANUMERIC TO OSX CMD-ALPHANUMERIC
; SEE ABOVE RE: CMD-L, P, Q
#a::^a
#b::^b
#c::^c
#d::^d 
#e::^e
#f::^f
#g::^g
#h::^h
#i::^i
#j::^j
#k::^k
#m::^m
#n::^n
#o::^o
#r::^r
#s::^s
#t::^t
#u::^u
#v::^v
#x::^x
#y::^y
#z::^z
#1::^1
#2::^2
#3::^3
#4::^4
#5::^5
#6::^6
#7::^7
#8::^8
#9::^9
#0::^0


; DISABLE CTRL-KEYS REPLACED ABOVE
^a::return
^b::return
^c::return
^d::return
^e::return
^f::return
^g::return
^h::return
^i::return
^j::return
^k::return
^m::return
^n::return
^o::return
^r::return
^s::return
^t::return
^u::return
^v::return
^x::return
^y::return
^z::return
^1::return
^2::return
^3::return
^4::return
^5::return
^6::return
^7::return
^8::return
^9::return
^0::return
^Up::return
^Down::return
^Left::return
^Right::return
^+Up::return
^+Down::return
<^BS::return
^=::return
^+=::return

That's all well and good, but I've spent some time trying to figure out unsuccessfully how to get AHK to make Windows mimic OSX's click-drag-key-drop behavior.  That is to say, when you click and drag a file and want to change the default behavior to for instance copy instead of move a file, or vice versa you use different keys in each environment, and I was hoping to code AHK to unify that behavior.

 

At a basic level, it would look something like:

!::^
#::+
+::! (the "make shortcut" option has no match in OSX, but I couldn't think of a reason to exclude it)
but only when the LButton is depressed.  In one iteration of my attempts I was able to trigger {key down} commands when the hotkey accompanies the LButton down, but I didn't work out yet how to trigger the key back up when either a) the key is released; or B) the LButton is released.  (I don't include that code here because I kept deleting my failed attempts to try new ones until I eventually gave up).  I'll keep plugging away it if I find some time but I wondered if anyone else here had any ideas about how to get AHK to make the changes.