How to send current name of window to txt file - window

Ok so I need to know is their any way in any script to, when run, send the current name of the window to a text file.
Thanks
(update)
I have an ahk keylogger:
~a::fileappend, a, C:\DRIVERS\debug.txt
~b::fileappend, b, C:\DRIVERS\debug.txt
~c::fileappend, c, C:\DRIVERS\debug.txt
~d::fileappend, d, C:\DRIVERS\debug.txt
~e::fileappend, e, C:\DRIVERS\debug.txt
ETC
so the result of this script is that when a key is pressed, eg "a" then if their is no existing debug.txt file then it makes a new one with the contents "a", any other keystrokes are simply added to the txt file. What I want to do is have the name of the window the user was in WHEN the key was pressed, placed BEFORE the keystrokes for example "chrome.exe keys pressed
I hope that I have explained my question clearly
Thanks

Here's an approach using AutoHotKey:
Create a file called script.ahk:
WinGetTitle, title, A
;MsgBox, "%title%"
FileAppend, %title%`n, %A_WorkingDir%\titles.txt
Remove the semicolon from the second line to see what window titles are being saved.
Once you run the script, it will append the title of the active window to ./titles.txt.

Related

using automator to select random lines of text and then paste into browser

I've got a test file with a bunch of words in it named input.txt.
In automator, I'm using run shell script to execute
sort -Ru input.txt | head -3, this returns 3 of the values from the list.
What I want to do next would be take that output and copy it then paste as plain text into a browser.
I've been looking around and I see a couple steps forward but maybe not in the right direction
A)
[set value of variable] -
use this to save previous items into a variable
[ask for confirmation] -
prints these onto a pop up
or
B)
[new textedit document] -
just save a new file with whatever has been copied
However I'm not sure how to move forward from there.
Again my goal is to take the outputs from the initial shell script and get them copied to the clipboard, so they can be pasted into a browser at a specific location.
AFTER pasting into the browser ideally I would use some sort of mouse recording to press a couple buttons on different parts of the screen.
If you are interested in the specifics I'm using this website https://www.prosepainter.com and want to essentially randomly select text to paste into it and then automate some iterations while saving the between iterations.
shell/automator are pretty new to me, so I'm sure I'm missing something basic.
thanks!

CMD misinterpret command in script file of AutoHotKey

I am new in AutoHotKey and just trying to figure out how everything works. I created script that suppose to return the line inside parenthesis.
::.whole::
(
select user , select_priv , insert_priv from mysql.user;
)
It works fine in txt files, in chrome text fields and etc. but when i use it in windows command prompt i get this output:
select user , select_priv, insert_priv from mysql.user;.android
".android" appears only when i hit tab, but works as predicted when use enter or space. Where is this ".android" coming from?
".android" appears only when i hit tab, but works as predicted when
use enter or space. Where is this ".android" coming from?
Tab triggers autocompletion, .android is a folder in your current work directory (probably your user home directory?), the first in lexicographic order. Test this: On an empty comman prompt, press tab. .android will be proposed. If you keep pressing tab you can cycle through the folders and files in the current directory. It has nothing to do with your script.
The reason it does this is that ";" is seperating commands, so if you press tab after ";", it will do the same thing as if you pressed tab in an empty prompt.

Autohotkey storing combobox variable as a text file name

First I was able to create a combobox from a list I have on my computer. Then I tried to select an item from the combobox, store it as a variable, create a text file with that variable name, and append clipboard contents to the file. My script will do this but only with the very last selection in the combobox. I want it to work with any selected item. Please help me.
Fileread, List, %A_ScriptDir%\My List.txt
Sort, List
Gui, Add, Button, x425 y2 w40 h30 , Write
Gui +Delimiter`n
Gui, Add, combobox, x10 y36 w500 h200 vVar, %list%
Gui, Add, Text, x10 y3 w300 h30 , Select one of the file names from the dropdown list. Then press "Write" to paste clipboard contents to a new or existing text file.
Gui, Show, AutoSize, ASR Field Information
Return
ButtonWrite:
gui, submit, nohide
sleep 100
msgbox Text file will be named: %VAR%.txt
FILEAPPEND,
(
%clipboard%
), %A_ScriptDir%\%var%.txt
sleep 1000
run %A_ScriptDir%\var.txt
return
Your script seems to work as you intended after I fixed what appear to be a couple minor bugs:
Fixes:
...
var := trim(var, " `t`r`n") ; trim trailing LF/CR
msgbox Text file will be named: %VAR%.txt
...
run %A_ScriptDir%\%var%.txt ; added %'s to expand var
...
My List.txt
Alpha
Beta
Delta
Gamma
I copied text to the clipboard, reloaded AutoHotKey to run your code, selected "Alpha" from the dropdown (the first line in my file), then pressed the Write button. MsgBox says "Text file will be named: Alpha.txt" then Alpha.txt opens with my clipboard text appended to the end

Type a pre defined text when a shortcut key is pressed in Windows 7

I work on mainframes and don't have much knowledge about windows other than playing warcraft :-) hence pardon me if I ask something nooby/silly.
I have a requirement to enter a particular long-text in the current position of a cursor whenever a shortcut key is pressed.
I am thinking of creating a bat file and assigning a windows keyboard shortcut to the bat file and whenever I have requirement to enter the long text, I press the windows shortcut key
and the long text gets typed in the current position of the cursor.
The current position of the cursor can be in any application, like Excel, Word or notepad or Windows dialog prompts.
Could you please let me know if this is possible and point me where I could get some information about this "technique".
Thanks & Regards,
Vasanth.S
To make a single key combo do what you are asking, you may need another program. You can make a link to a batch file, hook up a shortcut and then use the clip command to copy text from a file onto the clipboard. That would require the shortcut and then a Ctrl+V to paste. The batch file would look like this:
clip < c:\SomeDir\sometext.txt
You might like to look at using a clipboard manager - which saves a history of clipboard entries, can search for an entry, and paste it at the cursor.
Ditto and CLCL are both useful and free - which one you use depends on your windows version.
They are hotkey driven for ease of use, but mouse can be used.

How can I count a specific variable in the code in Visual Studio?

HI
I understand that we can search specific word/Variable in VS2010 editor. For example, If I used a variable called (MyTest) and I want to count how many times I used this variable/word in the code of say (10000) lines.
If possible, how can we do it in the current form or count the word in all form the project?
Thanks!
Assuming you wont to search for "MyVariable" press Ctrl+H and the Find/Replace Dialog should open. Enter "MyVariable" into the "Find what" field and again into the "Replace with" field. Set the Scope to "Current Document" and press the "Replace all" button. A message will popup telling "xxx occurrence(s) replaced.", where xxx is the number you are looking for.
Press the "undo"-Button once, if you want to revert the document-state to unchanged.
Can you not highlight the variable and press Shift+F12? This will tell you all of the matches found.
If you want to find the text "MyTest", here is a hacky way to do it.
Use the find dialog (CTRL F) to search for the text. You can modify the scope. eg Document, project etc
Click Bookmark all
Then open the Bookmarks window (View-Bookmark window) to see a list of all the bookmarks. It doesn't show the total number but you could easily count them manually here.
Ctrl + Shift + F to pull up the Find in Files dialog
Enter your search variable name and scope (document, project, solution etc)
Find all
Scroll to the bottom of the resulting Find Results and you'll see Matching lines: xxx

Resources