AutoHotkey: how to change key behaviour when specific app is in focus - windows

I want to additionally send CTRL+RIGHT when I press RIGHT in case the Windows Media Player is currently in focus. What I achieved so far is that it works in case the WMP is running. How can I change the script such that it only reacts when the WMP window is currently in focus?
SetTimer, KeepRunning
return
KeepRunning:
ifWinActive, "Windows Media Player"
{
Right::Send ^{Right}{Right}
}
return
PS: I'm a total newbie regarding AutoHotkey, so any other code suggestions are welcomed :)

Have a look at #If to create context-sensitive hotkeys and hotstrings.
#Persistent
#If winactive("Windows Media Player")
Right::Send ^{Right}{Right}
#If

Related

Is it possible to program a custom dialog/pop-up for Alt+Tab switcher for Win 10?

I saw this post by Raymond Chen: https://stackoverflow.com/a/12865402/257299
The title says it all: Is it possible to program a custom dialog/pop-up for Alt+Tab switcher on Win 10?
Example: Can I trap EVENT_SYSTEM_SWITCHSTART, then show my custom Alt+Tab dialog with highest Z-Order? To be clear, I know this could be a security issue. Please assume the user local admin access.
Why? I want to program a replacement for the Win 10 "classic" Alt+Tab dialog that allows me to use the arrow keys. On Win 7, it was possible to do a key sequence like this: Alt+Tab (hold), the dialog would pop-up, then arrow keys would allow you to move left/right/up/down. After release Alt+Tab, the window focus would change. Very convenient! For me, the default Win 10 Alt+Tab dialog is awful, but the "classic" mode only needs a minor tweak.
Finally, I have Google'd like crazy before I asked this question. I cannot find anything.

Keep chrome open while a game is on fullscreen

Maybe this question doesn't belong here but I didn't know where else to ask. Is it possible to have chrome open and overlap another fullscreen game. For example I am on gta 5 and at the right top corner there is a chrome tab pinned there. Is this possible ?
Here is an edited photo of what I am trying to achieve. Link
This looks like something that AutoHotkey can do.
Try this script to toggle the AlwaysOnTop state of your chrome window before fullscreening your app:
;Alt+T = Toggle AlwaysOnTop state of the active window
!t::WinSet, AlwaysOnTop, Toggle, A
Source from the AHK forums
If you want to change Alt+T (!t) to be a different hotkey, take a look at the Hotkey section in the AHK documentation.

OSX Photos video play/pause Applescript shortcut

There is currently no keyboard shortcut to play videos in the new Mac Photos application.https://discussions.apple.com/thread/6996731?start=0&tstart=0
Rather than be frustrated in manually clicking the "play" button hundreds of times, I would like to run an Applescript to play/pause with a keyboard shortcut. I tried with no success:
tell application "photos"
"play" video
end tell
Any help advice on this would be appreciated.
Thanks
Just to update Paul's response, in Photos 2.0 (3150.4.120), you need to hit TAB twice, then spacebar will start playback. Similarly you need to hit TAB twice once you are done playing it, and then (and only then) spacebar will take you back to the grid view of your thumbnails.
If you do not mind a slightly time-consuming workaround, you can enslave Automator to create a Service that will subsequently respond to a keyboard shortcut. You can find the instructions here.
Since your goal is to use the keyboard, there's a better option for you. After selecting a video with cursor keys or mouse, press space to maximize the video, and then press TAB. Then space will start the video playing, left and right arrows will move frame-by-frame. Hitting TAB again will allow the space bar to return the video to its normal size.
Apparently this changes the focus to the pane with the movie so that space can start it, or perhaps it changes focus to the movie controls? IMHO, whatever it does, it's not very intuitive and badly needs to documented and preferably fixed.
More info at:
https://discussions.apple.com/thread/6996731?start=0&
2020 / Photos 6.0:
You can now toggle playback with Option + Space
or do it manually via "Image" -> "Start Playback".
Autoplay Script
repeat while application "Photos" is running
delay 1
try
tell application "System Events"
tell process "Photos"
click menu item "Start Playback" of menu "Image" of menu bar 1
end tell
end tell
end try
end repeat
Save it as autoplay.scpt and run it with osascript autoplay.scpt.
The script exits when you close the Photos application.

Bind Win7 Hotkeys to Chrome/FF javascript (Greasemonkey, native fns?)

I want to control a streaming music website with global hotkeys, so I can use the site's player controls (play/pause/next/etc) while another application has focus. I can use Greasemonkey to do this on the site when the browser has focus. What I can't figure out is a bridge between OS-level hotkeys and Greasemonkey.
Any suggestions?
Edit 2011-02-04:
New method: https://gist.github.com/cc9cf651f341cc938852.
The window switching was becoming a hassle and would glitch out occasionally, so I've added MozRepl to the stack (https://github.com/bard/mozrepl). Same idea, just targets a terminal with a Mozrepl instance, which controls Firefox.
Edit 2011-02-01:
AutoHotKey works well here. I put up a gist at https://gist.github.com/805417 for anyone else whom this might help.
Greasemonkey cannot do this.
I doubt that a Firefox or Chrome extension could do this.
A C, Python, etc. program probably could do it -- maybe coupled with an extension...
I found a bridge: AutoHotKey
This script I whipped up will look for a window with "Hype Machine" anywhere in the title. If successful, it will map ctrl+shift+[e|q|...] to functions that activate the Hype Machine window, send a certain keystroke command then alt+tab, which gets us back to our original window.
#SingleInstance force
SetTitleMatchMode 2 ; Anywhere in title
SetTitleMatchMode Fast
SendMode Input
#IfWinExist Hype Machine
{
^+d::
WinActivate
return
^+e::
WinActivate
WinWaitActive
Send n !{Tab}
return
^+q::
WinActivate
WinWaitActive
Send p !{Tab}
return
}

How to assign alt + f1 key to an opened Windows application

I usually have more then 10 opened application windows. When I write code I need to switch fast between a browser, an IDE and terminal windows. Alt + tab is too slow, too many windows to choose from.
Virtual desktop is a work around for me. On a first desktop I keep browser, on a second IDE, etc. So I am able to switch fast between my most important applications.
And the question. Is there an utility for Windows XP / Vista which allows to assign a keyboard shortcut like alt + f1 .. f10 to an opened application window?
UPDATE: All programs I've found allow to define a shortcut to an application. E.g. they will open new instance of Firefox instead of switch to an opened one. Closest to what I need is Switcher. It displays big thumbnails of all open windows with assigned numbers to press.
Autohotkey I've found to be very powerful. Here is a part of my test script.
SetTitleMatchMode, 2
#z::Run http://stackoverflow.com/
^!n::
IfWinExist Notepad
WinActivate
else
Run Notepad
return
!F1::
IfWinExist Firefox
WinActivate
else
Run Firefox
return
!F2::
IfWinExist Commander
WinActivate
return
!F3::
IfWinExist Carbide
WinActivate
return
Just use Win32 api KBS.
There's a fair number of shareware apps for keyboard shortcuts out there. Take a look at Stardock's Keyboard Launchpad, it's supposed to be able to do stuff like that.

Resources