Plugin Window Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
boiler
Posts: 17113
Joined: 21 Dec 2014, 02:44

Re: Plugin Window

17 Apr 2020, 22:06

Add this line immediately after the ImageSearch line and see what it says:

Code: Select all

MsgBox, % ErrorLevel
If it’s a 1, it just can’t find it, but if it’s a 2, there’s something wrong with the command, such as the location of the image file.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Plugin Window

18 Apr 2020, 04:40

Philharmonic wrote:
17 Apr 2020, 19:19
All audio suite plugins has a "render" button in the bottom
If the button always is at the same place, then You dont need image search.
Just get dimension of Your window, and send controlclick to it with necessary coordinates.
User avatar
boiler
Posts: 17113
Joined: 21 Dec 2014, 02:44

Re: Plugin Window

18 Apr 2020, 05:08

Philharmonic wrote:
28 Jun 2017, 11:27
I know that I can use mouse base location, but that would not be ideal for me because the plugin window will not always be in the same location.
If the plugin window is a true stand-alone window, then you can do this using coordinates relative to the window. It looks like it may not be, though. If not, then you need to somehow locate the position of the button, and ImageSearch should work.

It may be possible that the "Render" text is getting drawn (rendered) differently in different positions due to anti-aliasing, so I suggest making the reference image a piece of the button that doesn’t include any of the text and none of its border. That should be the same no matter where it is located.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Plugin Window

18 Apr 2020, 06:56

Just for the records, as far as I remember ImageSearch works best/more reliable if the source image is in *.bmp format.
I've used that format always in the first instance proving the concept and changed to png (and its necessary IS-parameters) if I had enough time left to waste.
Cropping the image was done using Alt+Print > and MS Paint.

BTW, have you tried this already?

FindClick() FindClick() - Documentation
User avatar
boiler
Posts: 17113
Joined: 21 Dec 2014, 02:44

Re: Plugin Window

18 Apr 2020, 07:23

BoBo wrote:
18 Apr 2020, 06:56
Just for the records, as far as I remember ImageSearch works best/more reliable if the source image is in *.bmp format.
Using .png format is just as reliable as .bmp format. They both are lossless (no compression artifacts), which is the key -- 100% pixel-for-pixel true to the original image. It is formats like .jpg that change the pixel content while they compress the image that can and will cause ImageSearch to fail.
BNOLI
Posts: 548
Joined: 23 Mar 2020, 03:55

Re: Plugin Window

18 Apr 2020, 09:15

I had both formats of the same image, the *.png has been the identical (online) converted *.bmp. Nevertheless, it hasn't worked out for me with the *.png file - for whatever reason (?) :angel:
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
Philharmonic
Posts: 50
Joined: 22 May 2017, 13:51

Re: Plugin Window

18 Apr 2020, 12:22

Thanks everyone for your help and suggestions. Totally awesome of you all for pitching in. I'm going to run some test of my own, specifically using FindText. That looks very interesting. If that doesn't find the result I want, then I'll move to other suggestions noted on this thread. There will definitely be a bunch of trial an error, but regardless, I will keep you all updated on my findings. It's' going to take sometime so thank you all again. :thumbup:
w0z
Posts: 230
Joined: 19 Jun 2014, 08:21

Re: Plugin Window

18 Apr 2020, 13:26

Philharmonic wrote:
18 Apr 2020, 12:22
Thanks everyone for your help and suggestions. Totally awesome of you all for pitching in. I'm going to run some test of my own, specifically using FindText. That looks very interesting. If that doesn't find the result I want, then I'll move to other suggestions noted on this thread. There will definitely be a bunch of trial an error, but regardless, I will keep you all updated on my findings. It's' going to take sometime so thank you all again. :thumbup:

I made a short video:

https://www.youtube.com/watch?v=rnJF_D5yIBQ

I hope it helps.! :beer:
If I was helpful consider Donate me. :beer: , plz :D
Philharmonic
Posts: 50
Joined: 22 May 2017, 13:51

Re: Plugin Window

18 Apr 2020, 16:43

w0z wrote:
18 Apr 2020, 13:26
Philharmonic wrote:
18 Apr 2020, 12:22
Thanks everyone for your help and suggestions. Totally awesome of you all for pitching in. I'm going to run some test of my own, specifically using FindText. That looks very interesting. If that doesn't find the result I want, then I'll move to other suggestions noted on this thread. There will definitely be a bunch of trial an error, but regardless, I will keep you all updated on my findings. It's' going to take sometime so thank you all again. :thumbup:

I made a short video:

https://www.youtube.com/watch?v=rnJF_D5yIBQ

I hope it helps.! :beer:
Halelluja!!!! :dance:
That actually works! The video you made was freakin awesome and I'm so grateful for that. I also want to thank everyone in this thread that tried to help me figure this puzzle out. Seriously, I wish I can repay all of you guys back somehow. I am a complete noob when it comes to scripting, but I am a power Pro Tools user. It's a DAW application for Music and Post Production. I mainly use it for Post Production (Film/TV) work, so if any of you guys need help with Pro Tools, consultation with Film/TV project, or anything within the realm of audio production, I am now obligated to help you guys out.

On that note, there's a couple of things that I want to modify with the script. Originally, I had a script to bring up the audiosuite plugin, but the problem was always trying to figure out how to click the "render" button. Now that you have helped me with that, I now want to be able to bring up the audiosuite plugin, click on the "render" button, and close the audiosuite plugin window. My first script to bring up the plugin is below

Code: Select all

PgUp::
WinMenuSelectItem, Pro Tools, , AudioSuite, EQ, Channel Strip
return
So I combined the script you wrote with mine below.

Code: Select all

 #Include FindText.ahk

PgUp::
WinMenuSelectItem, Pro Tools, , AudioSuite, EQ, Channel Strip
return

 t1:=A_TickCount, X:=Y:=""

Text:="|<Render Button>*188$66.zzzzzzzzzzzU1zzzzzVzzzU1zzzzzVzzzbsTzzzzVzzzbsTzzzzVzzzbsM7U7U1US1bsM7U7U1US1U1VVbbba66TU1VVbbba66TbbU1bbba06TbbU1bbba06TbVtzbbbbbyTbVtzbbbbbyTbsM7bbU7USTbsM7bbU7USTzzzzzzzzzzzU"

 if (ok:=FindText(842-150000, 1703-150000, 842+150000, 1703+150000, 0, 0, Text))
 {
   CoordMode, Mouse
   X:=ok.1.x, Y:=ok.1.y, Comment:=ok.1.id
   Click, %X%, %Y%
 }


 for i,v in ok
   if (i<=2)
     FindText_MouseTip(ok[i].x, ok[i].y)

Return

I tried putting in "SetWinDelay" after my first script, but it just brought up the plugin without clicking on "render." Is that the correct delay to use or is there another command?
w0z
Posts: 230
Joined: 19 Jun 2014, 08:21

Re: Plugin Window

18 Apr 2020, 17:36

Code: Select all

 #Include FindText.ahk

PgUp::
WinMenuSelectItem, Pro Tools, , AudioSuite, EQ, Channel Strip
;return          ; in this line it is the end of the code therefore  lines below won't work. So delete it

Sleep, 1000

 t1:=A_TickCount, X:=Y:=""
...
If I was helpful consider Donate me. :beer: , plz :D
SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: Plugin Window

18 Apr 2020, 17:54

Philharmonic wrote:
17 Apr 2020, 18:57
boiler wrote:
17 Apr 2020, 17:45
You need to crop that image so it's within the bounds of the button itself for the reason described in my last post. Best to make the image just around the letters.

In what directory is the script file that you are running? That's where you put the image. Otherwise, you can specify the full path to the image by changing the ImageSearch to this:

Code: Select all

	ImageSearch, ImX, ImY, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Program Files\AutoHotkey\render.png
I'm sorry to keep wasting your time on this, but I just can't figure it out...
A couple of things that can be done to help ImageSearch work better.

1. Use *n (variation). https://www.autohotkey.com/docs/commands/ImageSearch.htm
The variation can be adjusted between 0 to 255. Helps if coloring of the image varies slightly and compensates for differences between ImageFile format (.jpg, .png, .gif, etc...) and image on the screen.

Code: Select all

ImageSearch, ImX, ImY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 C:\Program Files\AutoHotkey\render.png
2. Optionally, use WinActivate to select the correct window, before using ImageSearch. https://www.autohotkey.com/docs/commands/WinActivate.htm
If you have multiple windows on the desktop, this can help that you are searching the correct one.

3. Optionally, use CoordMode for searching the screen. https://www.autohotkey.com/docs/commands/CoordMode.htm
You usually just have to choose between WinActivate, WindowTitle or CoordMode, Pixel, Screen in your script.
Philharmonic
Posts: 50
Joined: 22 May 2017, 13:51

Re: Plugin Window

18 Apr 2020, 18:11

SOTE wrote:
18 Apr 2020, 17:54
Philharmonic wrote:
17 Apr 2020, 18:57
boiler wrote:
17 Apr 2020, 17:45
You need to crop that image so it's within the bounds of the button itself for the reason described in my last post. Best to make the image just around the letters.

In what directory is the script file that you are running? That's where you put the image. Otherwise, you can specify the full path to the image by changing the ImageSearch to this:

Code: Select all

	ImageSearch, ImX, ImY, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Program Files\AutoHotkey\render.png
I'm sorry to keep wasting your time on this, but I just can't figure it out...
A couple of things that can be done to help ImageSearch work better.

1. Use *n (variation). https://www.autohotkey.com/docs/commands/ImageSearch.htm
The variation can be adjusted between 0 to 255. Helps if coloring of the image varies slightly and compensates for differences between ImageFile format (.jpg, .png, .gif, etc...) and image on the screen.

Code: Select all

ImageSearch, ImX, ImY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 C:\Program Files\AutoHotkey\render.png
2. Optionally, use WinActivate to select the correct window, before using ImageSearch. https://www.autohotkey.com/docs/commands/WinActivate.htm
If you have multiple windows on the desktop, this can help that you are searching the correct one.

3. Optionally, use CoordMode for searching the screen. https://www.autohotkey.com/docs/commands/CoordMode.htm
You usually just have to choose between WinActivate, WindowTitle or CoordMode, Pixel, Screen in your script.

Thank you SOTE for chiming in. Super awesome of you to do that. Another gentleman in this thread has recommended me to use "FindText" and so far it's been doing the trick. A couple of modification and I believe I have finally cracked this 3 year old puzzle. Ha! :o
Philharmonic
Posts: 50
Joined: 22 May 2017, 13:51

Re: Plugin Window

18 Apr 2020, 18:24

w0z wrote:
18 Apr 2020, 17:36

Code: Select all

 #Include FindText.ahk

PgUp::
WinMenuSelectItem, Pro Tools, , AudioSuite, EQ, Channel Strip
;return          ; in this line it is the end of the code therefore  lines below won't work. So delete it

Sleep, 1000

 t1:=A_TickCount, X:=Y:=""
...

You sir, are a freakin stud! 8-) ,

I added a line (WinKill) at the end of the script to close the plugin window and it seems to work. The script is below. I'm curious if you know if there's multiple plugin windows open, would that script be able to distinguish the current active plugin I'm using or would it close all plugin window since the Window Class is generic. Curious to know if what I included in the script is adequate to tell the difference.

Code: Select all

 for i,v in ok
   if (i<=2)
     FindText_MouseTip(ok[i].x, ok[i].y)

if WinExist("ahk_class DigiFloaterClass")
   WinKill

Return
Also, is there a way to have the mouse go back to its default location. It would be ideal to have the mouse click on the "render" button and then go back to it's original location. I tried substituting the script below but it's not doing anything

Code: Select all

FindText_Left_Click(Obj,X_Adj=0,Y_Adj=0,Move_Back=0){
	CoordMode, Mouse
	MouseGetPos,Orig_X,Orig_Y
	x:=(obj.1+obj.3//2)+X_Adj
	y:=(obj.2+obj.4//2)+Y_Adj
	Click, %X%,%Y%
	if (Move_Back){
	Sleep, 30
	MouseMove, %Orig_X%,%Orig_Y%
}
Return
Philharmonic
Posts: 50
Joined: 22 May 2017, 13:51

Re: Plugin Window

18 Apr 2020, 21:50

Actually, the mouse returning to it's default location doesn't bother me too much. My other goal that I have now is having different plugin windows that I want up, click on render button, and then close the window. The original script is for one specific plugin I use.

Code: Select all

 #Include FindText.ahk

+d::
WinMenuSelectItem, Pro Tools, , Audiosuite, Noise Reduction, RX 7 De-click

Sleep, 1000
SetMouseDelay, 20

 t1:=A_TickCount, X:=Y:=""

Text:="|<>*190$41.zzzzzzz1UakM8CtTBirrBqy/QjisABKt31qvuBmyrgrqPhxbQUiks/bzzzzzzw"

 if (ok:=FindText(1392, 652, 1458, 672, 0, 0, Text))
 {
   CoordMode, Mouse
   X:=ok.1.x, Y:=ok.1.y, Comment:=ok.1.id
   Click, %X%, %Y%
 }


 for i,v in ok
   if (i<=2)
     FindText_MouseTip(ok[i].x, ok[i].y)

Sleep, 50

if WinExist("ahk_class DigiFloaterClass")
	WinKill

Return 
As you can see, I created a hotkey (shift + d) to bring up the plugin, which works exactly the way I want it to. The problem now is when I add in another hotkey to bring up a different plugin. The plugin comes up, but the script can't find the text and the mouse does not follow and click on the render button (which the render button is identical to all other audiosuite plugins). The new plugin window just opens, then closes, but skips out all the middle function. The modified script is below.

Code: Select all

 #Include FindText.ahk

+d::
WinMenuSelectItem, Pro Tools, , Audiosuite, Noise Reduction, RX 7 De-click

Sleep, 1000
SetMouseDelay, 20

 t1:=A_TickCount, X:=Y:=""

Text:="|<>*190$41.zzzzzzz1UakM8CtTBirrBqy/QjisABKt31qvuBmyrgrqPhxbQUiks/bzzzzzzw"

 if (ok:=FindText(1392, 652, 1458, 672, 0, 0, Text))
 {
   CoordMode, Mouse
   X:=ok.1.x, Y:=ok.1.y, Comment:=ok.1.id
   Click, %X%, %Y%
 }


 for i,v in ok
   if (i<=2)
     FindText_MouseTip(ok[i].x, ok[i].y)

Sleep, 50

if WinExist("ahk_class DigiFloaterClass")
	WinKill

Return 


+p::
WinMenuSelectItem, Pro Tools, , Audiosuite, Noise Reduction, RX 7 De-plosive

Sleep, 1000
SetMouseDelay, 20

 t1:=A_TickCount, X:=Y:=""

Text:="|<>*190$41.zzzzzzz1UakM8CtTBirrBqy/QjisABKt31qvuBmyrgrqPhxbQUiks/bzzzzzzw"

 if (ok:=FindText(1392, 652, 1458, 672, 0, 0, Text))
 {
   CoordMode, Mouse
   X:=ok.1.x, Y:=ok.1.y, Comment:=ok.1.id
   Click, %X%, %Y%
 }


 for i,v in ok
   if (i<=2)
     FindText_MouseTip(ok[i].x, ok[i].y)

Sleep, 50

if WinExist("ahk_class DigiFloaterClass")
	WinKill

Return 



Any ideas? Also, a bizarre behavior will happen randomly. The FindText will sometimes not find the text that's already been captured, so I'll have to re-capture it again and re-do the steps over. Maybe I'm modifying the script and something funky is happening. :?
Philharmonic
Posts: 50
Joined: 22 May 2017, 13:51

Re: Plugin Window

18 Apr 2020, 23:08

BNOLI wrote:
18 Apr 2020, 09:15
I had both formats of the same image, the *.png has been the identical (online) converted *.bmp. Nevertheless, it hasn't worked out for me with the *.png file - for whatever reason (?) :angel:

Mr. BNOLI, I salute you sir. After hundreds of trial and error with different suggestions from all these fine folks in the thread, the script you originally suggested finally works. I don't know what I did differently. The only real difference is I originally tried doing this in my Surface Pro 4, which as you know didn't work, but then I moved over to my desktop workstation and it WORKS!!! :superhappy:

I started to use FindText and it was very promising and speedy, however I would encounter little quirks that annoyed me so I scratched that process. It's a wonderful process, but maybe too involved for my work. I still very grateful for that suggestion and everyone else.

If I can perhaps bug you again. Is there a way to have the mouse default back to it's original location as opposed to going to the "render" button and just staying there? I posted the script you helped me with and added a few to boost my approach.

Code: Select all

~+d::
WinMenuSelectItem, Pro Tools, , Audiosuite, Noise Reduction, RX 7 De-click

Sleep, 500

CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
loop, 50 ; wait a maximum of 5 seconds (50 * 100ms) for render button to appear
{
	ImageSearch, ImX, ImY, 0, 0, A_ScreenWidth, A_ScreenHeight, render.png
	Sleep, 100
} until !ErrorLevel
if ErrorLevel
	MsgBox, Could not find 'Render' button
else
	Click, %ImX%, %ImY%

Sleep, 2500

if WinExist("ahk_class DigiFloaterClass")
	WinKill

Return 
It would be super ideal if I can have the mouse move back to it's original location. I can live with not having the mouse default to it's original location, but I figure we went this far, let's keep going if possible. :dance: Again, very grateful for your valuable time in helping with this. :D
BNOLI
Posts: 548
Joined: 23 Mar 2020, 03:55

Re: Plugin Window

19 Apr 2020, 03:24

Congrats! But I've checked the whole thread for that script that you've said I've had suggested - and didn't find it! 8-)
So I have the idea you saluted the wrong guy/lady :lol: Anyway, IMHO it's a combined effort of all contributors/supporters.
GO AHK 8-)

BTW, use MouseGetPos to keep the mouse position right before you trigger ImageSearch. Once ImageSearch went successfully let's move back to the previous position using MouseMove.
Good luck :)
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
User avatar
boiler
Posts: 17113
Joined: 21 Dec 2014, 02:44

Re: Plugin Window

19 Apr 2020, 05:38

Below is how to use MouseGetPos and MouseMove to return the mouse pointer to its original position.

Code: Select all

~+d::
WinMenuSelectItem, Pro Tools, , Audiosuite, Noise Reduction, RX 7 De-click

Sleep, 500

CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
MouseGetPos, PrevX, PrevY
loop, 50 ; wait a maximum of 5 seconds (50 * 100ms) for render button to appear
{
	ImageSearch, ImX, ImY, 0, 0, A_ScreenWidth, A_ScreenHeight, render.png
	Sleep, 100
} until !ErrorLevel
if ErrorLevel
	MsgBox, Could not find 'Render' button
else
	Click, %ImX%, %ImY%
MouseMove, PrevX, PrevY
Sleep, 2500

if WinExist("ahk_class DigiFloaterClass")
	WinKill

Return 
I suspect the reason it didn’t work on your laptop is that you have a Windows setting for scaling at something other than 100%. What I’ve seen is that when the scaling factor is greater than 150%, Windows doesn’t render graphics at their true pixel-for-pixel representation, but it stretches and blends the pixel colors, usually making ImageSearch impossible even with high allowable variation in color.
Philharmonic
Posts: 50
Joined: 22 May 2017, 13:51

Re: Plugin Window

19 Apr 2020, 11:36

BNOLI wrote:
19 Apr 2020, 03:24
Congrats! But I've checked the whole thread for that script that you've said I've had suggested - and didn't find it! 8-)
So I have the idea you saluted the wrong guy/lady :lol: Anyway, IMHO it's a combined effort of all contributors/supporters.
GO AHK 8-)

BTW, use MouseGetPos to keep the mouse position right before you trigger ImageSearch. Once ImageSearch went successfully let's move back to the previous position using MouseMove.
Good luck :)
Oh shoot. Hahahahaha. Thanks for pitching in anyways.
Philharmonic
Posts: 50
Joined: 22 May 2017, 13:51

Re: Plugin Window

19 Apr 2020, 11:44

boiler wrote:
19 Apr 2020, 05:38
Below is how to use MouseGetPos and MouseMove to return the mouse pointer to its original position.

Code: Select all

~+d::
WinMenuSelectItem, Pro Tools, , Audiosuite, Noise Reduction, RX 7 De-click

Sleep, 500

CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
MouseGetPos, PrevX, PrevY
loop, 50 ; wait a maximum of 5 seconds (50 * 100ms) for render button to appear
{
	ImageSearch, ImX, ImY, 0, 0, A_ScreenWidth, A_ScreenHeight, render.png
	Sleep, 100
} until !ErrorLevel
if ErrorLevel
	MsgBox, Could not find 'Render' button
else
	Click, %ImX%, %ImY%
MouseMove, PrevX, PrevY
Sleep, 2500

if WinExist("ahk_class DigiFloaterClass")
	WinKill

Return 
I suspect the reason it didn’t work on your laptop is that you have a Windows setting for scaling at something other than 100%. What I’ve seen is that when the scaling factor is greater than 150%, Windows doesn’t render graphics at their true pixel-for-pixel representation, but it stretches and blends the pixel colors, usually making ImageSearch impossible even with high allowable variation in color.
Boiler! I initially saluted the wrong guy so I want to apologize. Haha! I wanted to personally thank you for helping me with this 3 year old problem. :dance: Thank you for your valuable time and effort in helping me out.

I will try out the other line you added for getting the mouse position back to its original position sometime today. I’ll definitely get back to you on that. Again, thanks a bunch! :superhappy:
w0z
Posts: 230
Joined: 19 Jun 2014, 08:21

Re: Plugin Window

19 Apr 2020, 11:58

try this way I hope it works for you. :beer:

Code: Select all

#IfWinActive, Pro Tools
	+d::
	WinMenuSelectItem, Pro Tools, , AudioSuite, Other, Gain
	if WinExist("AudioSuite")
		WinActivate

	Sleep, 1000
	WinGetPos, wX, wY, wW, wH, AudioSuite
	SetMouseDelay, 20

	t1:=A_TickCount, X:=Y:=""

	Text:="|<>*190$41.zzzzzzz1UakM8CtTBirrBqy/QjisABKt31qvuBmyrgrqPhxbQUiks/bzzzzzzw"

; Text:="|<Render Button>*188$66.zzzzzzzzzzzU1zzzzzVzzzU1zzzzzVzzzbsTzzzzVzzzbsTzzzzVzzzbsM7U7U1US1bsM7U7U1US1U1VVbbba66TU1VVbbba66TbbU1bbba06TbbU1bbba06TbVtzbbbbbyTbVtzbbbbbyTbsM7bbU7USTbsM7bbU7USTzzzzzzzzzzzU"



	if (ok:=FindText(wX, wY, wX+wW, wY+wH, 0, 0, Text))
	{
	CoordMode, Mouse,Screen
	MouseGetPos, Orig_X,Orig_Y

	X:=ok.1.x, Y:=ok.1.y, Comment:=ok.1.id
	Click, %X%, %Y%
	} else {
		MsgBox, 48, , No render button found!, 2
	}

	for i,v in ok
	if (i<=2)
	 FindText_MouseTip(ok[i].x, ok[i].y)

	MouseMove, %Orig_X%, %Orig_Y%

	Sleep, 1500
	if WinExist("ahk_class DigiFloaterClass")
	WinKill

	Return 

#IfWinActive
If I was helpful consider Donate me. :beer: , plz :D

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: haomingchen1998, ntepa, sofista, TAC109, Tvlao and 117 guests