How to press "ALT+F4" using AutoIt [duplicate] - autoit

This question already has answers here:
How to press "Ctrl+Shift+Q" in AutoIt
(2 answers)
Closed 4 years ago.
I am new in AutoIt. I have run the notepad by using the following code in AutoIt:
Run("notepad.exe")
Now I want to quit the application by using "ALT+F4". How to press "ALT+F4" with AutoIt tool?

You'll want to check out the documentation for AutoIt - which is pretty good.
The one you're looking for is: https://www.autoitscript.com/autoit3/docs/functions/Send.htm
Keep in mind that you want to make sure that the window is active or that you're targeting the window.
With that, I recommend using this : https://www.autoitscript.com/autoit3/docs/functions/ControlSend.htm
ControlSend() works in a similar way to Send() but it can send key
strokes directly to a window/control, rather than just to the active
window.

The following code for pressing "ALT+F4" should work in AutoIt:
Send("{ALT down}{F4 down}{F4 up}{ALT up}")
OR,
Send("!{F4}")
OR,
Send("!{F4}", 0)

Related

How to assign a string to a keybinding in Sublime Text 4? [duplicate]

This question already has answers here:
Sublime Text: how to make shortcut for inserting text?
(4 answers)
Closed 1 year ago.
Is there a way to print something with the given keybinding in Sublime Text 4?
E. g. for the sake of R, I would like the alt+oem_minus and alt+- keybindings strokes to result in <-.
I understand that for whatever I want to do, I can record a macro and this would work just fine but this action is so trivial that I wonder whether I can do without macro.
I understand that there are probably language plugins and IDEs that include this feature by default, but the most apparent one, the R-IDE, doesn't seem to have it, and moreover, Sublime is just an editor for quick scripts, not a comprehensive IDE, I have to intention to aggravate the app with scripts I do not need.
Thank you in advance for any response!
Open Sublime Text, go to Preferences > Key Bindings and add this:
[
{
"keys": ["alt+keypad_minus", "alt+-"],
"command": "insert_snippet",
"args": {"contents": "<-"}
}
]
If you want to position the cursor after <-, you can do it via $0 like this:
"args": {"contents": "<- $0"}

How to scroll up in Vim buffer with R (using Nvim-R)

I'm a happy user of the Nvim-R plugin, but I cannot find out how to scroll up in the buffer window that the plugin opens with R. Say for instance that I have a large output in console, but I cannot see the top of it - how do I scroll up to see this? In tmux for instance there's a copy mode that quite handily lets you do this, but how is this done in the R buffer?
An example below where I'm very curious to see what's on the line above the one begining with "is.na(a)...". How can this be achieved?
I have scoured the documentation found here, but without luck.
The answer is apparently to use Ctrl+\ Ctrl+n according to this answer on the bugreports for NVim-R.
Here's what my output looks like when I output mtcars:
When I hit Ctrl+\ Ctrl+n, I can move the cursor and I get line numbers:
To get back to interactive, I just use i, the same way I normally would.
Apparently, if you are using neovim, then you can add let R_esc_term = 0 in your ~/.vimrc file and you can then use the escape key, but if you don't use neovim, you are stuck using the two ctrl commands ¯\_(ツ)_/¯.
As pointed out by ZNK, it is about switching to normal mode in Vim's terminal. This, however, can easily fail due to cumbersome keybinding. If such is the case, remap the default keybinding to something reasonable, say, by putting this in your .vimrc:
tnoremap jk <C-\><C-n>
This works for me in Linux running Vim 8.0 in terminal (e.g. does not require Neovim). As you can see, I use 'jk' to switch from insert to normal mode. One can use Esc instead of jk, however, this makes me unable to use up arrow to retrieve command line history as been reported elsewhere.

How to get QFileDialog to select and return multiple folders [duplicate]

This question already has an answer here:
PyQt QFileDialog - Multiple Directory Selection
(1 answer)
Closed 6 years ago.
I want to have the user be able to select multiple folders and then store the paths of those folders in a list.
How can i make that happen? My current QFileDialog looks like this:
str = QtGui.QFileDialog.getExistingDirectory(self, "Open Directory", /folder/subfolder, QtGui.QFileDialog.DontResolveSymlinks)
But of course, it only lets me select one folder. How can I change it to select multiple folders and return them in a list?
As far as I know you can't do that with the native FileDialog.
There, however, exists a workaround in which you don't use the native dialog:
file_dialog = QFileDialog()
file_dialog.setFileMode(QFileDialog.DirectoryOnly)
file_dialog.setOption(QFileDialog.DontUseNativeDialog, True)
file_view = file_dialog.findChild(QListView, 'listView')
# to make it possible to select multiple directories:
if file_view:
file_view.setSelectionMode(QAbstractItemView.MultiSelection)
f_tree_view = file_dialog.findChild(QTreeView)
if f_tree_view:
f_tree_view.setSelectionMode(QAbstractItemView.MultiSelection)
if file_dialog.exec():
paths = file_dialog.selectedFiles():
This workaround is a bit clunky however, but it's the best solution I know of other than rolling your own custom dialog.

How do I block comment in Jupyter notebook? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I want to comment out a block of multiple lines in Jupyter Notebook, but can't find out how to do that in this current version.
It used to be in one of the drop down menus but is no longer there.
How do you comment out multi-line blocks of code at once?
This is not a duplicate because the solution given in the following link doesn't seem to work anymore:
How can I block comment code in the IPython notebook?
Ctrl + / does nothing.
Ctrl + / works for me in Chrome browser in MS Windows. On a Mac, use Cmd + / (thanks Anton K).
Please note, if / did not work out of the box, try pressing the / key on the Numpad. Credit: #DreamFlasher in comments to this question.
I have not yet managed to find the best way possible. Since I am using a keyboard with Finnish layout, some of the answers do not work for me (e.g. user5036413's answer).
However, in the meantime, I have come up with a solution that at least helps me not to comment each and every line one by one. I am using Chrome browser in MS Windows and I have not checked other possibilities though.
The solution:
It uses the fact that you can have multiple line cursors in an Ipython Notebook.
Press the Alt button and keep holding it. The cursor should change its shape into a big plus sign. The next step is, using your mouse, to point to the beginning of the first line you want to comment and while holding the Alt button pull down your mouse until the last line you want to comment. Finally, you can release the Alt button and then use the # character to comment. Voila! You have now commented multiple lines.
Try using the / from the numeric keyboard.
Ctrl + / in Chrome wasn't working for me, but when I used the /(division symbol) from the numeric it worked.
Quick Addition to Top Answer: CTRL + / is nice because it toggles back and forth between adding and removing # at beginning of all selected lines. Didn't see that exact nuance mentioned so just wanted to add it here. (This worked in Firefox Developer Edition 54.0b12 on Windows 7).
On a Finnish keyboard use Ctrl + ' to comment on multiple lines and use the same keys to de-comment.
Ubuntu 14.04 Google Chrome
TL;DR:
Using MacBook Pro with Spanish - ISO Keyboard.
Solution: Ctrl + -
Full story
This is an old post but reading it got me thinking about possible shortcuts.
My keyboard is a Latin Apple MacBook Pro, which is called Spanish - ISO. I tried the changing keyboard distribution to U.S. solution... this works but with this solution I have to switch keyboards every time I want to comment which... sucks.
So I tried ctrl + - and it works. The - is where the / is located in an english keyboard but doing Cmd + - only changes the Chrome's zoom so I tried Ctrl which isn't as used as Cmd in macOS.
My takeaway with this would be: if I have more shortcut problems I might try the original shortcut but using the key where the U.S. keyboard would have it.
Select the lines you want to comment out. Then press:
Ctrl + #
I tried this on Mac OSX with Chrome 42.0.2311.90 (64-bit) and this works by using CMD + /
The version of the notebook server is 3.1.0-cbccb68 and is running on:
Python 2.7.9 |Anaconda 2.1.0 (x86_64)| (default, Dec 15 2014, 10:37:34)
[GCC 4.2.1 (Apple Inc. build 5577)]
Could it be a browser related problem? Did you try Firefox or IE?
Use triple single quotes ''' at the beginning and end. It will be ignored as a doc string within the function.
'''
This is how you would
write multiple lines of code
in Jupyter notebooks.
'''
I can't figure out how to print that in multiple lines but you can add a line anywhere in between those quotes and your code will be fine.
Fn + Cmd + / in Safari browser on MacOS
On MacOS 10.11 with Firefox and a German keyboard layout it is Ctrl + ?
Select the lines on windows jupyter notebook and then hit Ctrl+#.
I add the same situation and went in a couple of stackoverfow, github and tutorials showing complex solutions. Nothing simple though! Some with "Hold the alt key and move the mouse while the cursor shows a cross" which is not for laptop users (at least for me), some others with configuration files...
I found it after a good sleep night. My environment is laptop, ubuntu and Jupyter/Ipython 5.1.0 :
Just select/highlight one line, a block or something, and then "Ctrl"+"/" and it's magic :)
After searching for a while I have found a solution to comment on an AZERTY mac. The shortcut is Ctrl +/= key
I am using chrome, Linux Mint; and for commenting and dis-commenting bundle of lines:
Ctrl + /
For a Dutch keyboard layout (on Debian 9 in Chromium 57) it is Ctrl + °
Another thing to add, in the version I'm using, the code has to be initialized in order to be to comment it out using CTRL and / . If you haven't ran the code and the code isn't colorized it wont work.
If you have a Mac and not a English keyboard:
Cmd-/ is still easy to produce.
Follow the below steps:
Just go into the Mac's System Settings, Keyboard, tab "Input Sources" or whatever it might be called in English
Add the one for English (shows up as ABC, strange way to spell English).
Whenever you want a Cmd-/, you have to change to the ABC keyboard (in your menu row at the top of your screen,if you have ticked it to be shown there in the System Settings - Keyboard tab).
Cmd and the key to the left of the right "shift key" gives you Cmd-/.
P.S: Don't forget to switch back to your normal keyboard.

How to end a 'debug' mode? [duplicate]

This question already has answers here:
How to leave the R browser() mode in the console window?
(3 answers)
Closed 8 years ago.
In RStudio, I started a debug mode by
debug(ls)
ls()
Then I do not know how to end this mode.
The prompt changed to
Browse[2]>
How can I end this debugging mode?
First quit debugging the function with Q at the Browse[2]> prompt as jbaums tells you in his comment. This takes you back to the > prompt. Now turn off the debugging on ls with this command:
undebug(ls)
?debug is helpful for this sort of thing.
Use debugonce() instead of debug(). As the name suggests, this will only take the function through debug mode once. When in debug mode hit continue to run through the end or the next breakpoint or use the stop button to end the debug session.

Resources