How do I use autohotkey to create a new text file by right click -> New -> New text document? [closed] - autohotkey

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I want to create a new text file by right click -> New -> New text document using AutoHotKey. How do I do this? I am new to AutoHotKey.
Edit:
Using Autohotkey, you can assign shortcut for some tasks such as running a particular program like Notepad. You do so by writing scripts. You can find the details on the Autohotkey website. I want to write a keyboard shortcut to manually automate the "right click -> New -> New text document" functionality.
I figured out that it could be done by adding the following script to to AutohotKey's existing script.
^+t::
Click, right, 1024, 355 (or any other mouse co-ordinates for that matter)
Send w
Send t
return
However, this syntax wouldn't work when I tried. Could someone tell me what's wrong and tell how should be the correct syntax?

As Ken White said you already have that built in Windows Explorer, Right click > New > New Text Document, so it's kinda pointless having another one doing the same thing.
However, if you want to use AutoHotKey to create a new text file more efficiently and faster then i would recommend this script
SetTitleMatchMode RegEx
MsgBox, 64, NewTextFile, USAGE: When in a folder in Windows Explorer press Ctrl + Shift + T to create empty text file.`nIf you press multiple times, multiple files will be created (e.g. NewTextFile0.txt, NewTextFile1.txt)
#IfWinActive ahk_class ExploreWClass|CabinetWClass
^+t::
NewTextFile()
return
#IfWinActive
NewTextFile()
{
WinGetText, full_path, A
StringSplit, word_array, full_path, `n
Loop, %word_array0%
{
IfInString, word_array%A_Index%, Address
{
full_path := word_array%A_Index%
break
}
}
full_path := RegExReplace(full_path, "^Address: ", "")
StringReplace, full_path, full_path, `r, , all
IfInString full_path, \
{
NoFile = 0
Loop
{
IfExist %full_path%\NewTextFile%NoFile%.txt
NoFile++
else
break
}
FileAppend, ,%full_path%\NewTextFile%NoFile%.txt
}
else
{
return
}
}
When you have this running and you are in a folder using Windows Explorer (or Desktop) press Ctrl+Shift+T to create New text files, as many as you'd like.
https://github.com/ilirb/ahk-scripts/blob/master/executable/source/NewTextFile.ahk

Related

How to make script to paste something in with AutoHotKey

I'm trying to make a script in AutoHotkey where, when I press Numpad 1, it presses the slash button, then pastes in some text, let's say "hello world", and then presses enter, but I can't figure out how. Can someone help?
Welcome to Stack Overflow.
In the future, try to at least show what you tried. All of this should be accomplished pretty easily by e.g. looking at the beginner tutorial combined with a quick Google search.
But well, here it is:
Numpad1::
Clipboard := "/hello word"
SendInput, ^v{Enter}
return
Numpad1:: creates the hotkey label.
Clipboard:= ... puts something into the clipboard.
SendInput sends input.
^v means Ctrl+v.
{Enter} means the enter key (could've possibly appended `n (line feed) into the string as well).
Return stops the hotkey label's code execution (in other words, ends the hotkey's code).
Assuming that you already have some text copied inside your clipboard before pressing the numpad1, the following code will work.
Numpad1::
Send, /^v ; ^ means ctrl key,
Send, {Enter}
return

Automatic translation

im really new to all this and i was trying to make an Autohotkey for translation. i was digging for some time looking for examples that only confused me more, even if the code looked simple, i didn't understand half of it.
So, what I'm trying to do is: select a paragraph and replace it automatically with its translation.
i was hooping it to be somenthing as simple as CTRJ + C, Translate, CTRL + V, but i can't find the command to go to google translate or somenthing similar, it's not on the autohotkey help file so i'm guessing i don't have libraries?
I'm at my wits end, please help.
You came to the right place. Check out AutoHotKey for sure.
First, how to do it by hand? Those are the steps for ahk. So, lets say you have a paragraph of text selected. You will hit the ahk shortcut and that shortcut will:
first ahk figures out what window its in (using WinGetActiveTitle) and then sends the keystrokes Ctrl+c to copy the selection ("send, ^c" and "Clipwait"), then
ahk can access the clipboard containing the text, do a string manipulation or regex to replace all spaces with the html escape sequence %20 (eg, transtext := StrReplace(Clipboard, " ", "%20")) and
construct a URL to do the Google Translate, something like (where sl is source language and tl is translation language, and text is what you want translated): transurl := "https://translate.google.com/#view=home&op=translate&sl=en&tl=es&text=" . transtext
AHK runs that url and opens a browser window showing result (run % transurl).
This part sucks. Now, you need to use a mouse click at a location (or maybe you can find a controlsend or a combination of keystrokes moving the cursor with tabs and such) to land on the "Copy translation" button. Or how bout you do it manually (try sleep, 8000 to wait while you hit the button)
then have ahk close the window (optionally, or you just do it by hand during the sleep time) and
ahk switches back to the application with the original selected paragraph (WinActivate or do it yourself) and
send ctrl+v to paste the translated text over the original (send ^v).
A starter pack of AHK code (edited per user comments):
WinGetActiveTitle, activewin
Clipboard =
SendInput, ^c
ClipWait
transtext := StrReplace(Clipboard, " ", "%20")
transurl := "https://translate.google.com/#view=home&op=translate&sl=en&tl=es&text=" . transtext
Run, % transurl
Sleep, 6000 ; adjust to taste.
SendEvent, {tab 10} ; adjust to taste.
Sleep 1000
SendInput, {enter}
Sleep, 1000
SendInput, ^{F4}
WinActivate, activewin
sleep, 1000
SendInput, ^v
Try it and let us know how else to help.
OKOK, first of all, thank you all, the script works just fine now. I'm able to copy, translate and paste any text now. Only a few questions lingering.
1) i'm not sure i get what the step number 5 is suppose to do. whatever it is, it works so i don't touch it.
2) is there a way to reset google.translate so it dosent open a new window every time? that could save a lot of time.
3) this one doesn't have a chance, but i ask anyway. Is there a way to not open google chrome at all? because i know that u can translate from excel automatically. (i know that if it is possible will be super hard)
This is the code i ended with:
^a::
clipboard := ""
sendinput, ^c
ClipWait [,,Waitforanydata]
transtext := StrReplace(Clipboard, " ", "%20")
transurl := "https://translate.google.com/#view=home&op=translate&sl=en&tl=es&text=" .
transtext
run % transurl
Sleep, 4000
SendEvent, {tab 9}
SendEvent, {enter}
Winactivate, NAME.pdf - PROGRAM
sendinput, ^v

Paste into custom GUI with AHK

I have been working on this for a while and I have no idea how to fix this issue. I want to create a custom GUI in AutoHotKey (AHK), I would post ont he AHK Forums but I haven't been able to get my account to work so I am posting here (sorry if this is the wrong place). The ideal state is that I can paste in a list of indiscriminate length from a list, it is almost always return delimited, see the picture below. I would be happy with pasting 10 items in. I have built the GUI but I can not paste the values in with the shortcut Ctrl+v. All that happens is the first value goes into the first cell and I cannot figure out how to get the rest to paste in.
I need to be able to read the values into an array in the AHK when I click continue. Thanks for your help in advance. Below is my code to create the GUI.
Gui, Add, Text,, Please add the List that you want (10 Max at once)
Gui Add, Edit, vButton1,
Gui Add, Edit, vButton2,
Gui Add, Edit, vButton3,
Gui Add, Edit, vButton4,
Gui Add, Edit, vButton5,
Gui Add, Edit, vButton6,
Gui Add, Edit, vButton7,
Gui Add, Edit, vButton8,
Gui Add, Edit, vButton9,
Gui Add, Edit, vButton0,
Gui Add, Button, x200 y270 w88 h26 vButton02 gGoCont, Continue
Gui Add, Button, x290 y270 w88 h26 vButton03 gGoQuit, Cancel
Gui Show
return
GoCont:
{
MsgBox %Button1%
MsgBox %Button2%
}
return
GoQuit:
Gui Destroy
return
If you can stand a txt file with one name per line, called "names.txt" in the same folder as your ahk script, try something like this:
Add this to the top (it reads in your names.txt file one line at a time):
Loop, Read, names.txt
x%A_Index% := A_LoopReadLine
START EDIT (per comments):
Alternatively, if you already copied to the clipboard the several names from a spreadsheet or website table or other list, then put it this way:
Loop, parse, Clipboard, `n, `r
x%A_Index% := A_LoopField
Either way,
END EDIT
Then, replace all 10 of your edit box lines with these two lines:
Loop, 10 ; or more?
Gui Add, Edit, vButton%A_Index%, % x%A_Index%
The rest is just as you had it.
Let us know, Have fun,
Big thanks to #PGilm
Gui, PasteGUI:Add, Text,, Please add the Names that you want to Process.
Counter := 0
Loop, parse, Clipboard, `n, `r
{
x%A_Index% := A_LoopField
Counter++
}
Counter--
Loop, %Counter% ; Dynamic List length
Gui PasteGUI:Add, Edit, vButton%A_Index%, % x%A_Index%
Gui PasteGUI:Add, Button, x200 y270 w88 h26 vButton02 gGoCont Default, Continue
Gui PasteGUI:Add, Button, x290 y270 w88 h26 vButton03 gGoQuit, Cancel
Gui, PasteGUI:Show
}
Return
GoCont:
{
Loop, %Counter%
{
CODE TO PROCESS MY EACH NAME
}
MsgBox Done!
Gui Destroy
}
Return
GoQuit:
Gui Destroy
Return
Lastly if I want to add a keyboard shortcut to work then I mapped in one where I put the below line at the top of the code
PasteIn:
{
And then close the bracket at the end of the code and then add the shortcut. (the below can be added to the bottom of the code to work) this uses the Ctrl+v keyboard shortcut.
}
^v:: GoTo, PasteIn

microsoft word: copy without formatting

When I copy a text from Microsoft Word and the text is a heading in the clipboard I see it included a paragraph number. Then in another application I must remove the number manually.
Can I copy just a text without any additional information?
(The same is with Chrome when you copy a URL it adds a http:// automatically)
Method 1:-
one way is right mouse click and use this paste special option
Method 2:-
assign a shortcut(Ctrl+Shift+V) for this operation (Note: by default Ms word not set shortcut for it so we need to set it by own)
File > Options > Customize Ribbon > Keyboard shortcuts: Customize.
on Left Categories List section, click on All Commands
Under right Commands List, select for PasteTextOnly
then Set the keyboard shortcut for PasteTextOnly as Ctrl+Shift+V
Method 3 permanent/Default Settings
use this option which will each time paste as plain text by default
Try this
Sub FormatFreeTextCopy()
Dim ffText As DataObject
Set ffText = New DataObject
ffText.setText Selection.Text
ffText.PutInClipboard
End Sub
Note: You would have to Reference to Microsoft Forms Object Library
There is a generic "paste plain text" solution using autohotkey open-source automation software:
^+v:: ; Text–only paste from ClipBoard
Clip0 = %ClipBoardAll%
ClipBoard = %ClipBoard% ; Convert to text
Send ^v ; For best compatibility: SendPlay
Sleep 50 ; Don't change clipboard while it is pasted! (Sleep > 0)
ClipBoard = %Clip0% ; Restore original ClipBoard
VarSetCapacity(Clip0, 0) ; Free memory
Return
Save this code to paste_plain_text.ahk script
Install autohotkey
Execute your script
It will paste plain text using Ctrl+Shift+V shortcut. You can put your script at Startup directory so it loads on Windows startup.

How to create a shortcut which copy line where cursor on [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Eclipse copy/paste entire line keyboard shortcut
I want to create an eclipse shortcut.
Wherever line cursor on (without selection) when pressed Ctrl+C, eclipse will copy the whole line to clipboard.
Is this possible?
Key bindings can be associated with commands, but this operation would be 3 commands - Line Start, Select Line End, Copy. You'd have to implement your own command to execute all the three (id = org.eclipse.ui.edit.text.goto.lineStart, id = org.eclipse.ui.edit.text.select.lineEnd and id = org.eclipse.ui.edit.copy). But setting Ctrl+C as key binding would conflict with existing binding - Copy.