Jump to content
Sign in to follow this  
TitaniusPlatinum

Issue using variables inside functions

Recommended Posts

Hey Guys, 

I really hate to be that person to post here asking for help but i have tried for hours fixing this and i have looked everywhere online. 
I honestly think it's something so simple just flying over my head. 

Now i have simply threw this together for demonstration purposes. 
All i'm trying to do is use a pixel search to detect if the windows 10 search bar is visible (1366 x 768 Resolution) and use a variable as the search coords.
As you can see in my little comment below, it's also not working inside of mousemove for example.

It's spits out an error at Line 7 which is:  Incorrect Number of Parameters
Using MouseMove to test it's only picking up the first number of the variable and i'm a little confused.

Can you guys please shed some light on this? Please don't just give me the answer, please explain what i'm doing wrong and how to fix it as i want to learn. Cheers :)

#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>

Global $Var1 = "306, 749"
Global $Var2 = "0xF2F2F2"

Local $TempPixel = PixelSearch($Var1, $Var1, $Var2)

If Not @error Then ;If True Then
   MsgBox($MB_SYSTEMMODAL, "GG", "REE")
Else
   MsgBox($MB_SYSTEMMODAL, "Faa", "REE")
EndIf

;MouseMove($Var1)       ; This Fails - Shouldn't it work?
;MouseMove($Var1, $Var1); This moves to 306 x 306

 

Share this post


Link to post
Share on other sites

You can't combine 2 function parameters into a single variable.  Split them into separate variables.

Share this post


Link to post
Share on other sites
4 minutes ago, Nine said:

You can't combine 2 function parameters into a single variable.  Split them into separate variables.

Fair enough, that's a pain but i'll work around it thankyou :)
I was certain it was an error on my end that i could resolve. 
I'll just use an Array to keep things nice and clean, thankyou :) 

Share this post


Link to post
Share on other sites

Like @Nine says, plus you are missing two parameters in the PixelSearch function call ... 3rd & 4th are not optional.

You should name your variables to something more useful. i.e. $top, $left, $right, $bottom, $color, etc.

Just because a variable has a comma in its midst doesn't mean it will be split by that in normal usage.


Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
2 minutes ago, TitaniusPlatinum said:

I'll just use an Array to keep things nice and clean, thankyou

Maybe use StringSplit to achieve that array.


Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...