Wrong use of IfWinExist into a thread ? Topic is solved

Ask for help, how to use AHK_H, etc.
scriptors
Posts: 227
Joined: 25 Feb 2016, 09:01

Wrong use of IfWinExist into a thread ?

Post by scriptors » 29 Sep 2020, 06:57

Hi, my goal is to continue thread only if the named windows exist:

Code: Select all

;###########################################################################
!^m::
PacchiMisteriosi("1", 560, 323, 0x381605, 320, 300, 0xBC8328, 345, 310)
PacchiMisteriosi("2", 560, 323, 0x381605, 320, 300, 0xBC8328, 345, 310)
PacchiMisteriosi("3", 560, 323, 0x381605, 320, 300, 0xBC8328, 345, 310)
PacchiMisteriosi("4", 560, 323, 0x381605, 320, 300, 0xBC8328, 345, 310)
PacchiMisteriosi("5", 560, 323, 0x381605, 320, 300, 0xBC8328, 345, 310)
PacchiMisteriosi("Alexa", 560, 323, 0x381605, 320, 300, 0xBC8328, 345, 310)
PacchiMisteriosi("Destiny", 560, 323, 0x381605, 320, 300, 0xBC8328, 345, 310)
PacchiMisteriosi("Supermario", 560, 323, 0x381605, 320, 300, 0xBC8328, 345, 310)
...
Return

PacchiMisteriosi(wname, xclick_0, yclick_0, color_0, xclick_1, yclick_1, color_1, xclick_2, yclick_2)
	{
return AhkThread("
	(
if WinExist(" wname ") ; ----> it work only for windows named 1 - 2 - 3 - 4 - 5  .... NOT for other :( olso try   IfWinExist, " wname " and NOT work
{ 
	CoordMode ,Pixel,Screen ;set this to use absolute coordinates and for specific thread
	Sleep 100
	YYY := " yclick_0 " -20
	WinGetPos, X, Y, , , " wname " ; ----------------------------------- This work ok for all windows (if not use winexist check)
	xPixel := X + " xClick_0 " ;screen coords X for chek
	yPixel := Y + " yClick_0 " ;screen coords Y for chek
	Sleep 100
	xxPixel := X + " xClick_1 " ;screen coords X for chek
	yyPixel := Y + " yClick_1 " ;screen coords Y for chek
	xxxPixel := X + " xClick_2 " ;screen coords X for chek
	yyyPixel := Y + " yClick_2 " ;screen coords Y for chek
	Sleep 100
		...
		...
}		
	)")
}
were i mistake ?

scriptors
Posts: 227
Joined: 25 Feb 2016, 09:01

Re: Wrong use of IfWinExist into a thread ?

Post by scriptors » 30 Sep 2020, 04:11

workaround:

Code: Select all

...
return AhkThread("
	(
NomeFinestra = " wname "
Sleep 300
IfWinExist, %NomeFinestra%
{
...
code
...
}
...

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Wrong use of IfWinExist into a thread ?  Topic is solved

Post by swagfag » 30 Sep 2020, 05:33

Code: Select all

...
if WinExist(""" wname """)
...

scriptors
Posts: 227
Joined: 25 Feb 2016, 09:01

Re: Wrong use of IfWinExist into a thread ?

Post by scriptors » 01 Oct 2020, 07:13

Thanks, i try this ... bu you can explain more about ? Why triple quotation marks ??

I think you put " like a text: """ (central quotation mark) and wname like variable, correct ?

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Wrong use of IfWinExist into a thread ?

Post by swagfag » 01 Oct 2020, 08:58

...
return AhkThread("
(
if WinExist(""" wname """) ; ---...
...
...
")

simply obey the rules for escaping quotation marks inside quoted string literals
  • green - start/end of quoted string literal
  • red - quote inside a quoted string literal, requiring escaping
  • blue - quote inside a quoted string literal which escapes a quote
if u find this confusing u can use Format(), or pass ur variables in A_Args, or use ahkv2

scriptors
Posts: 227
Joined: 25 Feb 2016, 09:01

Re: Wrong use of IfWinExist into a thread ?

Post by scriptors » 01 Oct 2020, 10:39

ok, i understand :thumbup:

really thanks

Post Reply

Return to “Ask for Help”