Jump to content

Console or dunno


HiNoTora
 Share

Go to solution Solved by sahsanu,

Recommended Posts

Hi guys, i have script for Forex trade program, it works good, but my question is how i can turne my msgbox into 1 console like thing instead having popup notices all the time. and id love to if it stays ontop,

MsgBox(4096, "AutoTrade started", "Press ESC to exit")
HotKeySet("{ESC}", "Terminate")
while 1
$coord = PixelSearch(17, 753, 37, 765, 0x90F393); wait till positive position
MsgBox(4096, "AutoTrade started", "wait till positive position", 2)
If Not @error Then
    MouseClick("left", 1265, 738, 1); closing position
    MsgBox(4096, "AutoTrade started", "closing position", 2)
            Sleep ( 3000 )
                        $coord = PixelSearch(214, 124, 249, 182, 0xFF6060); waiting for sale mark
                            MsgBox(4096, "AutoTrade started", "waiting for sale mark", 2)

                        If Not @error Then
                        MouseClick("left", 306, 148, 1); opening new position
                        MsgBox(4096, "AutoTrade started", "opening new position", 2)

                        EndIf
                        If @error Then  
                        Sleep ( 100 )
                        EndIf


 EndIf      
        If @error Then         
    Sleep ( 100 )
 EndIf
  wend 
 

    
     Func Terminate()
    Exit
EndFunc
Link to comment
Share on other sites

if you are running your script from SciTE, then simply replace "MsgBox"

MsgBOX(4096, "AutoTrade started", "wait till positive position", 2)

with "ConsoleWrite"

ConsoleWrite("AutoTrade started wait till positive position" & @crlf)

bye

i want console to be stand alone, like msg box is, but it wont close, instead it keeps showing texts i have entered to autoit

Link to comment
Share on other sites

so heres new code.
 

#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode 
GUICreate("Forex Runner By:NerfKitten", 350, 252)
GUISetState(@SW_SHOW)
GUICtrlCreateLabel("To Exit Press ESC", 20, 25)
HotKeySet("{ESC}", "Terminate")


while 1
$coord = PixelSearch(17, 753, 37, 765, 0x90F393); wait till positive position
If Not @error Then
    MouseClick("left", 1265, 738, 1); closing position
            Sleep ( 3000 )
                        $coord = PixelSearch(214, 124, 249, 182, 0xFF6060); waiting for sale mark
                        If Not @error Then
                        MouseClick("left", 306, 148, 1); opening new position
                        EndIf
                        If @error Then  
                        Sleep ( 100 )
                        EndIf


 EndIf      
        If @error Then         
    Sleep ( 100 )
 EndIf
  wend

so id like to set console kind of thing ito this GUI

Edited by HiNoTora
Link to comment
Share on other sites

you should create a window at the beginning of your script

$MyGui = GUICreate("Console", 400, 100,-1,-1,Default,0x00000008) ; always on top
$MyConsole = GUICtrlCreateEdit("" , 0, 0, 400, 100)
GUISetState()

a function to write in that window at the end of your script

Func MyConsole($msg)
GUICtrlSetData ($MyConsole,GUICtrlRead($MyConsole)&$msg & @CRLF)
EndFunc

and use the function to print in that window instead of MsgBox

MyConsole("message")

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • Solution

 

Hi guys, i have script for Forex trade program, it works good, but my question is how i can turne my msgbox into 1 console like thing instead having popup notices all the time. and id love to if it stays ontop,

 

I think you need something like this:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <GUIEdit.au3>
#include <ScrollBarConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)

Global $hGUI = GUICreate("AutoTrade", 350, 400, -1, -1, -1, $WS_EX_TOPMOST)

Global $hEdit = GUICtrlCreateEdit("", 0, 0, 350, 350, BitOR($ES_READONLY, $ES_AUTOVSCROLL))
GUICtrlSetBkColor($hEdit, 0xFFFFFF)

Global $hButton = GUICtrlCreateButton("Start", 0, 350, 175, 50)
GUICtrlSetOnEvent($hButton, "_StartProgram")
Global $hButton2 = GUICtrlCreateButton("Pause", 175, 350, 175, 50)
GUICtrlSetOnEvent($hButton2, "_PauseProgram")

GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")
GUISetState(@SW_SHOW, $hGUI)

Global $start = 0, $wait = 1

_WriteToEditBox("AutoTrade started. Press ESC or click X to exit")

While 1
    If $start = 1 Then _MainProgram()
    Sleep(100)
wend

Func _StartProgram()
    _WriteToEditBox("Starting program")
    $wait = 1
    $start = 1
EndFunc   ;==>_StartProgram

Func _PauseProgram()
    _WriteToEditBox("Pausing program")
    $start = 0
EndFunc   ;==>_Pauserogram

Func _MainProgram()
    If $wait=1 Then _WriteToEditBox("Wait till positive position")
    $coord = PixelSearch(17, 753, 37, 765, 0x90F393); wait till positive position
    If Not @error Then
        $wait=1
        _WriteToEditBox("Closing position")
        MouseClick("left", 1265, 738, 1); closing position
        _WriteToEditBox("Waiting for sale mark")
        Sleep(3000)
        $coord = PixelSearch(214, 124, 249, 182, 0xFF6060); waiting for sale mark
        If Not @error Then
            MouseClick("left", 306, 148, 1); opening new position
            _WriteToEditBox("Opening new position")
        EndIf
    Else
        $wait=0
        Sleep(100)
    EndIf
EndFunc   ;==>_MainProgram

Func _WriteToEditBox($sText)
    $iEnd = StringLen(GUICtrlRead($hEdit))
    _GUICtrlEdit_SetSel($hEdit, $iEnd, $iEnd)
    _GUICtrlEdit_Scroll($hEdit, $SB_SCROLLCARET)
    If $iEnd = 0 Then
        GUICtrlSetData($hEdit, @HOUR & ":" & @MIN & ":" & @SEC & " :-: " & $sText, 1)
    Else
        GUICtrlSetData($hEdit, @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " :-: " & $sText, 1)
    EndIf
EndFunc   ;==>_WriteToEditBox

Func Terminate()
    Exit
EndFunc   ;==>Terminate

I'm pretty sure you will need to change several things but I think you have some start point to get what you are looking for.

Cheers,

sahsanu

Link to comment
Share on other sites

I think you need something like this:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <GUIEdit.au3>
#include <ScrollBarConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)

Global $hGUI = GUICreate("AutoTrade", 350, 400, -1, -1, -1, $WS_EX_TOPMOST)

Global $hEdit = GUICtrlCreateEdit("", 0, 0, 350, 350, BitOR($ES_READONLY, $ES_AUTOVSCROLL))
GUICtrlSetBkColor($hEdit, 0xFFFFFF)

Global $hButton = GUICtrlCreateButton("Start", 0, 350, 175, 50)
GUICtrlSetOnEvent($hButton, "_StartProgram")
Global $hButton2 = GUICtrlCreateButton("Pause", 175, 350, 175, 50)
GUICtrlSetOnEvent($hButton2, "_PauseProgram")

GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")
GUISetState(@SW_SHOW, $hGUI)

Global $start = 0, $wait = 1

_WriteToEditBox("AutoTrade started. Press ESC or click X to exit")

While 1
    If $start = 1 Then _MainProgram()
    Sleep(100)
wend

Func _StartProgram()
    _WriteToEditBox("Starting program")
    $wait = 1
    $start = 1
EndFunc   ;==>_StartProgram

Func _PauseProgram()
    _WriteToEditBox("Pausing program")
    $start = 0
EndFunc   ;==>_Pauserogram

Func _MainProgram()
    If $wait=1 Then _WriteToEditBox("Wait till positive position")
    $coord = PixelSearch(17, 753, 37, 765, 0x90F393); wait till positive position
    If Not @error Then
        $wait=1
        _WriteToEditBox("Closing position")
        MouseClick("left", 1265, 738, 1); closing position
        _WriteToEditBox("Waiting for sale mark")
        Sleep(3000)
        $coord = PixelSearch(214, 124, 249, 182, 0xFF6060); waiting for sale mark
        If Not @error Then
            MouseClick("left", 306, 148, 1); opening new position
            _WriteToEditBox("Opening new position")
        EndIf
    Else
        $wait=0
        Sleep(100)
    EndIf
EndFunc   ;==>_MainProgram

Func _WriteToEditBox($sText)
    $iEnd = StringLen(GUICtrlRead($hEdit))
    _GUICtrlEdit_SetSel($hEdit, $iEnd, $iEnd)
    _GUICtrlEdit_Scroll($hEdit, $SB_SCROLLCARET)
    If $iEnd = 0 Then
        GUICtrlSetData($hEdit, @HOUR & ":" & @MIN & ":" & @SEC & " :-: " & $sText, 1)
    Else
        GUICtrlSetData($hEdit, @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " :-: " & $sText, 1)
    EndIf
EndFunc   ;==>_WriteToEditBox

Func Terminate()
    Exit
EndFunc   ;==>Terminate

I'm pretty sure you will need to change several things but I think you have some start point to get what you are looking for.

Cheers,

sahsanu

Great thanks man. that looks promising, ill see what i can do with it. Need to wait til monday until forex are opend :)

Link to comment
Share on other sites

Great thanks man. that looks promising, ill see what i can do with it. Need to wait til monday until forex are opend :)

one more thing :P Mind to share how i should add codes for change background color and fonts and font color?

Its not necessary but would be bretyer with some design xD

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