Page 1 of 1

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

Posted: Feb 11th, ’20, 18:20
by cadudesun
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

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

Posted: Feb 12th, ’20, 10:12
by Tom
After running your command from the start menu, I get the focus on Chrome search field.
Also, you should use if instead of #if.

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

Posted: Feb 12th, ’20, 13:39
by cadudesun
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

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

Posted: Feb 12th, ’20, 22:05
by Tom
There should be no need for a pause.

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

Posted: Feb 21st, ’20, 13:11
by cadudesun
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.