viresmetus Posted April 26, 2020 Posted April 26, 2020 I want to make a text file in my current folder, paste text into the name, open it, paste into the body, and then close. I was trying to create a macro but it has the static info of the file location so it would be useless as I want it to do these actions but be "smart" enough to work regardless of where I am in the file hierarchy. My workflow is: (step 1, 2 are probably fine to do manually, and 9 if it's too complicated) copy text click into opened explorer folder (make it active) create new text file (right-click > new text) paste into text file name open file paste again (there's a hard return in the text so it conveniently works for the title and body) save close window click into opened explorer folder (make it active)
faustf Posted April 26, 2020 Posted April 26, 2020 1. copy text ? where? anotert txt ? ord doc file?? or in internetexplorer browser?
faustf Posted April 26, 2020 Posted April 26, 2020 the point 2 to 9 you can do with filewrite look in help F1 in scite here find also example
viresmetus Posted April 26, 2020 Author Posted April 26, 2020 22 minutes ago, faustf said: 1. copy text ? where? anotert txt ? ord doc file?? or in internetexplorer browser? From text in a browser but I can do that part manually
Nine Posted April 26, 2020 Posted April 26, 2020 10 minutes ago, viresmetus said: From text in a browser which one ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
faustf Posted April 26, 2020 Posted April 26, 2020 (edited) you can use _IeBodyreadtext , if you want some part of text , you can youse a regexp Edited April 26, 2020 by faustf
viresmetus Posted April 26, 2020 Author Posted April 26, 2020 3 minutes ago, Nine said: which one ? As I said I'm probably just going to do that part manually because it's likely too dynamic to bother with
viresmetus Posted April 26, 2020 Author Posted April 26, 2020 #region --- Au3Recorder generated code Start (v3.3.9.5 KeyboardLayout=00000409) --- #region --- Internal functions Au3Recorder Start --- Func _Au3RecordSetup() Opt('WinWaitDelay',100) Opt('WinDetectHiddenText',1) Opt('MouseCoordMode',0) Local $aResult = DllCall('User32.dll', 'int', 'GetKeyboardLayoutNameW', 'wstr', '') If $aResult[1] <> '00000409' Then MsgBox(64, 'Warning', 'Recording has been done under a different Keyboard layout' & @CRLF & '(00000409->' & $aResult[1] & ')') EndIf EndFunc Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc _AU3RecordSetup() #endregion --- Internal functions Au3Recorder End --- _WinWaitActivate("Expression","") MouseClick("right",372,308,1) MouseClick("left",429,522,1) Send("{CTRLDOWN}v{CTRLUP}{ENTER}{ENTER}") _WinWaitActivate("C:\Users\Glenn\Downloads\Video1\Posing\Expression\EXPRESSION SERIES.txt - Notepad++","") Send("{CTRLDOWN}v{CTRLUP}") _WinWaitActivate("*C:\Users\Glenn\Downloads\Video1\Posing\Expression\EXPRESSION SERIES.txt - Notepad++","") Send("{CTRLDOWN}s{CTRLUP}") _WinWaitActivate("C:\Users\Glenn\Downloads\Video1\Posing\Expression\EXPRESSION SERIES.txt - Notepad++","") Send("{CTRLDOWN}w{CTRLUP}") _WinWaitActivate("Expression","") MouseClick("left",430,467,1) #endregion --- Au3Recorder generated code End --- I used the recorder to generate this, my issue is I want the file location to be dynamic based on where I am (I'm want to run this macro on a button press in multiple locations), not locked to the above location
viresmetus Posted April 26, 2020 Author Posted April 26, 2020 So the above test code works (or actually something very similar as I tweaked the mouse movements but otherwise it's the same idea) but it only works in that specific window / file location. I essentially want it to do "that" but more generally and not tied to that folder
careca Posted April 27, 2020 Posted April 27, 2020 (edited) I think the way i would do this, would be by context menu item. I would create a context menu item pointing to the appropriate compiled script, which in turn would receive a parameter like %w, and use that as the working directory. From there on, it would be a simple matter of, as was already suggested, use filewrite to create the file with the clipboard text. Now to rename the file to a specific name would be more tricky, but what could be done would be to use the first word/s of the text as the filename. Where are you getting the filename? From all browsers the IE would be the easiest to get all values needed. Meaning if it's IE, we could probably do a script that takes the filename and text and in one go. So, here it goes Global $GetClip, $FO, $NewFile = 'test.txt' If $CmdLine[0] = 1 Then If FileExists($CmdLine[1]) Then MsgBox(64 + 262144, '', $CmdLine[1]) $GetClip = ClipGet() $FO = FileOpen($CmdLine[1]&'\'&$NewFile, 10) FileWrite($FO, $GetClip) FileClose($FO) Run('explorer /select, "' & $CmdLine[1]&'\'&$NewFile&'"') Exit Else MsgBox(64 + 262144, '', 'No Parameter called') EndIf EndIf Plus the registry entry: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\UseThis] @="UseThisFolder" [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\UseThis\Command] @="C:\\Users\\W10LR\\Desktop\\UseThis.exe \"%w\"" The registry adds the entry for the exe, change username in path accordingly. The context menu item will pass the folder you right clicked in to the exe, the exe creates the new file with the clipboard content, and then open and select the file. You end up with 2 folders, but anyway, this is proof of concept. usethis.reg Edited April 27, 2020 by careca Trouble sleeping Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now