Allright, to start, here is my script so far;
http://p.ahkscript.org/?p=b09242f0
I have a script to center windows for me. After using it for a while I had to make exceptions for certain windows. Now, I make a new line for every window that should not be affected but this should and probably can, be done more efficiently.
I read the autohotkey help for arrays and did some googling but can't find a good example that I can use in my code. Making a array with the class names is the easy part, but how do I check my current active window to the content of the array and if there is a match, don't center and continue?
I am sure the amount if lines I currently use in my script can be halved.
need help to make a array and compare the content to current active window
Re: need help to make a array and compare the content to current active window
Example:
An alternative to arrays in this case is to use If var in
Code: Select all
array:=["Red","Blue","Yellow"]
detectedcolor=green
primary:=false
Loop % array.MaxIndex()
If (detectedcolor=array[A_Index])
primary:=true
If primary
MsgBox The color found was primary
else
MsgBox The color found was not primary
; the array is still defined, so now we just need to change the detectedcolor variable's value
detectedcolor=blue
primary:=false
Loop % array.MaxIndex()
If (detectedcolor=array[A_Index])
primary:=true
If primary
MsgBox The color found was primary
else
MsgBox The color found was not primary
return
Re: need help to make a array and compare the content to current active window
Exaskryz wrote:Example:
An alternative to arrays in this case is to use If var inCode: Select all
array:=["Red","Blue","Yellow"] detectedcolor=green primary:=false Loop % array.MaxIndex() If (detectedcolor=array[A_Index]) primary:=true If primary MsgBox The color found was primary else MsgBox The color found was not primary ; the array is still defined, so now we just need to change the detectedcolor variable's value detectedcolor=blue primary:=false Loop % array.MaxIndex() If (detectedcolor=array[A_Index]) primary:=true If primary MsgBox The color found was primary else MsgBox The color found was not primary return
I tried to adept your code to fit with mine and after many tries nothing worked in my script. I ended up with:
Code: Select all
WinGetClass, Class, A
Array := ["DV2ControlHost", "BaseBar"]
Loop % Array.MaxIndex()
If (Class == Array[A_Index])
Continue
Re: need help to make a array and compare the content to current active window
Found it! The link you gave me had the answer:
I knew there had to be a short and simple way for my simple script and there it is. Thanks a ton!
Code: Select all
WinGetClass, Class, A
If Class contains DV2ControlHost,BaseBar
Continue