Jump to content

Recommended Posts

Posted

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)

  1. copy text
  2. click into opened explorer folder (make it active)
  3. create new text file (right-click > new text)
  4. paste into text file name
  5. open file
  6. paste again (there's a hard return in the text so it conveniently works for the title and body)
  7. save
  8. close window
  9. click into opened explorer folder (make it active)
Posted
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

Posted (edited)

you can use _IeBodyreadtext , if you want some part of text , you can youse a regexp

 

 

 

Edited by faustf
Posted

 

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

Posted
#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

Posted

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

Posted (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 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...