Access the MDI toolbar menu with AutoHotKey ControlSend - autohotkey

Automating a process that is being run on a RDP session, I have to use ControlSend, and not Send command in AutoHotKey.
The WindowSpy doesn't find any control on the MDI toolbar, and there are no shortkey to the menu item I want to access (Filter..). How may I open the toolbar and select the item?
I've tried
ControlSend, ahk_parent, {alt}, ahk_class FNWND3170 ;Open project folder in treeview
But with no success.
I've considered using AutoIT, but I don't think that would help as the AutoIt spy doesn't pick up the control either.

Sorry, but think of the RDP window (or even full screen) as an ever-evolving bitmap image. Your PC and autohotkey have no idea what is behind the picture. Can you run the ahk script in the remote pc itself? Keep in mind, the RDP client handles your mouseclicks and keyboard (and even voice) entirely by re-directing inputs, etc. So best bet is to do a mouse click in the appropriate spot by running a script from outside the window:
CoordMode, TargetType [, RelativeTo]
Click, 44, 55 ; Clicks the left mouse button once at coordinates 44, 55 (based on CoordMode).
Use the CoordMode "RelativeTo" flag to set to "Relative" so coordinates are relative to the active window. You may have to click twice, once to activate the RDP window and then to click at the mouse position.
See https://www.autohotkey.com/docs/commands/Click.htm and https://www.autohotkey.com/docs/commands/CoordMode.htm for info.
Hth,

Related

Autoit MouseClick - click does not work on Connection Bar in RDP window

I am trying to minimize RDP window by using Autoit mouse functions
First MouseMove to correct location -> hint "Minimize" appear
but then MouseClick (or mousedown, sleep, mouseup) seems do click "through" connection bar , as I see icon on desktop under the connection bar got focused.
I thought before, any mouse action "by hand" can be imitated , but I am stuck here...
To fix this problem, you need to do one of the following:
Run the program on the remote computer - then you can use the "standard" AutoIt functions
Run the program on the local computer, and analyze the remote image with ImageSearch UDF or OpenCV UDF and click in the selected point of screen.

Unsure why AHK script isn't working as intended

I use chrome bookmarks a lot, and I also often have to send people screen snippets very often, however I don't want all my bookmarks on display (some are sorta private). I know I could add them to the Other Bookmarks folder, but would rather easy access. What I've been doing for a while is hitting the bookmark shortcut (CTRL+SHIFT+B), then the snipping tool (WIN+SHIFT+S), taking my screenshot and then putting the Bookmarks back (CTRL+SHIFT+B). Eventually I decided to bite the bullet and spend some time automating it, so that hitting CTRL+SHIFT+S would close the Bookmark Bar, and letting go of the mouse (after taking the clipping) would put it back. This is what I came up with:
~#+s:: Send, ^+B
KeyWait, LButton, D
Send, ^+B
return
Although the first half works (Bookmarks go away, snipping tools open) at no point does the bar return. I've tried many things including setting up a timer, and waiting for the space bar instead of the mouse button, which i'd only hit when ready. I have also tested, and manually pressing the keys immediately after letting go the mouse button did indeed re-open the Bookmarks.
Would anyone be able to explain why this is happening? I would really appreciate any help!
First problem is that you put the first command on the same line as the hotkey definition.
This will create a one liner hotkey and the rest of the code below wont run.
Second problem is that you're sending the input to show bookmarks again while the screenshotting window is active. You're going to want to wait until chrome is active again.
This works:
#IfWinActive, ahk_exe chrome.exe
~#+s::
SendInput, ^+b
Sleep, 2000
WinWaitActive, ahk_exe chrome.exe
SendInput, ^+b
return
#IfWinActive
A bit of sleep so the screenshot window has time to open, and also added in #IfWinActive, because I'd assume you only want that hotkey to be active while you're on chrome.
Also switched over to SendInput and made the b lower case. Having it as uppercase would send Shift+B (on most keyboard layouts).

autohotkey ControlClick does not work on MS tools

I have a basic AHK script that I am trying to run on a MS tool SurfaceDiagnosticToolkit.exe. Trying to click any button does not work.
Steps followed,
start SurfaceDiagnosticToolkit.exe
select screen with title Microsoft Surface Diagnostic Toolkit (Fan Test 1/1)
run script below.
.
detectHiddenWindows, On;
WinActivate, Microsoft Surface Diagnostic Toolkit (Fan Test 1/1)
MouseMove,1255,1190
MouseClick,Left,1255,1190
The script will bring the window to the front, but the mouse does not move over the screen and the MouseClick does not fire.
Other AHK tools like WinMove also do not seem to work.
Interestingly this program shows a green fading bar going left to right on the toolbar icon similar to the copying files icon.
I have also tried with the same results
MouseMove, 1560, 40
Send {vk01sc000}

What's the difference between Send and ControlSend?

AutoHotkey's official documentation lists two different sets of commands for sending simulated keyboard input to a window.
Send / SendRaw / SendInput / SendPlay / SendEvent
Sends simulated keystrokes and mouse clicks to the active window.
ControlSend / ControlSendRaw
Sends simulated keystrokes to a window or control.
What's the difference between Send and ControlSend?
Is there a reason to use one over the other?
Send/SendXXX commands send input to the active window. That is the window that currently has focus, usually by clicking it with your mouse, tabbing to it, or when a window sets focus to itself.
If your AHK script were to target a Notepad window that you have open, and you were to click on another window such as Chrome, your inputs would now be sent to Chrome.
On the flipside, using ControlSend/ControlSendXXX commands will send input to a specified window or control. A control might be a textbox, button, or similar interactive elements.
Here, the above example would still output to Notepad even if you switched focus to another window such as Chrome. The downside is that you must specify which control to send to.

In notepad++ change tab size instantly

I'm using notepad++ (v6.5.3) and I constantly have to change the size of the tab for viewing some results. Not that it's taking me a lot of time to do it manually everytime, but it would be great if I could optimize that.
Is there a way to do so? Would a macro be the solution, or are they just for typing stuff?
Thanks a lot!
Ok, there's an easy way how you can achieve this - I have tested it right now:
Install AutoHotKey (or start portable version which runs without installation)
In Windows 7 and above, ensure you launched AutoHotKey as Administrator (otherwise you get inconsistencies in its behavior) - if not sure, exit it and restart it as administrator
Right click Autohotkey tray icon and select Edit This Script
Import the macro below this list at the end of the AutoHotKey script file and save the file
Right click Autohotkey tray icon and select Reload This Script.
–– This was end of general steps, now let's go with your macro: ––
In N++, display Preferences window and press its Close button1 at the bottom (NOT at the top-right corner)
Now you can use shortcuts Win+F2 and Win+F3 to switch different tab sizes instantly
SendMode Input
DetectHiddenWindows, On
SetTitleMatchMode, RegEx
;--------------------------------- Hotkeys for Notepad++ only
#IfWinActive ahk_class Notepad\+\+
#F2::Send {F10}{Right 6}{Down}{Enter}{Tab 2}{Space}16{Enter}{Tab 3}{Space}
#F3::Send {F10}{Right 6}{Down}{Enter}{Tab 2}{Space}4{Enter}{Tab 3}{Space}
#IfWinActive
1) Important: N++ user experience provided in dialog boxes is absolutely terrible. There are no anchors where you can fix focus when using keyboard. Thus you always need to perform step 4 manually when leaving Preferences dialog box otherwise the macros would send keys into incorect window page OR at correct page but incorrect control. Preferences dialog window remembers selected page and control. Macros I created for you therefore assume that correct page is already listed and button Close was recently focused.
Good news is Notepad++ windows with this weird behavior are rare exception from general user experience. In other places in N++ (or in other apps) where user interface components (menus, dialogs etc.) always start from the same point you do not need any special precautions like the one in step 4.
Adjust the macros as you like:
you can create more of them
you can adjust the numbers "16" and "4" typed into tab size input box
you can change shortcut keys to something else
you can replace sending keys with sending mouse clicks at desired screen/window positions
you can achieve many other useful shortcuts in N++ and in all other apps – check AHK deeper!