After clicking start menu, Fastkeys isn't focusing the background app to run the expected command

Discussion, questions and support.
Post Reply
cadudesun
Posts: 103
Joined: Jun 6th, ’15, 03:28

Post by cadudesun » Feb 11th, ’20, 18:20

Hi,

I'd appreciate your help.
By clicking Fastkeys start menu having Chrome as the last used app, I was expecting the command below to run, copying to the clipboard the URL and webpage title with the following formatting:

FastKeys Automation Software
https://www.fastkeysautomation.com/

However, it seems after clicking the start menu, Fastkeys isn't focusing on Chrome again to run the expected command:

Code: Select all

#If WinActive("ahk_class Chrome_WidgetWin_1")
Sleep 150 ;wait for Fastkeys menu to disappear and the window on background be focused
WinGetActiveTitle, WinTitle
Send, {Ctrl Down}l{Ctrl Up}
Clipboard := ""
Sleep 50
Send, {Ctrl Down}c{Ctrl Up}
ClipWait, 1
Clipboard := StrReplace(WinTitle, " - Google Chrome") . "`n" . Clipboard
#If
I tried to set "Sleep 150" expecting for Fastkeys menu to disappear and Chrome be focused again.

When I run the script as a "shortcut" it works properly, so I'm considering the issue is related to performing the script from the menu.

=> How to get this command to run properly from Fastkeys start menu?

Thank you very much,
Carlos
User avatar
Tom
Posts: 402
Joined: Nov 24th, ’15, 23:39

Post by Tom » Feb 12th, ’20, 10:12

After running your command from the start menu, I get the focus on Chrome search field.
Also, you should use if instead of #if.
cadudesun
Posts: 103
Joined: Jun 6th, ’15, 03:28

Post by cadudesun » Feb 12th, ’20, 13:39

Hi @Tom,

Many thanks for the reply!
When creating this kind of script to be actionable from Fastkeys menu, do you know if it is necessary to use a "sleep" command to give Fastkeys menu the time to disappear and the script be guaranteed to work properly?

Code: Select all

Sleep 150 ;wait for Fastkeys menu to disappear and the window on background be focused
User avatar
Tom
Posts: 402
Joined: Nov 24th, ’15, 23:39

Post by Tom » Feb 12th, ’20, 22:05

There should be no need for a pause.
cadudesun
Posts: 103
Joined: Jun 6th, ’15, 03:28

Post by cadudesun » Feb 21st, ’20, 13:11

Tom wrote:
Feb 12th, ’20, 22:05
There should be no need for a pause.
Thanks @Tom.
I've been testing commands from the menu without pause, and they are working properly indeed.
Post Reply