Way to move mouse pointer and generate a mouse click from a MT4 MQL4 expert adviser? - mql4

I need to move the mouse pointer and generate a mouse click from a MT4 MQL4 expert adviser, is this possible and if so how? Wondering if a DLL plugin or some external library might be necessary. Platform is Windows. Thanks

Related

How to simulate touch with left mousebutton

I'm developing a Firemonkey Application wich should run on Windows with touchscreen.
Because I have no touchscreen for my development system, I can't test the behavior of some controls. For example the panning in a TListbox doesn't work with the mouse-button. It only works if ssTouch in KeyState is set.
Is there a way to simulate the touch via the mouse?
Regards,
Michael
Well, aside from the obvious answer (save up and get that touchscreen!), there are some solutions, but they might be a bit involved.
If I wanted to do this on PC, I would start by making a copy of the Firemonkey source code and including it in my project.
After checking to see that your 'local' copy of Firemonkey is compiling properly, you will have to edit this file: "FMX.Platform.Win.pas". Open this file and then search for "ssTouch".
Inside of the WM_LBUTTONDOWN handler, there must be some logic which determines whether "ssTouch" is part of the KeyState or not. Add it in yourself, and then the left button should be evaluated as a touch input.

Is it possible to invoke refactoring from the Open Tools API?

The Delphi IDE has a plugin system, the Open Tools API. The IDE also has a number of refactorings available, such as a rename refactoring to rename a field, method, etc - an identifier.
Is it possible to invoke this, or any, refactorings from the OTAPI? If not, is there a hacky way to do it?
My research shows no mentions of refactorings in ToolsAPI.pas, but I don't want to give up with "No." It doesn't mean there isn't a way to do it - it just means I don't know what it is :)
There is no support at all from OTA. Therefore your only hope is to hunt down the menu items or actions, invoke their OnClick or OnExecute handlers, poke values into the dialogs that are shown, and then programmatically press the dialog OK buttons.

REPL for Delphi IDE?

http://en.wikipedia.org/wiki/REPL Read–eval–print_loop
Is there such a thing for Delphi ?
It would be rather useful to explore DLLs such as Windows APi and sketch their usage, when dealing with border cases scarcely documented.
I tried pascal scripts, such as one in Cnwizards, but it is much less comfortable.
For example it cannot use units like Windows.pas and you had to make some strange stubs of your own for it.
And anyway, those scripts are less easy to use for "try this try that" scenario than Repl.
For Delphi objects most clsoe thing it to pause on breakpoint and use Evaluate/Modify window, but it only works with Delphi objects, not DLLs; it cannot make temporary vars to cache values and such.
It's not really what you're looking for, because Delphi is a statically typed, compiled language, but if you really insist on being able to type some pascal in and see if it does anything, you can try the TJvInterpreter component that comes in the Jedi VCL.
Note that the experience is nothing like using python. You can't just type "uses module" and hit enter, because pascal units must be complete before they can even be interpreted by JvInterpreter, and the JvInterpreter needs you to write a wrapper for every single other unit you want to import. You would go crazy. I'm not seriously advising anybody to try to build a REPL around TJvInterpreter.
The "interactive magic" element of Delphi is called the "designtime environment" and the way we build using "components". We don't even do that bit by writing code much, we do it all visually with our mouse and keyboard. It's called RAD (rapid application development) and is powered by the VCL (visual component library) in Delphi, and (like REPL) is one of the many ways of doing very-rapid development.
The other thing we have that is a lot like a REPL is this button in Delphi:
You click it, after creating a new empty project, and whatever code you added to your new empty project is built and running in less than a second. Close enough to a REPL for me. It's kind of like binary executable instant bliss.
Write one line. Build and run (1 second). Instant.

How to test labels in QTP

I'm using QTP 9.5 test my application written in
Delphi. I got Delphi Add-in installed and QTP
can identify Delphi controls. Most but not all,
specially TLabel. QTP can not recognize this
control and is being ignored by Object Spy.
Any suggestion, tip, clues how to test labels ?
cheers !
Have you tried with TStaticText instead of TLabel?
They are Labels with a Window Handle (descending from TWinControl instead of TGraphicControl) which means they can get Windows messages from the outside.
I'm guessing that it's your problem. (only a guess as I don't know QTP)
It can detect controls like TSpeedButton? If not, this can be a sign that Qtp cannot detect controls that descend from TGraphicControl and therefore doesn't have a window handle.
You may be able to write your own Delphi extender for QTP to handle this. There should be a pdf in your QTP install path: C:\Program Files\HP\QuickTest Professional\help\Extensibility\DelphiExtensibility.chm and DelphiExtensibility.pdf.
If you still have to test it "as is" you probably have to go a more hard-coded way addressing the parent of those controls.
A window object in QTP through its methods allows finding a rectangular area containing the text, or clicking on a text found.
If it's an area on the screen with the big amount of labels you can dump a whole screen to the text file and go with the text file comparison. You can also normalize text retrieved before doing comparison.
This approach is less robust but you can improve it if calculating rectangles dynamically, without hard-coding points wherever possible.

How to temporarily turn off "snap-to" (anything) in Delphi IDE /visual designer (D2007)

Every once in a while this drives me crazy: I want to move a control to some precise location, WITHOUT any kind of "snapping" -- snap-to-grid, snap-to-guidelines, snap-to-border, etc... and Delphi won't let me. Is there a key combination that one can use while dragging to temporarily turn off any and all "snapping"? I seem to recall it being available in D6, but can't for the life of me find a similar combination in D2007, short of going into Tools -> Options, etc... (which kind of defeats the purpose).
Drag with the Alt key down to disable snapping to the grid. Snapping to objects will remain in effect. You can use Ctrl with the arrow keys to move one pixel at a time. You can also type the desired coordinates into the Object Inspector.
In Delphi 2009 CodeGear has changed the behavior of ALT+Move to also disable the designer guide lines. But in Delphi 2007 this feature can't be turned off without an external tool.
On of those tools (and I think the only that can do this) is the DDevExtensions 1.6 IDE plugin that adds this ability to ALT+Move for Delphi 2007.

Resources