NexusFi: Find Your Edge


Home Menu

 





Sending a keyboard Command from a NinjaTrader Script


Discussion in NinjaTrader

Updated
    1. trending_up 2,065 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread

Sending a keyboard Command from a NinjaTrader Script

  #1 (permalink)
ECI Ed
Seminole, FL
 
Posts: 17 since Oct 2011
Thanks Given: 9
Thanks Received: 3

Would it be possible to send a keyboard command such as <PrintScreen> to the computer from within NinkaTrader script? Specifically, I'd like to save a copy of my charts at a trigger point using the Hot key in SnagIt. If so, can you please explain how and maybe provide some sample code?

There is another post on Big Mike's forum that suggests using:

SendKeys.Send("{PrintScreen}");

but when I tried this I got an error message on compile of:

The name 'SendKeys' does not exist in the current context.

Thanks

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Quant vue
Trading Reviews and Vendors
 
  #2 (permalink)
 
grankus's Avatar
 grankus 
Barcelona
 
Experience: Beginner
Platform: NinjaTrader 7
Trading: CL, TF
Posts: 8 since Aug 2012
Thanks Given: 5
Thanks Received: 0


Quoting 
...The name 'SendKeys' does not exist in the current context...

Did you finally find the solution?

Reply With Quote
  #3 (permalink)
 
devdas's Avatar
 devdas 
Al,India
 
Experience: Advanced
Platform: NinjaTrader
Broker: Z
Trading: NiftyFuture
Posts: 1,562 since Feb 2010
Thanks Given: 1,513
Thanks Received: 1,701



ECI Ed View Post
....... Specifically, I'd like to save a copy of my charts at a trigger point using the Hot key in SnagIt. If so, can you please explain how and maybe provide some sample code?

There is another post on Big Mike's forum that suggests using:

SendKeys.Send("{PrintScreen}");

but when I tried this I got an error message on compile of:

The name 'SendKeys' does not exist in the current context.

Thanks

SendKeys.Send will work with a listener , here it should be SnagIt.

You have to send keys to SnagIt from NT.

For that perhaps i only know some dirty methods of Dll import like this,

 
Code
using System.Threading;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Text;
using System.Linq;

[DllImport("user32.dll",EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string lp1,string lp2);

[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetForegroundWindow(IntPtr hWnd);


private void trigger_function()
		{
			IntPtr handle = FindWindow(null, "SnagIt");      // handle for SnagIt
			 
				if(!handle.Equals(IntPtr.Zero))
				{
					if(SetForegroundWindow(handle))
					{
						
						SendKeys.SendWait("Key combo for print in SnagIt");
						
						SendKeys.Flush();
					}
					else Print("Failed In");
					
				}
				else Print("Failed Out"+handle.ToString());
				
		}
I have exampled above code snap from my own different key thrower script, you have to take care of key combos
that are accepted in SnagIt.

OTOH, just for saving your chart, there are other esay way you can use, just look some tools from @vvhg

Harvest The Moon
Nest The Market
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on November 4, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts