FredMP Posted August 22, 2020 Share Posted August 22, 2020 Hello! I am new to the forums but am interested in what AutoIt has to offer. Ok, so I have a challenging ask for anyone that would like to help. In my TOS Java stock trading program, I have two monitors open. On the left monitor I have a 2x2 grid with a total of 6 charts. Each CELL in the grid has a ticker text box at top left populated with a ticker (i.e. STOCK3) On the right monitor I have my MAIN window with order flow and that's where orders are executed. This window also has a ticker text box at top left to type in a ticker. TOS refers to this as the "symbol entry" or "symbol selector" box. Here is the workflow I'd like to have in place: 1. I hover the cursor on any CELL in 2x2 grid (let's say CELL 3) 2. Trigger: Hotkey 3. Action: Send ticker (STOCK3) in top left of CELL 3 to MAIN window ticker box and press return. I know that "move mouse" commands are generally a last resort so I'd like to get this done with a script. This is a Java program. There is also a right click menu in TOS that accomplishes this workflow that could perhaps be scripted to a hotkey trigger. It goes like this: 1. Click on "Symbol Actions Icon" 2. Mouse over "Send STOCK3 to" 3. Click on [3] BLUE (this is the MAIN window ticker box) I have included pictures to better illustrate the desired workflow automation: Any ideas on how to map this workflow to a hotkey? I really don't know much about writing scripts but if AutoIt can do it I would download the app for sure! Lots of other automation to do as well. Thanks in advance. Link to comment Share on other sites More sharing options...
faustf Posted August 23, 2020 Share Posted August 23, 2020 but you wanna use autoit in mac ? Link to comment Share on other sites More sharing options...
FredMP Posted August 23, 2020 Author Share Posted August 23, 2020 Hey there! No, I would be using AutoIt in Windows 10 pro 64 bit. I just made the screenshots for my post on a mac. Sorry for the confusion! Link to comment Share on other sites More sharing options...
faustf Posted August 23, 2020 Share Posted August 23, 2020 ok but with au3info tool ??? return somthing ??? Link to comment Share on other sites More sharing options...
FredMP Posted August 23, 2020 Author Share Posted August 23, 2020 I am not sure how to answer that. I need my posted workflow mapped to a hotkey. Java app. Link to comment Share on other sites More sharing options...
Danp2 Posted August 23, 2020 Share Posted August 23, 2020 You will likely need to use UI Automation. faustf 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Champak Posted August 25, 2020 Share Posted August 25, 2020 I would suggest not to setup hotkeys to interact with thinkorswim. It's bad enough when it takes a while for your order to hit the market, now you are planning on having an external program interact with it? You hit your hotkey and think it didn't register then hit it again and you are positioned for an amount you didn't expect or want. Or, the hotkey doesn't execute fast enough and you lost money. I thought of doing the same thing but reconsidered....just my 2cents. Stick with thinkorswims hotkeys, or use a different broker with an app with more extensive hotkeys. Good luck. What Faustf is asking is if you downloaded Scite yet and used the au3info located under tools menu. When you use that, you hover the mouse over windows or controls and it tells you information about what you are looking at to interface. Link to comment Share on other sites More sharing options...
FredMP Posted August 27, 2020 Author Share Posted August 27, 2020 Hello, thanks for chiming in! If you read over my posted workflow I would not be using a hotkey to enter an order. I agree with you there, probably not the best idea. The hotkey trigger would send the ticker to the main window and press enter and that's it. From that point I would be manually placing an order with the platform's hotkey. It would simply be a quick way to send a ticker to the active window. I hope I'm not breaking any forum rules, I could not find any on the subject but I am willing to pay anyone who can provide me with a working script for this if someone would like to help. I simply do not have the time right now but I could really use the functionality. Seems to be doable, with just a few actions in the workflow. I work in IT so any instructions you would have me do, i.e. installing, troubleshooting, etc. I would have no problem doing. As a sidenote, you can download TOS papermoney which is free to use for testing and should have the same interface/menus that I would be using. https://platform.thinkorswim.com/platform/index.html#!/pmregister Pm me if anyone can help, thanks. Link to comment Share on other sites More sharing options...
faustf Posted August 28, 2020 Share Posted August 28, 2020 try to use this https://joel-costigliola.github.io/assertj/assertj-swing-lookup.html Link to comment Share on other sites More sharing options...
robertocm Posted August 28, 2020 Share Posted August 28, 2020 19 hours ago, FredMP said: I simply do not have the time Just a reference for a simple approach: i'm using something like this with RemoteApps: expandcollapse popup#AutoIt3Wrapper_UseX64=n ; In order for the x86 DLLs to work #include "OpenCV-Match_UDF.au3" Opt('WinWaitDelay', 250) Opt('WinDetectHiddenText', 1) Opt('MouseCoordMode', 1) Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Opt("SendKeyDelay", 50) Opt("SendKeyDownDelay", Default) Opt("SendCapslockMode", 1) Opt("MustDeclareVars", 1) ;needed for Windows Task Scheduler: "Failed loading DLLs" FileChangeDir(@ScriptDir) ;Pauses execution of the script until the requested window exists ;Help. Window Titles and Text (Advanced): When you use a window handle for the title parameter[s] then the text parameter[s are] completely ignored. Global $sTit = "Some Title", $sTxt = "" Global $hWnd = WinWait($sTit, $sTxt, 20) ;You can use the WinActive() function to check if WinActivate() succeeded. If Not WinActive($hWnd, $sTxt) Then WinActivate($hWnd, $sTxt) If WinWaitActive($hWnd, $sTxt, 10) = 0 Then MsgBox(0, "Error", "Window not active:" & $sTit, 4) ;_FileWriteLog($hFile, "WinWaitActive TimeOut: " & $sTit) ;Global $hActive = WinGetHandle("[active]") $sTit = WinGetTitle("[active]") MsgBox(0, "Error", "[active] " & $sTit, 4) Exit Else WinSetState($hWnd, "", @SW_MAXIMIZE) ;_FileWriteLog($hFile, "WinWaitActive OK: " & $sTit) EndIf Sleep(1000) _OpenCV_Startup();loads opencv DLLs _OpenCV_EnableLogging(True,True,True) ;Logs matches, errors in a log file and autoit console output. ;Please note that these examples might not work as the match pictures have to be found with the exact same size on your screen. Global $sCoords[4] = [32, 131, 59,146] Global $Match1 = _MatchPicture(@ScriptDir & "\Match\test_01.png", 0.70, $sCoords, 10, 1000);Try to find the match picture on the screen. Number of tries: 10, Sleep between each try: 500ms. If Not @error Then _MarkMatch($Match1) ;Debugging: Draws a rect on the screen/coordinates of the match to show the user where the match was found Sleep(100) _ClickMouse($Match1, "left",1) ;Calculates the center of the match and clicks the left mouse once on click position Sleep(1000) Else Exit EndIf Global $sCoords[4] = [340, 277, 353,290] Global $Match1 = _MatchPicture(@ScriptDir & "\Match\test_02.png", 0.70, $sCoords, 10, 1000);Try to find the match picture on the screen. Number of tries: 10, Sleep between each try: 500ms. If Not @error Then _MarkMatch($Match1) ;Debugging: Draws a rect on the screen/coordinates of the match to show the user where the match was found Sleep(100) _ClickMouse($Match1, "left",1) ;Calculates the center of the match and clicks the left mouse once on click position Sleep(500) Else Exit EndIf _OpenCV_Shutdown();Closes DLLs Link to comment Share on other sites More sharing options...
FredMP Posted August 28, 2020 Author Share Posted August 28, 2020 @faustf Would AssertJ work in tandem with AutoIt? @robertocm Could you elaborate on how I would do this? Quote So basically, all you need to do is provide a path to the match picture Someone else suggested using Microsoft UI Automation. So now I have 3 suggestions: AssertJ, OpenCV, and Microsoft UI Automation. Which one is more likely to work and would be easiest to set up? And then assuming I have picked an option, like say AssertJ, what are the steps? what do I need to download and run? Link to comment Share on other sites More sharing options...
robertocm Posted August 29, 2020 Share Posted August 29, 2020 Included in the .zip file, there is a folder called Snapshot-Tool Use the SnapshotTool.au3 script to save a png file As described by the udf author BBs19: On 2/8/2017 at 11:19 PM, BBs19 said: Includes a Snapshot-Tool that creates snapshots of a certain area(buttons, text etc.) on the screen and generates the code that is required for the matching. It can also be used to get the coordinates to a marked area on the screen in order to check only on a certain area for the match picture. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now