AutoHotkey background clicking and typing - background

I'm trying to use AutoHotkey to do some background clicking and typing while I'm doing other stuff in the foreground.
I've gotten used to Send but I haven't figured out how ControlSend works yet. Can anyone give me an example using something simple like MSPaint in the background and changing the color of paint.
Is this even possible to do? I have a script currently that pulls from daily Excel report, assigns each row a variable and punches it into another program, but I need it to click and type some canned messages as well.

The first question should probably be why use mouse control? Keyboard control is sooo much easier and often more reliable. What is it that you try to do with a mouseclick that can't be done through keyboard commands?
Also mouse clicks normally activate the hidden app.
OK you wanted an example...
+Home:: ;Shift + Home = stop/start radio
SetControlDelay -1
ControlClick, x384 y143, Radioplayer
Return
Here i click on the play/pause button of a streaming radioplayer. The mouse coordinates are found with the aforementioned Windows Spy and the title of the browser (you might have to use SetTitleMatchMode). Why not look at the AutoHotKey Command list and check out the examples there....

Let me know if this is (roughly) what you are looking for....
SendMode Input ; Recommended for new scripts
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 2 ; A window's title can contain the text anywhere
!F1:: ; Press Alt F1 to execute
IfWinExist, Microsoft Excel
{
ControlSend ,, 1000{Enter}{Down}, Microsoft Excel
}
return

Here is some code I used to first record the mouse position (relative mouse position did not work since the window was tiled and the click position could be changed by moving the tiles). Immediately after that I click the mouse at the recorded position (and redo this later on in the code as well).
SplashTextOn, 200, 100, Script Preparations, Please Click on the Person `"Search Term`" link (1) in SAP. ; Show new instructions to the user
WinMove, Script Preparations,, (A_ScreenWidth/2)-150, (A_ScreenHeight/2)-200 ; Move the text instructions window with the name "Script Preparations" 150 pixels right of the center of the screen and 200 pixels up SoundBeep 600, 300 ; Wake up user
; From here on the left mouse button will temporarily be disabled
Hotkey, LButton, on ; Turn Left Mouse Button OFF, to capture the Mouse click
KeyWait, LButton, D ; Wait for LeftMouseButton click Down
MouseGetPos, xposS ,yposS ; Store the position where the mouse was clicked (Search Box)
MouseClick, left, %xposS% ,%yposS% ; Perform the mouse click on the captured mouse location
Hope this helps.
In your situation, I assume that you only need to determine the mouse position with Window Spy.

Related

How can I move focus from the Quick Documentation pop-up back to the Code completion pop-up without using the mouse?

Context:
When a code completion pop-up (Ctrl+Space) appears I often need to have a look at docs for each individual method / constant / etc). The IDE is set to show the Quick Documentation pop-up for a highlighted suggestion automatically after a small delay. Sometimes the documentation is too big and I need to jump to the Quick Documentation pop-up in order to be able to scroll down through it.
Using the mouse I can click on the documentation pop-up and scroll using the mouse wheel. When I'm done reading the documents I can click on the code completion pop-up to explore other suggestions.
My problem is that once the Quick Documentation pop-up is in focus, I haven't found a way to move the focus back to the code completion pop-up without using the mouse.
While I can move focus from the code completion to the quick documentation pop-up by pressing Ctrl+Q, and then use the arrow keys to "scroll" through the documentation, I haven't found a shortcut to return the focus to the code completion pop-up.
What I've tried to far:
Esc closes both pop-ups
Pressing Ctrl+Q a second time opens the docs on a tool window
Any insights on how I can close the Quick Documentation pop-up or move the focus back to the code completion pop-up in such a way that preserves the suggestion that I have previously highlighted?
This seems to be a bug in IntelliJ IDEA . Feel free to add your use-case at https://youtrack.jetbrains.com/issue/IDEA-168388
Here is a workaround that could be used for the time being:
Open Documentation as a Tool Window:
Add keyboard shortcut to focus documentation window from anywhere:
When the completion popup appears, focus documentation tool window by the shortcut from [2] and scroll it
Press Esc to unfocus documentation tool window and focus completion popup

IntelliJ - Debug info window shortcut?

In IntelliJ, when a breakpoint suspends an a program.. If I hover over a variable with the mouse cursor and wait for a second or two, a tooltip appears, which lets me inspect the variable by clicking the + sign. For example in the below image, I kept my mouse cursor over three for a second or two and the tooltip saying Main$Die#452 appeared.
Is there a way to show this tooltip only by using the keyboard and the current cursor location? In other words, in the screenshot above, how would I see the tooltip for the variable one (where my keyboard cursor is) without moving the mouse cursor over the variable one? (And how would I expand it once I see the tooltip?)
While debugging code, I realized I end up inspecting objects like this very often and moving around the mouse and waiting for the tooltip to appear starts to slow down the process a little.
The action is called "Quick evaluate expression":
You can invoke it via alt+⌘+F8 on macOS, or ctrl+alt+F8 on Windows

Simulate mouse presses (BUTTON 4 and 5)

I'm trying to create a single file in BAT (Windows Command Prompt) to simulate a Mouse Back and Mouse Forward event (which is in fact just pressing down mouse button 4 and 5). I can't find anything on the internet on how to simulate these exact events. Most of them are about clicking the left mouse button but that's not what I need.
The program should be as simple as possible as I do not want heavy coding on this one. It should be straight forward and I hope one of you could help me out. Is this even possible (with BAT)?
The reason for this is that Logitech Gaming Software wrongly executes the back and forward buttons' up event twice, which results in annoying behaviours while for example browsing a webpage and trying to go back one page. It would then go back two pages.
Ok, I've been a little too quick with my question but it might help others. If you have the problem of your Logitech mouse doing double forward or backwards on browsers (Chrome, IE etc.) and in Windows Explorer please try the following.
First of all, you'll want to remove the currently mapped buttons. Be sure to select the desired profile first! So go over all three buttons (MOUSE 3, MOUSE 4 and MOUSE 5 (middle, tilt left, tilt right)) and remove their current mapping. By default (generic buttons) it will be "Middle click", "Back" and "Forward".
Now right click the profile at the top and select "Scripting". This is open a new window in which we can do some very advanced but still easy coding. Clear the whole thing and paste the code you find below in there. Press "Script" >> "Save" at the top of the window to save it and enjoy the working glory! You can easely test this by right clicking the profile again and selecting "Test profile". Now press any of the three buttons and you should get the outcome we want (down and up event only once on those exact buttons).
If you want to do some coding of your own feel free to change the script! The actual numbers to each mouse button can be found by clicking "Help" >> "Scripting API" at the top, along with some handy documentation. Keep in mind that you'll have to do this for every profile you desire. Doing this on the Default Profile seems the most reasonable for browsing.
function OnEvent(event, arg)
if (event == "MOUSE_BUTTON_PRESSED" and arg == 4) then
OutputLogMessage("Pressing back button\n");
PressAndReleaseMouseButton(4);
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == 5) then
OutputLogMessage("Pressing forward button\n");
PressAndReleaseMouseButton(5);
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == 3) then
OutputLogMessage("Pressing middle button...\n");
PressAndReleaseMouseButton(2);
end
--OutputLogMessage("event = %s, arg = %s\n", event, arg);
end

Mouse button hotkeys only work once, not continual

I need to make an AutoHotkey script that performs some action when and while the mouse button is pressed, then finishes when the mouse button is released.
For (a very simplified) example:
LButton::
MouseGetPos x,y
MsgBox %x%-%y%
LButton Up::MsgBox Foobar
Replacing the LButton with a keyboard key (e.g., LWin) makes it work correctly and moving the mouse cursor updates as expected while the key is held down, but using the mouse button only performs the LButton action one time. I need the hotkey action to continue occurring until the button is no longer being held.
After a bunch of query-term tweaking, I found a page that gives sample scripts for autofire.
I wasn’t sure that was what I wanted (even though it made sense) because as I said, the sample script already works just fine for keys, but I gave it a shot anyway. I tweaked the sample a bit and now it works as desired. (Actually, it is very similar to a solution I had already been using, but now it absorbs the button event, which solves the underlying problem that I led me to trying the aforementioned script.)
Hopefully I picked good keywords in this post so that anyone else who finds themselves in the same situation can find the/a solution faster than I did.
#SingleInstance,force
CoordMode, Mouse, Screen
LButton::
While GetKeyState("LButton","p") {
MouseGetPos x,y
Tooltip %x%/%y%
Sleep 75
}
return
LButton Up::
Tooltip Foobar
return

How can i take snapshot of command prompt window in full screen mode

I need to take snapshot if command prompt window running in full screen mode.
I had tried it using PrintScreen,Ctrl+PrintScreen, Ctrl+Alt+PrintScreen button(s) but nothing seems to work
Also are there any reasons that the print screen button does not work in full screen commandprompt mode? After all, it does for all windows under normal conditions.
Abdul Khaliq
In full screen mode all you have is text. There is no graphical `rendering' as such. If you can capture the text, it is enough ... though you can always reconstruct a png image later from the text (if you really have to get an image out of it).
Why don't you just use an external screen shot software?
There's many, e.g. greenshot, which is free (is in speech and beer :-)).
did you try alt + print screen?
Click any window except the command window and then hit PrtScrn.
First off all open cmd in full screen mode then click on print screen button after that open paint brush and press ctrl+v (past) you can save it in any where, where ever you want (file type should be .png).
I wasn't able to find any of these replies that work, and I can't install unapproved software do to IT policies. Here is what I did:
Right click inside command window. Hit select all. Right click outside of window (on top bar close to the maximize minimize controls. Select edit; select copy. Open a notepad window and paste. The advantage here is you have text that can be copied and pasted back into a command window later. I hope this helps.
press ctrl+a //select all
press ctrl+c // copy all text
write notepad mytext.txt + press entet // open notepad
press ctrl+v //paste in text in notepad
press ctrl+s // Save file
press ctrl+w // Close notepad.