Autohotkey Chrome IfWinExist Issue - google-chrome

I want to have a sound repeat periodically when there is a new message in the Google Voice Inbox. So far what I've come up with is to have the GV Inbox always open in chrome, and have the following script running:
100:
IfWinExist, Google Voice - Inbox (
SoundPlay, C:\Users\Terry's\Desktop\chimes.wav, wait
Sleep, 1000
Goto 100
If there is a new message, the title of the GV tab is "Google Voice - Inbox (1) - Google Chrome" and if there are no new messages, the "(1)" is missing, so that's why the search string for IfWinExist includes one a "(".
This only works, however, when the GV tab has the attention within chrome (it will work when chrome is minimized or another window is active, as long as GV is the selected tab within chrome). But if another tab within chrome has the attention, then it won't work, and I can't figure out how to make it work. I've tried Adjusting SetTitleMatchMode, but that's all I could come up with to mess with. Any ideas would be greatly appreciated.

Have you tried the AutoHotKey Windows Spy to see how the GV is identified? This is what you will need (and it will most probably be the string you already have) Then set SetTitleMatchMode to 2 (find string anywhere in title). You could try to experiment with "escaping" the "open bracket".
Please don't use Sleep but launch a timer. I temporarily changed the sound back to something I know works. Once this works, you can make a change back to SoundPlay and remove the MsgBox.
Pseudo Code
#SingleInstance Force
#installKeybdHook
#Persistent
SetTitleMatchMode, 2
SetTimer, CheckWin, 10000 ; Run CheckWin every 10 seconds.
CheckWin:
IfWinExist, Google Voice - Inbox (
{
MsgBox, Alert
SoundBeep, 700, 700
}
Return

Related

Applescript click on multiple Google Chrome buttons - stopped working randomly

I was using a relatively simple applescript to automate clicking on two buttons in Google Chrome. It was working for weeks but has now stopped randomly without me changing anything. Here is the code I was using:
...
set loc1 to {1200, 400}
set loc2 to {1000, 600}
repeat 30 times
tell application "System Events"
tell process "Google Chrome"
set newest to true
delay 0.2
click at loc1
delay 0.1
click at loc1
delay 0.1
click at loc2
end tell
end tell
end repeat
...
After some experimenting I can still click on the tabs at the top of the chrome browser, but I can no longer click on any buttons/elements on the webpage. Any thoughts on things I can try?
Thanks!
#mrstuckguy, I see your question has no answer yet. I think you'd probably be better off just using Greasemonkey-style user scripts (JavaScript) to interact with HTML elements. Check Tampermonkey for example. You have a lot of examples on the web of how to interact with HTML buttons such as those pesky Cookie Banners. If you need help with an annoying popup just ask.
You'd add in a user scripts manager something like this:
setTimeout(() => {
var elements = document.querySelectorAll('a-moving-target-button')
elements.forEach((element) => {
if (element.textContent == 'I Agree') { element.click() }
})
},1000)
You should be aware, however, that the layout of these button-elements keeps changing and redact them respectively.

Jump to specific cell in google spreadsheets macro

I am aware of f5 to open the jump to cell dialog, the problem with it, is that, while it allows you to do it once, the next time you press f5, to jump to another specific cell, the previous text is not highlighted, therefore you need to get you hands off the keyboard and select it with the mouse.
If I could have a way where I don't lift my hands from the keyboard it would speed up my workflow tremendously.
Any ideas?
Like, I'd need a macro to pop up the goto range dialog AND select whatever text is there so that I can just type a new cell range (e.g: a391)
Thank you!
There is a simple approach to add customized macros to Sheets. You only need to create a bounded script beforehand that contains a function with your desired actions. Then you can follow these steps:
Go to Tools > Macros > Import
Find your function and click on Add Function and click on the X to close.
Go to Tools > Macros > Manage Macros
Assign a number to your macro and click on Update
Run your macro using Ctrl + Alt + Shift + {NUMBER}
Following those steps you will create a customized macro without difficulty, but feel free to ask me any doubts.
Work around for MacOS (High Sierra, probably it will work on newer os as well)
I downloaded the file AppleScript Toolbox.osax from here: https://astoolbox.wordpress.com/
Put the file in the folder: /Users/me/Library/ScriptingAdditions
Run Automator and start a new Service:
Paste this script
activate application "Firefox" -- or "Safari" or "Chrome", etc
set mousePointLocation1 to {1700, 250} -- coordinates depend on your screen size
AST click at mousePointLocation1 number of clicks 1
And save:
Go to Preferences > Keyboard > Services and add shortcut for this service
After that you will see the new shortcut here:
In Google Spreadsheet I press F5, to show the panel and then I press ^F5 and cursor jump on this panel and does click.
I'm a noob in macOS I'm sure it can be done better. It's just how I managed to do it right now.
Another modification of the script could be more convenient:
activate application "Firefox"
tell application "System Events"
key code 96 -- this is F5 key
end tell
delay .5
AST click at {1700, 250} number of clicks 2 -- or 3 maybe
This way you don't need to press F5. Just press ^F5 and go ahead.
It works
Just in case. If you know Python. I've managed to press F5 move and click mouse with Python module pynput:
from pynput import mouse, keyboard
k = keyboard.Controller()
k.press(keyboard.Key.f5)
k.release(keyboard.Key.f5)
m = mouse.Controller()
m.position = (1700, 240)
m.press(mouse.Button.left)
m.release(mouse.Button.left)
m.click(mouse.Button.left, 2)
https://pynput.readthedocs.io/en/latest/
It can be converted into macOS Service this way:
And then you can run this Service the same way via Keyboard > Services > Add Shortcut
Keyboard shortcuts in Google Spreadsheets are rather suck. If you're on Windows I'd advice to try Autohotkey. It can move cursor at any coordinates on your screen (coordinates can be set relative current window). For example 'Win+F5' could work as F5 + move cursor at top-right corner of the screen and perform a left click.
I just found another a much more obvious native solution.
Put the code in Script Editor:
function jump() {
var range = SpreadsheetApp.getUi().prompt('Input cell').getResponseText();
SpreadsheetApp.getActiveSheet().getRange(range).activate();
}
Save it and add the function as a macros:
Then assign some shortcut to the macros:
After that you can press the shortcut (CmdOptionShift5 in my case), input cell address, press Tab and Enter and here we go.

Google Script Autocomplete activates when semicolon is pressed instead of period

I started using Google Script a few hours ago, and I noticed that the Autocompletion doesn't not work correctly. It activates when I press ; (semicolon), but not when I press . (period).
Logger. // Does not display anything
Logger; // Diplays clear(), getLog(), ...
I am using an french AZERTY keyboard and I noticed that when I switch a QUERTY keyboard, then it works correctly.
It makes everything hard to do because, first I do not have the autocomplete, and also it inserts a method at the end of the line every time I press Semicolon and Enter...
Does anyone knows why I have this problem or how to fix it ?
Thank you!
Posting this for documentation purposes.
This behaviour was reported in Issue Tracker a few weeks ago. Users who are experiencing this and want to keep track of this case might want to click the star on the top left in the referenced page.
Reference:
Issue Tracker: Autocompletion dialog malfunctions on AZERTY keyboards

How can you send text to a Google Hangouts window then alt-tab to another window and keep on sending text to the minimized window, in AutoHotKey?

I want to spam my friend (I'm a great friend, I know hahahaaa) in Google Hangouts. The twist is, I want alt-tab to another window and I want the spammer to run in the background to spam my friend. Here's my code:
#NoEnv
#SingleInstance Force
SetBatchLines -1 ; maximum speed
^!m:: ; Ctrl + Alt + m: starts the spammer
sleep 500
BreakLoop := 0 ; 0 - Don't break the loop, 1 - Break the loop
Loop {
if (BreakLoop = 1) {
BreakLoop := 0
break
}
ControlSend,, text to spam, Google Hangouts - Google Chrome ; types the text
ControlSend,, {enter}, Google Hangouts - Google Chrome ; sends the text
sleep 5000 ; spams every 5 seconds
return
}
Esc:: ; stops the spammer
BreakLoop := 1
sleep 500
return
The problem is that I can't get it to work. When I alt tab to another window, it doesn't send or type the text. How do I fix that? Thanks in advance and sorry if my code is messy. Also, I am using the latest version of AutoHotKey.
The short answer is that this isn't really possible with AHK. AutoHotkey simulates keyboard and mouse input, and while you can get more advanced with JavaScript calls, the Hangouts window itself is still going to need to be the active window for any text input that AutoHotkey generates, and you can't use the keyboard/mouse while it's doing its thing.
You're likely better off performing this via Javascript in the Hangouts web client in Gmail, or y'know, just not spamming people altogether.

Refresh the top (active) tab with autohotkey

I have never used it, and after few attempts I feel like i will never get this. I feel this little program has potential but after finding out chrome has multiple child windows i don't think i know what's going on so please help...
I need a script that reloads the page on the current tab of chrome whenever i press Ctrl+R without switching to chrome and then little variation of that key to actually switch and refresh. Like lets say Numpad 1 for just refresh and Numpad 2 for switch and refresh.
Adding on to BGM...
Google Chrome - Hotkeys
https://support.google.com/chrome/answer/157179?hl=en
Activates the Google Chrome window
WinActivate,ahk_class Chrome_WidgetWin_1
Switches to the next tab.
ControlSend,,{Ctrl Down}{Tab}{Ctrl Up},ahk_class Chrome_WidgetWin_1
Switches to the previous tab.
ControlSend,,{Ctrl Down}{Shift Down}{Tab}{Shift Up}{Ctrl Up},ahk_class Chrome_WidgetWin_1
Ctrl+R : Reloads your current page.
ControlSend,,{Ctrl Down}r{Ctrl Up},ahk_class Chrome_WidgetWin_1
F5 : Reloads your current page.
ControlSend,,{F5},ahk_class Chrome_WidgetWin_1
Here is, basically, what you need to do:
Create a hotkey to run a sub.
Set Chrome as the active window (this will "switch") to Chrome.
Send the hotkey for refresh (usually F5)
If you can scramble a sample script together and post it, I'll help you debug it.