Replace mouse click for function key in Gimp - gimp

Is there a way to setup Gimp to use a held key (e.g control or alt) to do the same as mouse click?

The general answer is no.
There are some mouse clicks in the tool boxes and editor dialogs which change parameters (like brush size) - these are mapped as "actions" inside GIMP and you can create keyboard shortcuts for them (including using the F keys) under Edit->Preferences->Interface->Edit Keyboard Shortcuts...
But probably that is not what you want - the main mouse button-click effect in GIMP is stroking the image with a paint tool - and that is wired in a different way inside the program: it can't be replaced by a keypress.
However, there are different painting devices that can be used that might serve your needs - a graphics tablet like those sold by Wacon provide a fundamentally different interface than mouse not just for GIMP, but for all drawing programs.
And GIMP is somewhat a unique program that can actually make use of a MIDI controler
(like a MIDI foot controller) to control the pressure of the painting - so, if your problem is getting rid of the "click and hold" action for painting with the mouse, a proper configured such peripheral could serve you.
That said, this question would be ontopic for https://graphicdesign.stackexchange.com/ and is offtopic here - I hope someone can move both the question and this answer there.

If GIMP does not allow such function. I have a suggestion, if you are using Ubuntu you can enable mouse control by numeric keypad as explained here. After enabling mouse control by numeric keypad you must turn Num Lock ON and press the key 5 to simulate a mouse click.

One workaround I use is to rebind an unused key to left mouse button, through macro or some other method.

Related

Delphi - identify mouse click source (hardware vs virtual click)

This time something what I had troubles to find title for...
I'm using windows hooks ( TMOUSEHOOKSTRUCT ~ WH_MOUSE ) to follow mouse movements and mouse button clicks...
This all works fine, however, I want to know whether is there a way to determine the mouse move/click source?
Either if it's possible to identify it by either device ID, or maybe source type (mouse, trackball, touchscreen...), or at least if it was sent from hardware source at all (aka, was it hardware or some mouse recorder macro, or other app's "SetCursor" procedure).
The main goal I'm looking for here is to find a way to block the ability to use mouse recorder to make clicks inside my app (so while in focus, I'd start a mouse hook and in case the move / click was made by software, I'd ignore any actions made..)
This could be asked as "How to block mouse recorder macros in my app" but I'd rather see an actual solution to identify the source as well (and as primary answer), as it might have other uses too.
Thanks.
Edit:
One way would be to check whether the mouse movement was made on snap or slowly (like actually moving the mouse). However, here then the problem persists with touchscreens.
Though, on the other hand - Windows does detect when touch was used (cursor is changed for the dot onscreen), so there surely is a way to at least separate mouse from touch events -> and knowing that would already solve a lot, combined to decline snap-actions on mouse only...
Raymond Chen summed it up in this blog post
There's no point discussing the possibility that the sender of the message is playing tricks and lying to you because (1) your program should just go along with the ruse and respond to fake [menu] messages as if they were real [menu] messages, because (2) there's no way to tell that you're being lied to anyway.
And this blog post of his shows that all input ultimately goes through the same queue, so even Windows does not know the difference between real input and simulated input.
You should look into using the Raw Input API to receive WM_INPUT messages directly from hardware. SetCursor(), SendInput(), macro players, etc cannot simulate those messages. And you would be able to differentiate between input from different devices, but not necessary the type of mouse if multiple mouse devices are being used. Although, since a trackball might have more capabilities than a standard mouse, it might represent itself as a HID device instead of a mouse device.
As for touchscreens, that type of input generates WM_TOUCH messages, which cannot be simulated, either.
So, between WM_INPUT and WM_TOUCH, you can differentiate between hardware mouse input and touchscreen input, at least. Beyond that, simulated input is going to generate standard WM_MOUSE... and WM_(L|M|R|X)BUTTON... messages, which cannot differentiate between hardware input and simulated input, not even in lower-level mouse hooks. You would probably need to keep track of the WM_INPUT/WM_TOUCH messages and match them up to the other messages, and if you cannot find a match then assume input is being simulated.

Delphi - Activating the Hint from another control of Application

I'm trying to activate Hint from control of different application created from delphi upon focus, I'm using hook to identify the focused control, and then use WM_MOUSEMOVE, which I think will activate the Hint of that control, the handle would be the Control itself and the lParam is the Left and Top of the Control. The Control activate the OnMouseMove Event, but the Hint never shows. but when I use SetCursorPos, Hint show, but I need to show the Hint with out the cursor move on that Control. Can you please help me with this? Thank you in advance... by the way I'm using Delphi XE4
Among the really asked question is how to show the hint of a control that resides on another application (i am afraid without hook that application can not be done), the title is "Delphi - Activating the Hint from another control of Application".
First is first: That can be done without knowing what language the other app was done, but it is very complex to put it here (and i am not an expert on such way of coding, also i hate apps that work that way).
Second: The main idea is to hook the other application, search on Google some code of that apps, that can show you a rectangular hole square of the object the mouse is passing over, that application while doing it is iconized (i do not remember the name of it).
Waht such app does: As you move the mouse over the screen it overlays a rectangular over the control that mouse is over, then if you press the key to print screen, that small region is the only thing that goes to clipboard; on of such apps i saw had an extra funcion, they can move such controls if you press cursors on keyboard, also can hide/enable/disable such control... more, it can also make controls that are invisible to be visible, etc... i saw it working on my computer, and hey, for fun it is pretty and to DeBug or get extra things on some apps is also great (make some menĂºs to be visible and enabled and then can use such funtions).
Please, please, understand i am agaist piracy and also against using such apps to let code to be run... some apps need pay for letting some menus enabled, but they have the code there, no need to change EXE to have/use that menus; just using this kind of apps makes that limited apps to be unlimited (just enable or show hidden menus and voila).
Note: To unhide menus, mouse point is not needed to be over the app, can be anywhere and is not moved.
The idea i want to say is: Any app can move, alter any control on any other app (at least on Windows) that is running, so maybe there can be a way to show such hint.
In the past i had use such app (sorry i do not remember the name) for DeBug my own apps, so i do not need to recompile in such cases where something was wrongly hidden, also work with buttons, labels, texts, combos, memos, etc.
Now my small problem is: I just need exactly what title say, but i can not make it to work.
Must be:
Mouse position must be irrelevant (it also must be able to be outside the application)
Just when a button that has focus is pressed with keyboard (Space or Enter) or just after some code somewhere on my application, i want to show the Hint of a specific TEdit for a short period of time.
I did not get Hint to be shown; not unless mouse point is over such TEdit but i want/need mouse pointer to not be over it, neither it to jump to the TEdit.
Idea Conept for that Hint to be shown: After doing some code that changes something, show extra info associated.
Example:
A button with that loads a file using an open dialog, filename is put on a ReadOnly TEdit (so it let user copy the text, but not change it); i want extra info that i punt on .Hint of such TEdit to be shown inmediatly.
That hint use is for not overload window with a lot of fields (TLabels) for showing such file data.
Simple idea: such Hint shows TimeStamp and size of the selected file.
P.D.: Not much related (since i am trying with a normal plain text hint), but hints can also store a full HTML page and with 3rd party tools be shown as an HTMLhint, so they can show a lot info of that file (also its content, etc) in a web based format; as i say i first try with standard plain text hints.
In order to show hint programatically you need to call TApplications ActivateHint method to which you specify the position parameter.
http://docwiki.embarcadero.com/Libraries/XE3/en/Vcl.Forms.TApplication.ActivateHint
Based on position parameter Application automatically finds which controll is at that position and shows its hint.
NOTE: Position parameter screen coordinates in pixels and not your controll coordinates. So you will have to use ClientToScreen method to change your coordinates apropriately.
You can see simple example of how to use this here: https://stackoverflow.com/a/15031208/3636228
Now if you need to do this from another application then you will have to add some comunication mechanizm to these two application so that one could send a proper message to tell the other to show the hint at specific position. But this does require you to be able to change both applications.
EDIT: This works with VCL applications but I'm not sure if it would work with FireMonkey applications.

Custom Dock in Gimp

In GIMP: is there a way how to make my own custom dock (toolbar) where a could put my most used functions?
Something like this:
Create new empty dock or toolbar
Somehow set what functions will be in it
(any of the functions, no matter it has an icon or where in menus is located)
I'd like to have it so I don't have to search in menus every time I need something. I'm aware that I can make keyboard shortcuts but they are difficult to remember since I don't use Gimp every day. I'm used to this from Corel Photopaint and I think it is really useful.
Thanks for your suggestions.
In GIMP 2.8, you can only customize the dockable dialogs - by dragging then around, and in another level, customize tool presets and make use of the tags in the presets dialog to quckly access paint-modes with set brushes, gradients and painting dynamics - so, keeping the tool-presets dialog around, and appropriately using the tags can give you quick access to these settings.
You can't, however, add additional menu entries or icons to select particular plug-ins (filters) - and access those from any of the dockable dialogs. without rebuilding GIMP, you could edit the XML files at /usr/share/gimp/2.0/menus to customize your menus.
In the master branch, the unstable "GIMP 2.9" which will eventually become GIMP 2.10, there is a "search" action implemented, initiated by pressing the / character that will probably make it for the need to quickly find-out any operations wanted.

Using barcode scanner with Delphi

I'm developing a POS (pet project) and I'm thinking of adding a bar code scanner to capture the sales faster. I do not have a scanner at the moment with me, and would like to ask some questions, as I'm stuck a bit.
On the sales screen my initial idea was to have an TEdit component and when a person scans the product it would fill the TEdit with the string. Now the problem I'm encountering is that I want to make the TEdit invisible so that the person does not see it. But once you make the TEdit invisible, you cannot set focus on it, so that plan cannot work.
So can anyone suggest what I can use to "capture" the scanned string? How would I make the component to listen and wait for the scanner? I assume that the scanner would be like a normal keyboard event, like button down or up.
There's KeyPreview property on TForm. Set it to true, so all key presses are processed by form first before controls.
Article about keyboard processing in Delphi: http://delphi.about.com/od/objectpascalide/a/keyboard_events.htm
Related SO question: How does Delphi's KeyPreview work?
What I have done is use the KeyPreview to monitor for a function key like F9 which the bar code scanner is set to prefix scans with. When this is received, I pop up a dialog with a single edit box and OK button. This then receives the rest of the barcode information, and the scanner ends the entry with the Enter key. I can then determine the purpose of the scanned data (in my case, one type starts with a prefix) and then put the data into the appropriate field on my main form.
I chose F9 because it seems inert in most applications, so you can use the scanner in other ways, but I support other keys too for flexibility. My application also has a scanner test mode where it shows the keys sent.
You can use a TEdit with a height and width of 0 so it won't appears and make sure it get focused when you scan your barcode.
You can also place the TEdit outside of the visible window, setting the component's Top and Left properties to something like -50. You can then set focus to it just like a regular visible TEdit box, but it will be invisible to the user.

How to tell what device triggered a particular event in Delphi?

I'm wondering if there's an easy way to tell which input device triggered a particular GUI event.
For example: A TButton.OnClick event gets fired. Did the user trigger it with a keyboard press (shortcut, Enter key for default button, space key for a focused button, etc.) or was it triggered with a mouse click? Is there any easy way to tell?
The reason I'd like to know is so that I can implement keyboard usage hints into some of our applications when the user uses the mouse to initiate actions that could also be done with the keyboard. Our systems on the shop floor are in pretty dusty/dirty environments, and mice tend to not hold up so well in them. Also, in many cases, there's simply not that much room for a mouse to be used. (No, keyboards without numeric keypads is not a solution. They're relied on too heavily.)
However, since our apps run in Windows, users tend to simply use the programs like they would at home -- with a mouse. There's nothing particularly wrong with that, but we've worked hard to optimize the input workflow to be keyboard friendly as well. It'd be nice if there was a low-impact way to indicate to our users that there's a way for them to do the things they're doing without having to grab the mouse.
There's no way to tell from within OnClick. However, you can also attach events to a control that will fire when the mouse rolls over it, which would probably be more appropriate for what you're trying to do anyway. Take a look at the OnMouseEnter and OnMouseLeave events. Also, if you really want something specific to happen when the mouse is clicked, you can attach it to OnMouseUp.

Resources