Getting Ahk to notice when app performs a task finish. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
legend maxfreak
Posts: 73
Joined: 03 Sep 2017, 04:35

Getting Ahk to notice when app performs a task finish.

21 May 2018, 20:21

I have this anagram solving app which I run with ahk script with the following codes :

Code: Select all

^v::
Send, !s ;searches for words in the app
Sleep, 1000 ;waits for search to be done(always varies in relation to amount of words
send, !a ;copy all words to clipboard 
Send, !{esc} ; switches tab from anagram to next tab (notepad)
Send %clipboard%
Return 
please place your code in [code][/code] tags!

As you can see the sleep time for search to be done varies, 1k result takes 5sec, 500words 2secs, 4k 6secs and many more which I have to keep resetting sleep timer everytime.

I once used window spy to check the app, what I noticed was that whenever I press the search button manually, every info in the spy will just stop updating and when search is completed, focus control and active windows position will and others will resume updating me about the anagram app. Can their be a way that after search is clicked, sleep timer will be based on frozen(search is going on) and Focused and windows position changes and new update (search is done, then the next alt key 'copy all' can then function).

Please I need a script sample that will be able to detect when search is done I.e automatically knows when search task results are out and copies it all without stressing myself to add sleep timers everytime because its really stressful.
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Getting Ahk to notice when app performs a task finish.

22 May 2018, 15:47

It sounds like a job for a Windows event hook handler but it's hard to say without being able to test the app out..
umm there's an archived WinEventsHook messages function that you could possibly test just to see if it reveals anything useful:
WinEventHook - Messages

If you're able to return usable event data, it shouldn't be too hard to adapt to your script.
User avatar
legend maxfreak
Posts: 73
Joined: 03 Sep 2017, 04:35

Re: Getting Ahk to notice when app performs a task finish.

22 May 2018, 18:13

TLM wrote:It sounds like a job for a Windows event hook handler but it's hard to say without being able to test the app out..
umm there's an archived WinEventsHook messages function that you could possibly test just to see if it reveals anything useful:
WinEventHook - Messages

If you're able to return usable event data, it shouldn't be too hard to adapt to your script.
Can you please help me test the app out? The name is James Garton anagram master.zip, you can search it on Google, it will easily bring it out, I don't really know about WinEventHook sir
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Getting Ahk to notice when app performs a task finish.

23 May 2018, 15:27

well you got linked the tutorial on WinEventHook, so it seems to me like a decent enough place to start learning about it
User avatar
legend maxfreak
Posts: 73
Joined: 03 Sep 2017, 04:35

Re: Getting Ahk to notice when app performs a task finish.

24 May 2018, 07:17

swagfag wrote:well you got linked the tutorial on WinEventHook, so it seems to me like a decent enough place to start learning about it
I'll definitely look into it and learn but please at least send here a simple script sample with the WinEventHook in it
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Getting Ahk to notice when app performs a task finish.

24 May 2018, 12:26

Just for testing purposes, you run the WinEventHook script, then the application, and see what messages it spits out during your actions..
Report back if it returns useful data..
User avatar
legend maxfreak
Posts: 73
Joined: 03 Sep 2017, 04:35

Re: Getting Ahk to notice when app performs a task finish.

24 May 2018, 15:36

TLM wrote:Just for testing purposes, you run the WinEventHook script, then the application, and see what messages it spits out during your actions..
Report back if it returns useful data..
No problem, I'll do just that and send any useful stuff here sir
User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Getting Ahk to notice when app performs a task finish.  Topic is solved

25 May 2018, 00:35

You can utilize clipboard as you said while search window freezes so "!a" would also not copy anything and clipboard remain empty, I would prefer using controlsend it would send key to specific window and you can do anything else but ^C copy :HeHe:

Code: Select all

^v::
Send, !s ;searches for words in the app
clipboard := ""
while clipboard = "" ; as you can said window is frozen then !a won't work and clipboard will remain empty 
{
	send, !a ;copy all words to clipboard 
	sleep, 1000
}
clipwait
Send, !{esc} ; switches tab from anagram to next tab (notepad)
Send %clipboard%
Return 
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
User avatar
legend maxfreak
Posts: 73
Joined: 03 Sep 2017, 04:35

Re: Getting Ahk to notice when app performs a task finish.

26 May 2018, 11:41

Thanks to everyone who contributed, the problem is solved.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mapcarter, Marium0505, wjt936826577 and 381 guests