file Redirection (request)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Konos93a
Posts: 13
Joined: 22 Aug 2017, 01:06

file Redirection (request)

22 Aug 2017, 01:11

May u help me a little bit here?

lets say that you have 2 folders original and shortcutoriginal . both folders have files with same name but not necessary all of them are the same.
.can you please make a script in autohotkey like input directory ,output directory to Redirect files from input to output pathfile.
so when i press file 0043 in shortcutoriginal run 0043 of original

Image

Image
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: file Redirection (request)

22 Aug 2017, 07:30

So you want that when opening(double clicking) picture ‘0043’ in the ‘Shortcutoriginal’ folder, Autohotkey opens the ‘0043’ in the ‘Original’ folder instead?
Konos93a
Posts: 13
Joined: 22 Aug 2017, 01:06

Re: file Redirection (request)

22 Aug 2017, 07:48

u know English is not my native language.i try to use google translate to express what i want.

i want a program where i have 2 empty paths . when i put 2 folders in paths the input be like a shortcut of the other
Konos93a
Posts: 13
Joined: 22 Aug 2017, 01:06

Re: file Redirection (request)

22 Aug 2017, 07:58

yes i want a program like that you describe
Konos93a
Posts: 13
Joined: 22 Aug 2017, 01:06

Re: file Redirection (request)

22 Aug 2017, 08:00

sorry again DyaTactic how difficult do u believe that it is ?
how can i begin with?
what do u suggest?
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: file Redirection (request)

22 Aug 2017, 08:12

The window you show is the most time consuming I think.
Image

Do you want to write it yourself or just have the code and see if it is what you want?
I would start by making a hotkey that does this instead of using the doubleclick event. This means that double clicking will cause to open the shortcut file and say ‘Ctrl + O’ opens the Original file.
Also I will use the clipboard of Windows (i.e. Ctrl + C hotkey) to get the filename of the selected file. This means when you copied something but did not paste it yet, this program will make that copy 'forgotten'.
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: file Redirection (request)

22 Aug 2017, 08:13

This, whithout the buttons is 15 min work.
Konos93a
Posts: 13
Joined: 22 Aug 2017, 01:06

Re: file Redirection (request)

22 Aug 2017, 08:28

just have the code and see if it is what i want

when you say without buttons you mean without Browse right? only the pathfile
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: file Redirection (request)

22 Aug 2017, 08:31

The filepath should then be entered in the script. This can always be extended with a browse function.
Ill start writing right away.
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: file Redirection (request)

22 Aug 2017, 08:51

This is working on my machine now. Make sure the filepath after ‘OriginalFolder = ’ is correct and the name ShortcutOriginal after ‘#IfWinActive, ’ is correct, dont put the full path here.

Code: Select all

#SingleInstance Force

OriginalFolder = C:\Experiment\Original
;ShortcutFolder = C:\Experiment\ShortcutOriginal

#IfWinActive, ShortcutOriginal ahk_exe Explorer.exe

^o::	; Press Ctrl + O to open the original picture.
	SEND, ^c	; Copy the picture's filepath.
	
	StringGetPos, FirstBackSlashPos, Clipboard, \, R

	StringRight, FileName, Clipboard, % StrLen(Clipboard) - FirstBackSlashPos
	
	Run, % OriginalFolder . FileName
Return

#IfWinActive
Let me know how this works.
Konos93a
Posts: 13
Joined: 22 Aug 2017, 01:06

Re: file Redirection (request)

22 Aug 2017, 09:26

sorry again my English must be bad enough .
can you make this with this paths

D:\ebookscanner\17-7-21\teckthought\experiment\original
D:\ebookscanner\17-7-21\teckthought\experiment\shortcutsoriginal
Konos93a
Posts: 13
Joined: 22 Aug 2017, 01:06

Re: file Redirection (request)

22 Aug 2017, 09:35

"the hotkey ^O will not be active because it does not exist in the current keyboard layout"
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: file Redirection (request)

22 Aug 2017, 12:42

I changed the hotkey to Ctrl + 0 (its a zero now). This can be changed to anykey desired.
Let me know if this works.

Code: Select all

#SingleInstance Force

OriginalFolder = D:\ebookscanner\17-7-21\teckthought\experiment\original
;ShortcutFolder = D:\ebookscanner\17-7-21\teckthought\experiment\shortcutsoriginal	; This line is obsolete.

#IfWinActive, shortcutsoriginal ahk_exe Explorer.exe

^0::	; Press Ctrl + 0 to open the original picture.
	SEND, ^c	; Copy the picture's filepath.
	
	StringGetPos, FirstBackSlashPos, Clipboard, \, R

	StringRight, FileName, Clipboard, % StrLen(Clipboard) - FirstBackSlashPos
	
	Run, % OriginalFolder . FileName
Return

#IfWinActive
Konos93a
Posts: 13
Joined: 22 Aug 2017, 01:06

Re: file Redirection (request)

22 Aug 2017, 13:24

:dance: :dance: :dance:

dude thanks for your patience.The script work perfect. if u ever wanna learn how to scan books with camera or your mobile phone and then read them on an ebookreader .tell me
Konos93a
Posts: 13
Joined: 22 Aug 2017, 01:06

Re: file Redirection (request)

22 Aug 2017, 13:32

something more is it possible when i delete a file from the original folder autodelete and the file from the shortcut?
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: file Redirection (request)

23 Aug 2017, 02:48

Ill put everything in one script.

Code: Select all

OriginalFolder = D:\ebookscanner\17-7-21\teckthought\experiment\original
ShortcutFolder = D:\ebookscanner\17-7-21\teckthought\experiment\shortcutsoriginal

Return	
; End of the autoexecute section.

#IfWinActive, shortcutsoriginal ahk_exe Explorer.exe
^0::	; Press Ctrl + 0 to open the original picture.
	FirstBackSlashPos := 0
	
	SEND, ^c	; Copy the picture's filepath.
	
	StringGetPos, FirstBackSlashPos, Clipboard, \, R	; Get the position of the first right side backslash.
	StringRight, FileName, Clipboard, % StrLen(Clipboard) - FirstBackSlashPos	; Get the characters on the right side of this backslash (including the backslash).
	
	Run, % OriginalFolder . FileName	; Open the Original file.
Return

; ‘Original’ in this WinTitle seems to be casesensitive.
#IfWinActive, original ahk_exe Explorer.exe
$Delete::
	FirstBackSlashPos := 0
	
	SEND, ^c	; Copy the selected file.
	
	StringGetPos, FirstBackSlashPos, Clipboard, \, R	; Get the position of the first right side backslash.
	StringRight, FileName, Clipboard, % StrLen(Clipboard) - FirstBackSlashPos	; Get the characters on the right side of this backslash (including the backslash).
	
	MsgBox, 4, Delete shortcut?, Do you want to delete the shortcut (%ShortcutFolder%%FileName%) and the original file?
	IfMsgBox, Yes
	{
		FileDelete, % ShortcutFolder . FileName	; Delete the shortcut file.
		SEND, {Delete}	; Command Windows to delete the selected file.
		
		WinWaitActive, ahk_class #32770 ahk_exe explorer.exe, , 2
		If ErrorLevel
			Return
		SEND, {Enter}	; Dismiss the MsgBox from Windows by pressing Yes: Delete selected file.
	} Else {
		SEND, {Delete}	; Command to delete the selected file.
	}
	Return

#IfWinActive
The WinTitle's seems to be case sensitive but it should be good now. Let me know.

The feature you are making sounds very useful. Ill remember your offer.
Konos93a
Posts: 13
Joined: 22 Aug 2017, 01:06

Re: file Redirection (request)

25 Aug 2017, 09:01

i tried it on delete part didn't work . this autohotkey part is more important having 2 folders with same filenames and if delete one in a folder delete and the one from the other .

example
Originals folder filename a-0001, a-0002, a-0003, a-...
Shortcuts folder filename a-0001, a-0002, a-0003, a-...

if i delete filename a-0003 in Originals folder autodelete in Shortcuts folder and if i delete filename a-0003 in Shortcuts folder auto-delete in Originals folder .

the part auto-open is no more necessary cause i check in shortcuts folder if some pages are double or missed and i have open windows viewer for originals images so i go to the filename and delete or take note from the missed page and then i delete and the shortcut file.
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: file Redirection (request)

25 Aug 2017, 09:09

I wrote it so it will only work in the Original folder. Don't know if you tested them both? However the way I wrote it is a bit clumsy because it expects the system to respond on a simulated Delete key stroke. But this way I hope to prevent deleting files which can't be retreived via the recycle bin.
If you realy want it working, which you say you don't, let me know what goed well and what goes wrong.

Glad I could help.
Konos93a
Posts: 13
Joined: 22 Aug 2017, 01:06

Re: file Redirection (request)

25 Aug 2017, 12:58

o you are right . i deleted from windows viewer and didnt work . But if i am in original folder and delete files everything is fine . tried to works with 2 scripts . one from original delete shortcuts and from shortcuts delete origininal

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, exodus_cl, ratyrat, Sniperman and 373 guests