Jump to content

Little help on my first project please


Recommended Posts

Hi

Sorry for my very messy. I watched lots if YT videos and been searching to mix and match the code to do the things I want but so far I cant seems to fire it.

Background info:
There is a pop-up "Alert" window and inside the window there will be text either "up" or "down"
If "Alert" window is "up", i want it to click it on certain places vice versa.

Below is my humble code that I got so far:

Quote

   While 1 ;to loop
         If StringInStr(WinActivate("Alert"), "up") Then ;to search if the alert window has "up" msg
            WinActivate ("Alert")
            Send ("ENTER") ; to close the alert window
            MouseClick ( "left",354, 237, 1, 10)  ;to activate the 44189 window
            WinWaitActive ("44189")
            MouseClick ( "left", 358, 294, 1, 10) ; coordinates for 03. Click "CLOSE ALL TRADES" ONCE
            MouseClick ( "left", 159, 314, 1, 10) ; coordinates for 04. Click twice at "GBPJPY" ONCE
            MouseClick ( "left", 74, 293, 1, 10) ; coordinates for 05. Click once "TRADE" ONCE
         EndIf

         If StringInStr(WinActivate("Alert"), "down") Then ;to search if the alert window has the "down" msg
            WinActivate ("Alert")
            Send ("ENTER") ; to close the alert window
            MouseClick ( "left",354, 237, 1, 10) ;to activate the 44189 window
            WinWaitActive ("44189")
            MouseClick ( "left", 358, 294, 1, 10) ; coordinates for 03. Click "CLOSE ALL TRADES" ONCE
            MouseClick ( "left", 159, 314, 2, 10) ; coordinates for 04. Click twice at "GBPJPY" TWICE
            MouseClick ( "left", 74, 293, 1, 10) ; coordinates for 05. Click once "TRADE" ONCE
         EndIf
      WEnd

This is what alert window looks like:
Alert_ask.JPG.2a6191c3d5825db00ca433f1ca14a8f8.JPG

 

Here is the window info of the "Alert" window around the "down/up" area:

Quote

>>>> Window <<<<
Title:    Alert
Class:    #32770
Position:    570, 74
Size:    365, 416
Style:    0x14CC2044
ExStyle:    0x00010500
Handle:    0x0000000000030478

>>>> Visible Text <<<<
OK
GBPJPY XXXXXXXXXX changed to up
List1

Any help/ pointers would be greatly appreciated and thank you very much for taking time to read this.

Link to comment
Share on other sites

@First_Project, welcome to AutoIt and to the forum.

this is obviously a monitoring program which you are trying to manipulate. now, any decent monitoring program should be able to perform an action (send email, at least) when a monitored element is down. why won't you use that feature?

 

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

24 minutes ago, orbs said:

@First_Project, welcome to AutoIt and to the forum.

this is obviously a monitoring program which you are trying to manipulate. now, any decent monitoring program should be able to perform an action (send email, at least) when a monitored element is down. why won't you use that feature?

 

Its actually for trading platform MT4 and when there is alert I have to manually do the trade myself and I want to do the trade while I sleep also. Hence, not sure if monitoring program is helpful or not but i just want the script to click few buttons when there is alert.

Do you have any suggestion for monitoring program so i can have a look. I can do similar thing with the mt4 platform but the learning curve is just too high. Hope you understand. 

Do you also mean that it cant be done with autoit?

 

Link to comment
Share on other sites

While 1 ;to loop

    $win_text = WinGetText("Alert")

    If StringInStr($win_text, "up") Then ;to search if the alert window has "up" msg
        WinActivate("Alert")
        Send("ENTER") ; to close the alert window
        MouseClick("left", 354, 237, 1, 10) ;to activate the 44189 window
        WinWaitActive("44189")
        MouseClick("left", 358, 294, 1, 10) ; coordinates for 03. Click "CLOSE ALL TRADES" ONCE
        MouseClick("left", 159, 314, 1, 10) ; coordinates for 04. Click twice at "GBPJPY" ONCE
        MouseClick("left", 74, 293, 1, 10) ; coordinates for 05. Click once "TRADE" ONCE
    EndIf

    If StringInStr($win_text, "down") Then ;to search if the alert window has the "down" msg
        WinActivate("Alert")
        Send("ENTER") ; to close the alert window
        MouseClick("left", 354, 237, 1, 10) ;to activate the 44189 window
        WinWaitActive("44189")
        MouseClick("left", 358, 294, 1, 10) ; coordinates for 03. Click "CLOSE ALL TRADES" ONCE
        MouseClick("left", 159, 314, 2, 10) ; coordinates for 04. Click twice at "GBPJPY" TWICE
        MouseClick("left", 74, 293, 1, 10) ; coordinates for 05. Click once "TRADE" ONCE
    EndIf

    Sleep(300) ; do tests 3x per second
WEnd

 

Link to comment
Share on other sites

21 minutes ago, First_Project said:

I can do similar thing with the mt4 platform but the learning curve is just too high

i'm not so certain about that. setting an "Action" for an "Alert" in MT4 seems quite simple, according to this article at-least.

regardless, as long as the elements of the window are recognizable by AutoIt, manipulating them should not be so complicated, as demonstrated in the prior post.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

1 hour ago, Zedna said:
While 1 ;to loop

    $win_text = WinGetText("Alert")

    If StringInStr($win_text, "up") Then ;to search if the alert window has "up" msg
        WinActivate("Alert")
        Send("ENTER") ; to close the alert window
        MouseClick("left", 354, 237, 1, 10) ;to activate the 44189 window
        WinWaitActive("44189")
        MouseClick("left", 358, 294, 1, 10) ; coordinates for 03. Click "CLOSE ALL TRADES" ONCE
        MouseClick("left", 159, 314, 1, 10) ; coordinates for 04. Click twice at "GBPJPY" ONCE
        MouseClick("left", 74, 293, 1, 10) ; coordinates for 05. Click once "TRADE" ONCE
    EndIf

    If StringInStr($win_text, "down") Then ;to search if the alert window has the "down" msg
        WinActivate("Alert")
        Send("ENTER") ; to close the alert window
        MouseClick("left", 354, 237, 1, 10) ;to activate the 44189 window
        WinWaitActive("44189")
        MouseClick("left", 358, 294, 1, 10) ; coordinates for 03. Click "CLOSE ALL TRADES" ONCE
        MouseClick("left", 159, 314, 2, 10) ; coordinates for 04. Click twice at "GBPJPY" TWICE
        MouseClick("left", 74, 293, 1, 10) ; coordinates for 05. Click once "TRADE" ONCE
    EndIf

    Sleep(300) ; do tests 3x per second
WEnd

 

OMG! Zedna THANK YOU!!! 
I been trying to fix it for whole Sunday and countless YT Vid and google search. You have my utmost respect!
Thanks for your kind help. 

I will make sure I will pass the good deeds forward <3.

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...