Close the "Sponsored session" window after Teamviewer disconnected - autohotkey

the following simple script is for closing the window "sponsored session" after the teamviewer(remote control client) disconnected, but i found the script does actually not working ? need help, thanks very much
#Persistent
#NoEnv
WinWait Sponsored session
WinKill

To close a window with Autohotkey as soon as it pops up, we have to create a loop (to do it multiple times), wait for a window to show up and kill it then. We detect the window through its title (here: "Sponsored Session")
SetTitleMatchMode, 2
#NoEnv
Loop, {
WinWait Sponsored session
WinKill
sleep 100
}
The SetTitleMatchMode, 2 does a partial match on the window title, so it may be kill more then expected if not used with caution (e.g. it will kill an browser if the title is part of the pagetitle).
The title of the target window can easily be detected with the "Window Spy" tool, which comes with AHK and can be used via the tray menu icon of any running AHK script.

Using Loop will cause a load on the CPU. So I made it resident in #Persistent and initialized with reload after processing.
#Persistent
#SingleInstance Force
WinWait, Sponsored session{
WinActivate, Sponsored session
Sleep, 500
Send, {Enter}
reload
}

Related

Unsure why AHK script isn't working as intended

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).

Activate my app from the tray - AHK

Imagine my application's window class name is classAbc
My app has a minimized in tray ability,
When a custom key is pressed it goes into tray,
How to activate it from the tray?
WinActivate, ahk_class classAbc
won't work at that time
I also tried WinShow with no success
Will it have a different class name when it goes into tray?
if so I used a macro recorder to find it's class name when it is resident in tray
but just found 2 classes which I think both are related to Microsoft windows menubar itself:
The classes and the activation codes:
WinActivate, ahk_class Shell_TrayWnd
WinActivate, ahk_class NotifyIconOverflowWindow
Tried these also but my app doesn't appeared once it goes to the tray.
Thanks in advance for any help
There are two methods depending on how your application manages its minimizing to tray:
WinShow ahk_class YOUR_APP_WINDOW_CLASS - to get the main window class name use AHK's built-in Window Spy available from a tray menu of an AHK script or in Windows Start Menu.
If the above method stops working on subsequent runs then the application stores its minimization state internally and you'll have to use TrayIcons function to send a mouse click message to the tray icon.
Since the application that is in the tray is just hidden (usually), you should use DetectHiddenWindows first. Then you use WinActivate
So it will look like this
#NoEn ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
DetectHiddenWindows, On
WinActivate, ahk_class classAbc
PS. I don't know what you want to do after activating the app from tray, but it might be a good idea to use WinWaitActive before anything else

AutoHotKey & Steam Overlay Interaction

Might already be answered but here we go. I wanted to write an AutoRun script using AutoHotKey for DayZ. It basically consists of two keys being constantly pressed and then slept. Easy script. But I want it to do one more thing. I want to be able to shift tab in the standalone to the web browser and still autorun while browsing say, facebook. Is there any way this can be possibly done? Thanks in advance.
Would probably help if I pasted the script to make it more concise.
#NoEnv
SendMode Input
#IfWinActive, DayZ
lctrl::
Send {w Down}
Send {lshift Down}
W::Sleep
return
Super simple. Basically the only issue, as I said, is that when I use the steam overlay to shift + tab to the browser, my keypresses, and therefore, autorun macro, doesn't persist. I am not sure if there's any way to remedy this but any help would be appreciated.
Your keys don't persist because they depend on DayZ being active. When the steam overlay is active, well the game is no longer active.
Use ControlSend, to send keys to inactive windows.
See the following example:
#NoEnv
SendMode Input
lctrl::
ControlSend, , {w Down}, DayZ
ControlSend, , {lshift Down}, DayZ
W::Sleep
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

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