Jump to content

Help with Code


Recommended Posts

--------------------------------------------------------------------------------

Hello

I need some help here!

What I have is an elseif statment within a while,continues loop, that needs to be modified.

I need to Buy as many time as possible, then Sell.

What is happening is when a Buy is no longer available the program still sees the option availabe.

The reason for this is it is controled by x,y screen location of the buttons location and the button is still there.

So it clicks the buy when infact it should click the sell seeing how the buy is no longer an option.

How can the code be corrected?

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

elseif $action = 4 then

; Buy/Sell

; if we can Buy then Buy otherwise Sell

if StringInStr(ControlGetText($optionname, "", $BuyButton), "Buy") = 1 then

ControlClick($optionname, "", $BuyButton);

else

ControlClick($optionname, "", $sellButton);

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I tried grouping 2 commands in one StringInStr and it would not allow me to do this.

I think a code that first click buy followed up by a sell everytime should work

seeing how it will buy first and at this point the sell would not be available so it would only false click

sell option.

On the other hand when a sell is available it will excecute it.

hence correcting the problem.

I am new to this group and my Knowledge is limited. Sorry if this question seem simple.

Thank You Mike1212 :lmao:

Link to comment
Share on other sites

--------------------------------------------------------------------------------

Hello

I need some help here!

What I have is an elseif statment within a while,continues loop, that needs to be modified.

I need to Buy as many time as possible, then Sell.

What is happening is when a Buy is no longer available the program still sees the option availabe.

The reason for this is it is controled by x,y screen location of the buttons location and the button is still there.

So it clicks the buy when infact it should click the sell seeing how the buy is no longer an option.

I would like to help you but o:) , what are you talking about? :lmao:

I am running a box with borg technology! The distintiveness of your brand box will be added to the colective ... protection utilities are futile!cha, cha, chachaaaanm!
Link to comment
Share on other sites

I think i understand, he has 2 buttons, buy and sell. he wants to click buy untill its no longer enabled, then click sell. is that right?

then try looking at the ControlCommand() function

ControlCommand ( "title", "text", controlID, "IsEnabled", "" )

"IsEnabled" Returns 1 if Control is enabled, 0 otherwise

maybe like this :

if ControlCommand($optionname,"",$BuyButton,"IsEnabled","") then

ControlClick($optionname, "", $BuyButton);

else

ControlClick($optionname, "", $sellButton);

Edited by steveR
AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Link to comment
Share on other sites

Hi SteveR

Yes you are correct, that is exactly what I need. :)

Now if I can get it to work. :lmao:

I tried your conrtol command idea and it does the same as my elseif

command no good :)

I think both of these commands are acting as single command seeing how the

program doesnt know if the button was enabled or not.

I think I need maybe some type of "then command" o:)

See these 2 buttons have no way of telling the program which one of them is active. If I reverse the oder it sells but never buys the the other way it buys

and never sells. :)

Mike

Edited by mike1212
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...