Result of run to clipboard

Discussion, questions and support.
JJussi
Posts: 29
Joined: Jan 22nd, ’19, 12:44

Post by JJussi » Jan 22nd, ’19, 12:51

Hi!
This maybe simple, but couldn't find it...

I have (bash.exe) script "RadomPassword" what generates random password as result. How I can copy "result of run command" automatically to clipboard?
thinman
Posts: 31
Joined: May 17th, ’13, 15:44

Post by thinman » Jan 22nd, ’19, 13:20

If the caret is at the end of the generated string, you can select the last word (Shift+Ctrl+Left) and copy it to clipboard. The following assumes the modifiers are turned on in Preferences/Text Expander. Type: Send

Code: Select all

!^{Left}^c
JJussi
Posts: 29
Joined: Jan 22nd, ’19, 12:44

Post by JJussi » Jan 23rd, ’19, 07:39

Hi!
I don't understand how I can make !^{Left}^c working. Because bash windows is closed automatically after run of the script. I I put echo -en "!^{Left}^c" at the end of my script, it wouldn't select anything.

I'm not yet good with this product.
Why "command"

Code: Select all

Run % "C:\Windows\" (A_Is64bitOS?"Sysnative":"System32")"\bash.exe"
works, but

Code: Select all

Run % "C:\Windows\System32\bash.exe"
don't work?

So, solution to my problem would be something like:

Code: Select all

Run % "C:\Windows\" (A_Is64bitOS?"Sysnative":"System32")"\bash.exe"
Sleep 100
Send, /home/jjussi/randpass.sh
Send, !^{Left}^c
except that this don't work
User avatar
Marko
Posts: 1719
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jan 23rd, ’19, 08:28

I'm not familiar with Bash. How you run is dependent on it's folder location on your system. Most probably you can run the script directly like this (one of the two should work):

Code: Select all

Run C:\Windows\System32\bash.exe /home/jjussi/randpass.sh
Run C:\Windows\Sysnative\bash.exe /home/jjussi/randpass.sh
Then you need to capture the result string. The solution above assumed the result is shown on a command line - how do you get it?
JJussi
Posts: 29
Joined: Jan 22nd, ’19, 12:44

Post by JJussi » Jan 23rd, ’19, 08:36

I found information that 32bit and 64bit don't mix... At C:\Windows\System32 -directory there is lot's of .exe files what you cannot start with direct Run command. You need to use that "virtual" Sysnative directory.

What comes to that my script, it echoes result to command line and then ends. When script ends, window is closed. As it is when .bat file is ran.

Anyway....

I managed to find other solution, what is "enough"

Code: Select all

RunWait % "C:\Windows\" (A_Is64bitOS?"Sysnative":"System32")"\bash.exe -c /home/jjussi/randpass.sh > /mnt/c/temp/randpass.txt",  , Hide
FileRead, clipboard, C:\temp\randpass.txt
Last edited by JJussi on Jan 23rd, ’19, 10:41, edited 1 time in total.
JJussi
Posts: 29
Joined: Jan 22nd, ’19, 12:44

Post by JJussi » Jan 23rd, ’19, 08:53

This is getting interesting.

Same code at "Start Menu" works fine, but not as "Shortcuts".

Both run that first "RunWait" commmand and result is saved to that temporary file. Only at "Start Menu" version that result is read to the clipboard. With Shortcuts version, nothing is inserted to clipboard.
User avatar
Marko
Posts: 1719
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jan 23rd, ’19, 10:56

Maybe a short pause is needed before FileRead.
JJussi
Posts: 29
Joined: Jan 22nd, ’19, 12:44

Post by JJussi » Jan 23rd, ’19, 11:19

I tested that too.. At least, 100 ms pause didn't do any difference. And anyway, that content should be at filecache.
User avatar
Marko
Posts: 1719
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jan 23rd, ’19, 20:44

If the command is the same there is no reason this would not work. For example, I tried the similar code below and it works in both, Shortcuts and Start Menu.

Code: Select all

FileAppend, % "This is a test", Test.txt
FileRead, clipboard, Test.txt
FileDelete, Test.txt
JJussi
Posts: 29
Joined: Jan 22nd, ’19, 12:44

Post by JJussi » Jan 24th, ’19, 05:03

Yes, you are right. Same code should work both cases. But at least my case it didn't.

First I made (and tested) that code as "Start menu" -item.
Then I copy paste that code to Shortcut item and noticed that it don't work.
Then I created new Start menu item, just right clicking that Shortcut item and selecting "Copy to start menu" and that start menu item worked as it should be.

All those three versions should work, but...
Post Reply