Why isn't my ImageSearch command working? - autohotkey

I am writing a script which uses the ImageSearch command.
The script starts by pressing F3 and it scans from 900,55 to 1005,72.
If it locates any of these 3 identical images, it should send F1, otherwise it should keep scanning until I press F12.
I tried changing the resolution and such but to no success.
F3::
SendMode , Input
SetMouseDelay , -1
SetBatchLines , -1
Loop
{
ImageSearch ,,, 0 , 0 , A_ScreenWidth , A_ScreenHeight , para1.png
bT := ErrorLevel ? bT : 1
ImageSearch ,,, 0 , 0 , A_ScreenWidth , A_ScreenHeight , para2.bmp
bT := ErrorLevel ? bT : 1
ImageSearch ,,, 0 , 0 , A_ScreenWidth , A_ScreenHeight , para3.png
bT := ErrorLevel ? bT : 1
If bT
{
bT := 0
Send , {F1}
Sleep , 100
}
}
Return
f12::ExitApp
thanks for the correction #GoldenLizard

Related

how to switch LAlt and LShift using AutoHotKey

I need RAlt + LAlt + g to behave as LShift + Del (nothing happend)
#InputLevel, 1
RAlt::F24
#inputLevel, 0
F24 & g::Del
LAlt::LShift
I test RAlt + RShift + g it works fine,
also I test to change the key g to d and it works too!!
#InputLevel, 1
RAlt::F24
#inputLevel, 0
F24 & d::Del
LAlt::LShift
did I miss something !?

SystemVerilog assertion for primitive

is there a way to add an assertion for a SystemVerilog primitive or only in the module (cell) wrapping the primitive ? simply adding an assertion does not compile
primitive mux (q, d0, d1, s);
output q;
input s, d0, d1;
table
// d0 d1 s : q
0 ? 0 : 0 ;
1 ? 0 : 1 ;
? 0 1 : 0 ;
? 1 1 : 1 ;
0 0 x : 0 ;
1 1 x : 1 ;
endtable
//assert(s != x) else $error("s has value x"); - add this assertion
endprimitive
The only construct allowed inside a user defined primitive (UDP) is the table. You'll need to wrap the UDP in a module to add anything else.

Count words Scala and create a dictionnary

I have a csv file with a type and a description text
type ; text
0 ; hello world
0 ; hello text 2
1 ; text1
1 ; text
2 ; world base
2 ; Hey you
2 ; test
In fact, I want to create a dictionnary and have another csv file structured like this with a unique line of each type and the frequence of each word on the description
type ; hello ; world ; text ; 2 ; text1 ; base ; hey ; you ; test
0 ; 2 ; 1 ; 1 ; 1 ; 0 ; 0 ; 0 ; 0 ; 0
1 ; 0 ; 0 ; 1 ; 0 ; 1 ; 0 ; 0 ; 0 ; 0
2 ; 0 ; 1 ; 0 ; 0 ; 0 ; 1 ; 1 ; 1 ; 1
I have tons of lines on my csv file with many Strings, this is just an example.
I am just starting to work with spark and scala these days. Any help is needed.
Thanks
Try:
import org.apache.spark.sql.functions._
df.withColumn("text", explode(split($"text", "\\s+")))
.groupBy("type")
.pivot("text")
.count.na.fill(0)

Integer conversion to given base

I want to convert any positive integer to some base from 2 to 9.
The output for base 2should be:
0 -> enlist 0
1 -> enlist 1
31 -> 1 1 1 1 1
62 -> 1 1 1 1 1 0
63 -> 1 1 1 1 1 1
64 -> 1 0 0 0 0 0 0
I developed the next function for this
convertToBase: reverse {[x;base;result]
result,: `int$x mod base;
x-: last result;
x%: base;
$[x=0;result;.z.s[x;base;result]]
};
//invocation
convertToBase[62;2;()]
The question is, if there is any build-in Q function to do it effectively? If not, how above solution can be optimized?
The vs function does this if the left-hand argument is a number.
For example:
2 vs 100
will return:
1 1 0 0 1 0 0
In the case where you have 0 as the right-hand argument it will, however, return an empty list, but you can wrap it with a conditional that outputs ,0 in the event that the returned value is empty.

Matlab PHD from Generator Matrix

I am studying phase-type distributions. Basically a phase-type distribution is defined on a directed graph, where the nodes have exponential holding times, and you want to know the distribution of the time before arriving into an absorbing state. As such, a phase-type distribution is defined by an initial probability vector PI and a Generator Matrix D0 (which really just captures the structure of the directed graph). For given PI and D0, the distribution is formally given by
F(t) = 1-PI * exp(D0 * t) * TAU
where TAU is a vector of ones of the same size as PI. For complicated D0, it is almost impossible to find the precise form by hand, because of that matrix exponential. However, using Matlab, one gets a rapid answer:
syms L H t
D0 = [-L , L , 0 , 0 , 0 , 0 , 0 , 0 ;
0 , -L , L , 0 , 0 , 0 , 0 , 0 ;
0 , 0 , -H , H , 0 , 0 , 0 , 0 ;
0 , 0 , 0 , -L , L , 0 , 0 , 0 ;
0 , 0 , 0 , 0 , -L , L , 0 , 0 ;
0 , 0 , 0 , 0 , 0 , -H , H , 0 ;
0 , 0 , 0 , 0 , 0 , 0 , -L , L ;
0 , 0 , 0 , 0 , 0 , 0 , 0 , -L ];
PI = [1, 0, 0, 0, 0, 0, 0, 0];
TAU = ones(8, 1);
DISTR = symfun(1-PI*expm(D0*x)*TAU, [L H t]);
PDF = symfun(diff(DISTR, x), [L H t]);
Here L and H are meant to be two parameters of the subjacent exponentially distributed holding times, and t is the time. My question is, how much can I trust DISTR and PDF? Is Matlab doing this computation exactly or is it a numerical approximation? The output seems certainly analytical (although very messy). For specific L=1 and H=2, you could simply do
PDF(1, 2, x)
to get the associated distribution, with the coefficient being in fractional form. For instance, the above gives
12*exp(-x) - 13*exp(-2*x) - 12*x*exp(-x) - 2*x*exp(-2*x) + 4*x^2*exp(-x) - (4*x^3*exp(-x))/3 + (x^4*exp(-x))/6 - (x^5*exp(-x))/30 + 1
Which seems to be in "exact" form, and does not look like an approximation... Moreover, numerical simulation shows that this formula is at least approximately correct.
Thanks in advance!
S