Autohotkey: Send Key to inactive Window - autohotkey

Im using Chrome and wanting to send a Key to Edge.
This function does not work in the inactive window. Instead it presses the key in the active window, which is wrong. How can i fix this?
F1::
Heal()
{
WinActivate , xxx - Profil 1 – Microsoft Edge
Send {3}
WinActivate , xxx - Google Chrome
}
BTW: ControlSend is not an option.

Related

What window is active after click toast notification - AHK

i'm browsing google chrome then toast notification appears on bottom right.
i click it and it disappears.
after that i can see google chrome as top window, it looks like a active window but it's not activated.
then sometimes i press ctrl+t to open new tab in google chrome but it doesnt work because its not activated.
its annoying.
i want to make like below one.
#If WinActive("After Click Toast")
^t::
WinActivate ahk_exe chrome.exe
WinWaitActive ahk_exe chrome.exe
Send %A_ThisHotkey%
return
after click toast, windows spy doesnt show anything.
MsgWinTitle(){
WinGet, ExStyle, ExStyle, A
MsgBox % ExStyle
return
}
but with this shows 0x08200000
i dont know how can i use this though.
thanks for read.
thanks for help.
Thanks for Big advise
now i solved it with this
#If WinActive("ahk_class Windows.UI.Core.CoreWindow")
~LButton:: return
~LButton Up::
Send {Alt Down}{Tab}{Alt Up}
return

How to activate a window after it has lost focus?

So i am using this great software called Website-Watcher, which is rss feed reader and web content tracker.
I have configured it to open external links in firefox, which is opening tabs in the background.
BUT the problem is that Website-Watcher looses focus after i hit some link, so is there a way to open a link, regain lost focus and send click to be able to scroll, i have found a script that activates window on mouse scroll BUT the scroll functionality of program is not regained.
Please, give me some ideas!
EDIT UPDATE::: I have finally made it work, the problem was with the Windows 8.1 Admin rights, because i run Website-Watcher elevated, script that i was using stopped working.
The scripts are here:
http://www.autohotkey.com/board/topic/6292-send-mouse-scrolls-to-window-under-mouse/
http://www.autohotkey.com/board/topic/99405-hoverscroll-verticalhorizontal-scroll-without-focus-scrollwheel-acceleration/?p=623967
With those scripts you can perform scroll without activating windows or if you use the former you can even activate windows with mouse scroll.
Use WinActivate
For example, WinActivate Untitled - Notepad would activate (bring focus to) the window "Untitled - Notepad". This title must be exact and is case-sensitive.
It might be easiest to do this in a low-tech way. I'm not familiar with Website-Watcher, so I'll share a script I use that you should be able to adapt.
I use Feedly in Chrome for RSS reading, and hitting "v" in Feedly opens the story in a new tab. I use my Media Play button to hit "v" and bring me back to Feedly:
Media_Play_Pause::
send v
sleep 50
send {Ctrl Down}{Shift Down}{Tab}{Shift Up}{Ctrl Up}
return
So, define your hotkey, have it trigger the link to open in Firefox, and then hit Alt-Tab to jump back:
X::
send y
sleep 50
send {Alt Down}{Tab}{Alt Up}
return
Obviously, replace "X" and "y" above.
I don't care about using my Media Play button for anything else, but if you want your hotkey to be context sensitive, use #IfWinActive.
Use "WinGet, variableName , List, yourWindowName" (without quote)
then call your variableName contate it with 1 in every ControlSend
for example :
WinGet, nexid, List, myHyperTerminal
ControlSend, , {shift down}at=cmgs{shift up}=303{ENTER}, ahk_id %nexid1%
sleep, 1000
ControlSend, , {shift down}sms{shift up}{space}10000, ahk_id %nexid1%
sleep, 1000
if you want to use control key such as shift, ctrl, alt, don't forget to add "SetKeyDelay, intDelay, intPressDuration" (without quote)
for example the script will be list this
#usehook on
SetKeyDelay, 50, 20
WinGet, nexid, List, zz1
$F6::
ControlSend, , {shift down}at=cmgs{shift up}=303{ENTER}, ahk_id %nexid1%
sleep, 1000
ControlSend, , {shift down}sms{shift up}{space}10000, ahk_id %nexid1%
sleep, 1000
return
$F7::pause
it will be sent to active/inactive window "zz1" as :
AT+CMGS=303
SMS 10000

If statements in autohotkey

I would like a hotkey that opens Chrome when I hold the windows key and press "c". This is what I have written:
#c::Run chrome.exe
however, if chrome is already open, I would like it to activate that window instead. The example of such a script given in the beginner's tutorial is this
IfWinExist Untitled - Notepad
{
WinActivate
}
else
{
Run Notepad
WinWait Untitled - Notepad
WinActivate
}
Unfortunately, the name of any Chrome window is (current website) - Google Chrome so I need to know how to use some kind of universal name for my Chrome windows so that it will recognise them as the one program. Any help is appreciated. I am total noob
You can use the ahk_class of the window instead, it's like a unique identifier for the window. You can get it by right-clicking the autohotkey icon in your taskbar, selecting "Window Spy" then clicking on Chrome and copying the ahk_class.
if (WinExist("ahk_class Chrome_WidgetWin_1"))
WinActivate, % "ahk_id " WinExist("ahk_class Chrome_WidgetWin_1")
else {
MsgBox, Run Google Chrome
;Run, chrome.exe?
}

Switch to last chrome window

#.::
IfWinExist Chrome
WinActivate
else
Run Chrome
return
Works just fine when the Chrome application is not running (i.e., when I just started my computer). But when chrome is running, it does not behave like I want to. It simply creates a new window. If I have a certain Chrome window active, then it creates a new window on top of that. If, however, I run Notepad and hit #. then a new window is created in the background, and I am still facing Notepad.
(I 'veread http://www.autohotkey.com/board/topic/7129-run-a-program-or-switch-to-an-already-running-instance/)
What I want to do, is to switch to the previous chrome window just as if I used #{tab}. And if there is no chrome window active, then and only then I wish to open a new one.
This will work.
Shortcut for a new tab is Ctrl-T.
There's no simple way of finding out if the tab is empty
so I go to the address bar and look if that is empty by
copying it to the clipboard.
You need to change the run command to point to chrome in your language version of windows.
Also when I start chrome with run, it opens some old tabs.
#.::
SetTitleMatchMode, 2
IfWinExist, Google Chrome
WinActivate, Google Chrome
else
Run, "c:\programme\Google\Chrome\Application\chrome.exe"
WinWaitActive, Google Chrome
Send, ^l
Sleep, 200
Clipboard =
Send, ^c
Sleep, 200
MyClip = %Clipboard%
If (MyClip <> "")
{
Send, ^t
}
return

Having Problems running Auto Hot Key in "ahk_class SWT_Window0" windows

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