Sign in to follow this  
Followers 0
helpme

Need help with a script.

15 posts in this topic

#1 ·  Posted (edited)

I have a script for a game, it's very nearly there, just need some help on an error I'm receiving.

I'm basically making a script to scan for 2D monsters on a game, in window mode, to attack(click on them) until the monster has died. Whenever I run the script in-game it returns that error, anyone have any idea?

Here is the error..

Posted Image

If you could speak on MSN or something, I could explain the whole scenario and hopefully you can come up with an answer as I've literally been stuck at it for hours and hours.

Thank you.

Edited by helpme

Share this post


Link to post
Share on other sites



I recommend posting your code and typing out the exact error message.

It may be on my end (behind work firewall) but I cannot get your error message image.


What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Share this post


Link to post
Share on other sites

I recommend posting your code and typing out the exact error message.

It may be on my end (behind work firewall) but I cannot get your error message image.

The code is pretty long and I don't really want to open release it, in a way.

I can type the error message,

Line 247 (My script location)
MouseMove(($POS[0] + $POS[2] / 2),($POS[1] + $POS[3] / 2)+10, 0)
MouseMove(($POS^ ERROR

Error: Subscript used with non-Array variable.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

The error message tells you that you want to access an "array" that is no array. I usually get this error when a a previous call to a function that should return an array fails.

Best way to help you is to post your code - or at least the lines where "array" $POS is populated.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

The error message tells you that you want to access an "array" that is no array. I usually get this error when a a previous call to a function that should return an array fails.

Best way to help you is to post your code.

I can PM you it or over msn, if you like.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Post the portion of the code that starts with:

$pos =

the problem has to do with how you set the data for $pos...

Since i have made the type of program you are talking about before im guessing your using:

$pos = pixelsearch($x1,$y1,$x2,$y2)

if this is correct then you have to find out of the function that does pixel search is being called.

Edited by Negative1

What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Share this post


Link to post
Share on other sites

$pos = pixelsearch($x1,$y1,$x2,$y2)

$POS = WinGetPos($WINTIT)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

In case of an error WinGetPos returns 0 and sets @error to 1 if window is not found. Could you change your code and post the result:

$POS = WinGetPos($WINTIT)
ConsoleWrite("Error for WinGetPos: " & @error & @CRLF)
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

$POS = WinGetPos($WINTIT)

Instead of

$POS = WinGetPos($WINTIT)

use

msgbox(0,"",$WINTIT)

in the same place. If the message box does not pop up then you know that the func is not being called and therefore $pos never gets set.

If the message box does pop up the text on the message box should match the window you are trying to get the position of.


What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Share this post


Link to post
Share on other sites

Instead of

$POS = WinGetPos($WINTIT)

use

msgbox(0,"",$WINTIT)

in the same place. If the message box does not pop up then you know that the func is not being called and therefore $pos never gets set.

If the message box does pop up the text on the message box should match the window you are trying to get the position of.

I was ingame, then I pressed the hotkey to start the bot and it worked, in a sense that the box opened and said 0

ToolTip("Initialising", 0, 0)
    $title = iniread ("hacks.ini" , "Windowtitle" , "title","")
    $WINTIT = WinGetTitle($title)
    $POS = msgbox(0,"",$WINTIT)
    $SIZE = WinGetClientSize($WINTIT)
    CENTER()

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I can only find a window with a title, but the window I want my script to find has no title... is there an alternative I can use so it can retrieve the $POS correctly, as it's not finding the window.

Also its myth of soma.

Edited by helpme

Share this post


Link to post
Share on other sites

I was ingame, then I pressed the hotkey to start the bot and it worked, in a sense that the box opened and said 0

ToolTip("Initialising", 0, 0)
    $title = iniread ("hacks.ini" , "Windowtitle" , "title","")
    $WINTIT = WinGetTitle($title)
    $POS = msgbox(0,"",$WINTIT)
    $SIZE = WinGetClientSize($WINTIT)
    CENTER()

My guess is that your problem is in line:

$title = iniread ("hacks.ini" , "Windowtitle" , "title","")

follow it up with

msgbox(0,"",$title)

My bet is the $title is = "" due to iniread failing.

I would also guess that the problem is with "hacks.ini"

if hacks.ini is in the same directory as the script you are running use:

iniread (@scriptdir&"\hacks.ini" , "Windowtitle" , "title","")


What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Share this post


Link to post
Share on other sites

I can only find a window with a title, but the window I want my script to find has no title... is there an alternative I can use so it can retrieve the $POS correctly, as it's not finding the window.

Also its myth of soma.

If the window has no title it will probably still have a class. Check the au3 window info tool for the class name. You can then use:

$WINTIT = WinGetTitle("[CLASS:classname]")

Change the bold "classname" to whatever the window info tool tells you.


What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Share this post


Link to post
Share on other sites

If the window has no title it will probably still have a class. Check the au3 window info tool for the class name. You can then use:

$WINTIT = WinGetTitle("[CLASS:classname]")

Change the bold "classname" to whatever the window info tool tells you.

I like your style, that part is working fine now, it was just the fact it couldn't find what window to go too, using the class found it. :)

Few more things to fix now, if I need help I know exactly where to go, you guys are great.

Thank you.

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  
Followers 0