i have this code AutoHotkey Code:
#NoTrayIcon
If WinExist("Mozilla Thunderbird")
{
WinActivate, Mozilla Thunderbird
}
Else
{
Run "c:/Users/xah/Desktop/Mozilla Thunderbird.lnk"
WinActivate
}
Return
ExitApp
activated by a key.
but when run twice (sometimes pressed the key twice), it seems to deactivate the window and change mouse position.
how to fix that?
(this is a pain for me because i have auto window focus on. When mouse position changes to another location, that window pops up to front)
thanks.
someone at ahk forum answered it.
http://www.autohotkey.com/forum/post-413075.html#413075
basically, my script is actually running the Else clause everytime.
What i need is to add
SetTitleMatchMode, 2
in the beginning, so the title matches if it contains the string.
Related
I use chrome bookmarks a lot, and I also often have to send people screen snippets very often, however I don't want all my bookmarks on display (some are sorta private). I know I could add them to the Other Bookmarks folder, but would rather easy access. What I've been doing for a while is hitting the bookmark shortcut (CTRL+SHIFT+B), then the snipping tool (WIN+SHIFT+S), taking my screenshot and then putting the Bookmarks back (CTRL+SHIFT+B). Eventually I decided to bite the bullet and spend some time automating it, so that hitting CTRL+SHIFT+S would close the Bookmark Bar, and letting go of the mouse (after taking the clipping) would put it back. This is what I came up with:
~#+s:: Send, ^+B
KeyWait, LButton, D
Send, ^+B
return
Although the first half works (Bookmarks go away, snipping tools open) at no point does the bar return. I've tried many things including setting up a timer, and waiting for the space bar instead of the mouse button, which i'd only hit when ready. I have also tested, and manually pressing the keys immediately after letting go the mouse button did indeed re-open the Bookmarks.
Would anyone be able to explain why this is happening? I would really appreciate any help!
First problem is that you put the first command on the same line as the hotkey definition.
This will create a one liner hotkey and the rest of the code below wont run.
Second problem is that you're sending the input to show bookmarks again while the screenshotting window is active. You're going to want to wait until chrome is active again.
This works:
#IfWinActive, ahk_exe chrome.exe
~#+s::
SendInput, ^+b
Sleep, 2000
WinWaitActive, ahk_exe chrome.exe
SendInput, ^+b
return
#IfWinActive
A bit of sleep so the screenshot window has time to open, and also added in #IfWinActive, because I'd assume you only want that hotkey to be active while you're on chrome.
Also switched over to SendInput and made the b lower case. Having it as uppercase would send Shift+B (on most keyboard layouts).
I'd like to assign back and forward YouTube keyboard commands to my middle and right click mouse buttons respectively. Unfortunately, with HTML player it is not possible to differentiate the youtube video window from Firefox ahk class as I did before with flash player. I've tried MouseClick commands and simple reassigning keyboard commands to mouse but none of it worked. For some reason autohotkey couldn't be made to send no click commands to the HTML video window and I couldn't even reassign the basic functions of the mouse middle click for example, to make it work as a Left keyboard command.
Anyone has an idea how to make a working autohotkey script that would enable me to turn Left and Right keyboard commands into mouse Right and Middle button clicks?
Like this?
#If YouTubeHtml5Active()
RButton::Right
MButton::Left
#If
YouTubeHtml5Active() {
tmmBackup := A_TitleMatchMode
SetTitleMatchMode, RegEx
youtubeVideoAvtive := WinActive(".+ \- YouTube \- Mozilla Firefox")
SetTitleMatchMode, %tmmBackup%
If youtubeVideoAvtive
Return True
}
Assuming you run on Win10:
I've tried MouseClick commands and simple reassigning keyboard commands to mouse but none of it worked.
AutoHotkey in Windows 10 - Hotkeys not working in some applications Some programs need AutoHotkey to be ran in admin mode, otherwise hotkeys are not recognized.
I've found a simple script doing this on autohotkey forum http://www.autohotkey.com/board/topic/69720-controll-youtube-volume-with-mousewheel/, here it is, works like a charm:
SetTitleMatchMode 2
#IfWinActive YouTube
RButton::Send {Left}
MButton::Send {Right}
return
I have a very simple AutoHotkey.ahk file, where I remap Capslock to Esc and Esc to Capslock (swapping the keys):
Capslock::Esc
Esc::Capslock
However, this doesn't work in games like Battlefield 4 or League of Legends. It simply does not do anything.
However, I can press Reload This Script in AutoHotkey, and the remapping will start working in those games. It does however work in other games without the need to reload the script first.
I hope you can help me. I would really like this to just work, instead of manually reloading the script.
Try using the #IfWinActive directive so that those hotkeys only work in the programs you want - then you don't need to ever reload.
Check in the documentation for "Context-sensitive hotkeys" (under "hotkey" in the index). Here is an example from the documentation:
#IfWinActive, ahk_class Notepad ^a::MsgBox You pressed Ctrl-A while Notepad is active. Pressing Ctrl-A in any other window will pass the
Ctrl-A keystroke to that window.
#c::MsgBox You pressed Win-C while Notepad is active.
But I think I know why it begins to "not work". It may be that certain programs set those keys as hotkeys. Whenever you start those programs they set their own hotkeys and it overrides your script. You see, the hotkey combination belongs to whatever program sets it last. When you reload the script, it resets your script as having the authourity.
So if you want the script to never be overridden, and you don't want to manually reload it, find out what programs the combinations don't work in, and use ifwinactive to reload your script using autohotkey's reload command.
I am working with a Help file as a Word 2007 document. I need to update the screenshots as I go through, so I'm trying to get AHK to select the 'Change Picture' option from the right click drop down menu when I press my key combination. I've got the code, and it works perfectly... the first time I use it. After that, I only see the right click menu flash and disappear. I suspect that the script from Send {Down 4} on is not executing because I can just barely see the 'Cut' option highlighted, but the selected image is not cut from the document, indicating that the Send {Enter} is also not being executed.
I cannot find anyone else who seems to be having this problem. If I manually reload my script, it works fine again, but only the once. Then it's back to flashing the drop down and nothing else. Any help would be greatly appreciated. I'm trying to get this process down to as few clicks as possible, but it's getting to the point where I'm wasting more time trying to solve my macro problems than I would just doing it the slow awkward way.
My script as it is now:
^!z::
Send +{F10}
Send {Down 4}
Send {Enter}
return
For clarification's sake:
When I remove everything following Send +{F10} and then use my hotkey, I get the right click menu displayed and not flashed, but again, only the first time I use it. After that, the menu goes back to flashing on the screen once. To compare, actually pressing Shift and {F10} displays the right click menu, and it does not disappear on lift.
If I move all three Send commands into one line to get Send +{F10} {Down 4} {Enter} The script executes the 'Cut' option from the right click menu, then moves the cursor down 4 lines and then sends the {Enter} keystroke. This set of actions works after the first use of the script, unlike previous instances.
In my copy of Word, the control key causes a secondary 'Layout Options' menu to pop up if there is an image selected. While I'm not sure why it's working for you the first time but not subsequently, when I test this at my end it works if I change two things:
Use mouseclick, right instead of Send +{F10}
Change the shortcut modifier from shift-ctrl to Win, i.e. set it to #z
You can try sending the keyboard shortcut instead of down command
SetBatchLines, 1
SetKeyDelay , 100 ; in miliseconds, keep increasing until your pc can hadle it
!x:: ; your hotkey in my case alt + x which is similar to ctrl + x for cutting text
Send +{F10}
Send {t} ; use the cut keyboard shortcut, for word should be 't'. if for some weird reason isn't change it
Send {Enter}
return
I'm not sure if this is common or not but I cannot get my code to run in this type of window. It works in all of my other windows except for the one, ahk_class SWT_Window0, I want it to work in... go figure.
My code is:
RButton::
SendInput {Click 166,350}
return
Pretty simple just move the cursor and click. It works in google chrome wundow spy scite and various other windows but not with the correct window. Any help would be awesome thanks!
Jack,
Have you tried to use the scan codes directly in your application?
Here is an example. It clicks the mouse at the current location and then sends a {Tab}. You need to change this for your needs. You can move your mouse to the right location first with MouseMove,%XPos3%,%YPos3%
F8:: ; Press F8 to start macro
Send, {vk01} ; Click left mouse button
;Send, {scYYY} ;
Send, {vk09sc00F} ; Send the Vk and SC codes for the {Tab} key.
Return
Let me know if this works