junkone

Ninjatrader scroll to right

5 posts in this topic

#1 ·  Posted (edited)

I have a script that takes screenshots of the ninjatrader charting window. I have 2 issues that i need an idea for solution.

1. i need to scroll the window fully to right? the title of the window =$EURUSD  and the class of the scrollbar =WindowsForms10.SCROLLBAR.app.0.378734a

i am already having the handle of the window using $hWnd = WinGetHandle($Title5) 

how can i click the scrollbar all the way to right?Fixed

2. sometimes the chart scaling is invalid and so there will be a icon F that i have highlighted with arrow on the image. its in the top right hand corder of this window. All i have to do is to click on it to restore the scaling. How can i find that point and automate the click?

IDCl0N9.png

#include <ScreenCapture.au3>
Example()

Func Example()
     Local $hWnd
     Local $Title5 ="$EURUSD"
     
     Local $FilePath="c:\temp\images"
     Local $FileName="Filename"

    Opt("WinTitleMatchMode", 2)

    if($CmdLine[0]>0) Then ; Contains the total number of items in the array.
        $FileName=$CmdLine[1]
        EndIf

     If WinExists($Title5) Then
       ; MsgBox($MB_SYSTEMMODAL, "", $CmdLine[0])
            ; Retrieve the handle of the Notepad window using the classname of Notepad.
     $hWnd = WinGetHandle($Title5)
      ; Activate the Notepad window using the handle returned by WinWait.
    WinActivate($hWnd)
;scroll to the right EndFunc

; click on focus icon 

      ; Capture window
    _ScreenCapture_CaptureWnd( $FilePath & $FileName & $Title5 &".jpg",  $hWnd)

    Else
        MsgBox($MB_SYSTEMMODAL, "", "Window does not exist")
    EndIf
#cs  If WinExists($Title1) Then
###        ; MsgBox($MB_SYSTEMMODAL, "", $CmdLine[0])
###             ; Retrieve the handle of the Notepad window using the classname of Notepad.
###      $hWnd = WinGetHandle($Title1)
###       ; Activate the Notepad window using the handle returned by WinWait.
###     WinActivate($hWnd)
### 
###       ; Capture window
###     _ScreenCapture_CaptureWnd( $FilePath & $FileName & $Title1 &".jpg",  $hWnd)
### 
###     Else
###         MsgBox($MB_SYSTEMMODAL, "", "Window does not exist")
###     EndIf
 #CE



  ShellExecute($FilePath & $FileName & $Title5 &".jpg")
   ShellExecute($FilePath & $FileName & $Title1 &".jpg")
EndFunc   ;==>Example

 

Edited by junkone
fixed half the problem

Share this post


Link to post
Share on other sites



When you search the forum you will notice that Windows Forms are hard/impossible to automate.
Doesn't NinjaTrader provide some kind of interface you could automate?


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

Ninjatrader does not offer automation in terms of such levels of scaling. need some ideas to do this.

Share this post


Link to post
Share on other sites

To scroll to the right I would try the following (can't at the moment): MouseClickDrag


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

i fixed the problem with the scroll part. Ninjatrader supports the {END} key so i fixed it by sending the {END} key after window is active.

my remaining issue is to find a way to click on that F button. its on the topright of the window with class name Class:    WindowsForms10.Window.8.app.0.378734a

how can i find the x and y position of the right edge of the control "Class:    WindowsForms10.Window.8.app.0.378734a" using Autoit dynamically?

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

  • Similar Content

    • Xandy
      By Xandy
      Screenshot program that can upload/FTP to website/storage with hotkey.
      Features GUI to display programmable keys.

      Set the hotkeys with this function to use, and display hotkeys.
      ; hotkey_set() Parameters: ; ----------------------------------------------------------- ; $aHotkey -                The array hotkeys are stored in. This function sets the values of this array[hotkey_id][$hotkey_data] ; $dHotkey_id -             The enum for this hotkey index ; $sHotkey_description -     The label displayed to the user to represent function of hotkey ; $sHotkey_name -            The hotkey it'self.  Whatever name string you want to give the key ; $dHotkey_key -             The _IsPressed keycode ;    Keycodes AT: https://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm ; $dHotkey_shift -             Shift flag 0 or 1 Default off ; $dHotkey_ctrl -             Ctrl flag 0 or 1 Default off ; $dHotkey_alt -             Alt flag 0 or 1 Default off Func hotkey_set(ByRef $aHotkey, $dHotkey_id, $sHotkey_description, $sHotkey_name, $dHotkey_key, $dHotkey_shift = 0, $dHotkey_ctrl = 0, $dHotkey_alt = 0)     $aHotkey[$dHotkey_id][$eHotkey_data_key_description] = $sHotkey_description     $aHotkey[$dHotkey_id][$eHotkey_data_key_name] = $sHotkey_name     $aHotkey[$dHotkey_id][$eHotkey_data_key] = $dHotkey_key     $aHotkey[$dHotkey_id][$eHotkey_data_shift] = $dHotkey_shift     $aHotkey[$dHotkey_id][$eHotkey_data_ctrl] = $dHotkey_ctrl     $aHotkey[$dHotkey_id][$eHotkey_data_alt] = $dHotkey_alt EndFunc   ;==>hotkey_set ; You can set your hotkeys here ; Please visit the hotkey_set() function for parameter information hotkey_set($aHotkey, $eHotkey_screenshot_ftp, "Selected Window to FTP", "F12", "7B", 0, 1, 0); F12 hotkey_set($aHotkey, $eHotkey_screenshot_disk, "Selected Window to Disk", "S", "53", 1, 1, 1); S hotkey_set($aHotkey, $eHotkey_clipboard_send, "Send Clipboard keystrokes", "F10", "79", 1, 1, 1); F10  
      Configure settings dialog:

      Screenshot Filename and Screenshot Counter, are used to create simple unique filenames that can cycle. Copy URL to clipboard option. - For linking your screenshots. The screenshot file type is for local copy only. App always uses .JPG for FTP right now, but I could add FTP screenshot file type specification.  
      Any suggestions?  Did I break anything, what did I miss?
      Package uses TTS.au3 by Beege: 
       
      FTP_Screen.zip
      File includes:
         - FTP_Screen.au3
         - FTPScreen.ico
         - TTS.au3 - by Beege
    • ashly
      By ashly
      i'm trying to use _ScreenCapture_Capture($sFileName) to cature full screen and save as a jpg file, but it always only capture the left-top about 3/4 area.
      but the print screen keyboard woks fine.
      and if i changed the display resolution from 150% to 100%, the jpg file is OK as well.
      so the issue only occurred when resolution is 150%.
      is there anybody know why or how to change resolution percentage by scripts?
      Thanks.
    • SalamanderSoup
      By SalamanderSoup
      I've created a simple script that opens the Snipping Tool; Selects the "Full Screen Snip" option; then closes the program, prompting a save.  What I can't figure is how to name the file using the system date and time.
      Can anyone help?
      Run(@WindowsDir & '\system32\SnippingTool.exe') AutoItSetOption('MouseCoordMode', 0) Sleep(1) $hWnd= WinWait("Snipping Tool", "ToolBarWindow32", 1) WinActive($hWnd) MouseClick('primary', 84, 48, 1, 0) MouseClick('primary', 84, 140, 1, 0) WinClose("[Class:Microsoft-Windows-Tablet-SnipperEditor]") ControlClick("Snipping Tool", "", "Button1")  
       
       
       
    • DrAhmed
      By DrAhmed
      Hey
      I'm not really familliar with GDI Plus , I am looking for how tocConvert a bitmap image to JPG in memory without saving it to disk
      Because I want to send it later via TCP directly without using FileRead and other stuff ..
      The only function I found is below but it saves the image in disk
      Func SaveBmp2JPG($Bitmap, $sSave = "Converted.jpg", $iQuality = 20) ;coded by UEZ 2013 If Not IsPtr($Bitmap) Then $Bitmap = _GDIPlus_ImageLoadFromFile($sFile) If @error Then Return SetError(1, 0, 0) EndIf Local $sCLSID = _GDIPlus_EncodersGetCLSID("JPG") Local $tParams = _GDIPlus_ParamInit(1) Local $tData = DllStructCreate("int Quality") Local $pData = DllStructGetPtr($tData) Local $pParams = DllStructGetPtr($tParams) DllStructSetData($tData, "Quality", $iQuality) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) If Not _GDIPlus_ImageSaveToFileEx($Bitmap, $sSave, $sCLSID, $pParams) Then Return SetError(2, 0, 0) Return True EndFunc what my code now looks like :
      #include <ScreenCapture.au3> #include <guiconstantsex.au3> #include <gdiplus.au3> #include <memory.au3> #include <staticconstants.au3> Global $ghGDIPDLL = $__g_hGDIPDll Example() Func Example() _GDIPlus_Startup() Local $hHBmp = _ScreenCapture_Capture("") ;create a GDI bitmap by capturing my desktop Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI bitmap to GDI+ bitmap _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore Local $hBitmap_Scaled2 = _GDIPlus_ImageResize($hBitmap, @DesktopWidth / 1.5, @DesktopHeight / 1.5) ;resize image SaveBmp2JPG($hBitmap_Scaled2,'Test.jpg',99) ; ===> Saving to disk ?? _GDIPlus_Shutdown() EndFunc ;==>Example Func SaveBmp2JPG($Bitmap, $sSave , $iQuality) ;coded by UEZ 2013 If Not IsPtr($Bitmap) Then $Bitmap = _GDIPlus_ImageLoadFromFile($sFile) If @error Then Return SetError(1, 0, 0) EndIf Local $sCLSID = _GDIPlus_EncodersGetCLSID("JPG") Local $tParams = _GDIPlus_ParamInit(1) Local $tData = DllStructCreate("int Quality") Local $pData = DllStructGetPtr($tData) Local $pParams = DllStructGetPtr($tParams) DllStructSetData($tData, "Quality", $iQuality) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) If Not _GDIPlus_ImageSaveToFileEx($Bitmap, $sSave, $sCLSID, $pParams) Then Return SetError(2, 0, 0) Return True EndFunc  
    • ame1011
      By ame1011
      Hi,

      What I would like to accomplish is to take a screenshot and upload it to a remote php file via _winHTTP.

      Previously, we were taking the screenshots and saving them to a network folder.
      However, we would now like to alter this so that it posts the information instead through win http.

      Please see the following code sample (note it does NOT run, it's just for reference).


      $hbitmap = _ScreenCapture_Capture('', $iScreenCapDimensions[1] , $iScreenCapDimensions[2], $iScreenCapDimensions[3], $iScreenCapDimensions[4]) _SavehBitmapEx($hbitmap, 100000000, _WinAPI_GetSystemMetrics(78), _WinAPI_GetSystemMetrics(79)) Func _SavehBitmapEx($hbitmap, $iID, $iWidth, $iHeight) Local $save_result = true $bitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbitmap) $graphics = _GDIPlus_ImageGetGraphicsContext($bitmap) $resizedbitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $graphics) $graphics2 = _GDIPlus_ImageGetGraphicsContext($resizedbitmap) _GDIPLUS_GraphicsSetInterpolationMode($graphics2, $InterpolationModeHighQualityBicubic) _GDIPlus_GraphicsDrawImageRect($graphics2, $bitmap, 0, 0, $iWidth, $iHeight) ;;; - CODE THAT REQUIRES UPDATE Local $locImgFile = "C:\temp\" & _GetImageFolderPathFromId($iID, '') $save_result = _GDIPlus_ImageSaveToFile($resizedbitmap, $locImgFile) ;saves to temp file PostImage(_GetImageFolderPathFromId($iID, '/'), FileRead($locImgFile)) ;file reads image and uploads to http server FileDelete($locImgFile) ;deletes image when done ;;; - END CODE THAT REQUIRES UPDATE _GDIPlus_GraphicsDispose($graphics) _GDIPlus_GraphicsDispose($graphics2) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_BitmapDispose($resizedbitmap) return $save_result EndFunc ;==>_SavehBitmapEx Func _GetImageFolderPathFromId($id, $sep = '\') Local $aLastImageSplit $aLastImageSplit = StringSplit(String($id), '') $return = $aLastImageSplit[1] & $aLastImageSplit[2] & $aLastImageSplit[3] & $sep & _ $aLastImageSplit[4] & $aLastImageSplit[5] & $aLastImageSplit[6] & $sep & _ $aLastImageSplit[7] & $aLastImageSplit[8] & $aLastImageSplit[9] & $sep & _ $aLastImageSplit[10] & $aLastImageSplit[11] & $aLastImageSplit[12] & '.jpg' return $return EndFunc Func _GDIPlus_SaveImage2BinaryString($hBitmap, $iQuality = 100) ;coded by Andreik, modified by UEZ Local $sImgCLSID = _GDIPlus_EncodersGetCLSID("jpg") Local $tGUID = _WinAPI_GUIDFromString($sImgCLSID) Local $pEncoder = DllStructGetPtr($tGUID) Local $tParams = _GDIPlus_ParamInit(1) Local $tData = DllStructCreate("int Quality") DllStructSetData($tData, "Quality", $iQuality) ;quality 0-100 Local $pData = DllStructGetPtr($tData) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) Local $pParams = DllStructGetPtr($tParams) Local $hStream = DllCall("ole32.dll", "uint", "CreateStreamOnHGlobal", "ptr", 0, "bool", True, "ptr*", 0) ;http://msdn.microsoft.com/en-us/library/ms864401.aspx If @error Then Return SetError(1, 0, 0) $hStream = $hStream[3] DllCall($ghGDIPDll, "uint", "GdipSaveImageToStream", "ptr", $hBitmap, "ptr", $hStream, "ptr", $pEncoder, "ptr", $pParams) _GDIPlus_BitmapDispose($hBitmap) Local $hMemory = DllCall("ole32.dll", "uint", "GetHGlobalFromStream", "ptr", $hStream, "ptr*", 0) ;http://msdn.microsoft.com/en-us/library/aa911736.aspx If @error Then Return SetError(2, 0, 0) $hMemory = $hMemory[2] Local $iMemSize = _MemGlobalSize($hMemory) Local $pMem = _MemGlobalLock($hMemory) $tData = DllStructCreate("byte[" & $iMemSize & "]", $pMem) Local $bData = DllStructGetData($tData, 1) Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data;ptr") Local $aCall = DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221473(v=vs.85).aspx _MemGlobalFree($hMemory) Return $bData EndFunc ;==>_GDIPlus_SaveImage2BinaryString
      The above method works but I would like to change it.
      It saves a temp jpg, file reads it, uploads to server and deletes the temp file.

      I would like to utilize the "_GDIPlus_SaveImage2BinaryString" method instead rather than using a temp file.

      Changing:

      ;;; - CODE THAT REQUIRES UPDATE Local $locImgFile = "C:\temp\" & _GetImageFolderPathFromId($iID, '') $save_result = _GDIPlus_ImageSaveToFile($resizedbitmap, $locImgFile) ;saves to temp file PostImage(_GetImageFolderPathFromId($iID, '/'), FileRead($locImgFile)) ;file reads image and uploads to http server FileDelete($locImgFile) ;deletes image when done ;;; - END CODE THAT REQUIRES UPDATE
      To:

      ;;; - CODE THAT REQUIRES UPDATE PostImage(_GetImageFolderPathFromId($iID, '/'), _GDIPlus_SaveImage2BinaryString($resizedbitmap)) ;sends binary image to server directly ;;; - END CODE THAT REQUIRES UPDATE
      Does NOT work. Anyone have any ideas?

      Thanks in advance.