Move File to Folder has Unwanted Delay Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wideeyedguy
Posts: 60
Joined: 11 Feb 2016, 11:49

Move File to Folder has Unwanted Delay

27 Jun 2016, 15:02

I am using this script to move a file, that is currently selected, into another folder with a simple keyboard command.
However, I have to hit the keyboard command twice for it to work. When the file is first selected, by moving the selection up/down in the Explorer window, a tooltip type message hovers to display specs on the file and I think that is stealing focus from AHK seeing Win Explorer as Active. It only takes a second or two for the display to disappear and then AHK script will do its thing just fine. But, I'm having to hit Win-z twice for the script to execute.

Not sure that the information display box is what's causing this; just a guess. I've tried a few different Sleep periods to see if that would work and the Escape line to make the display box go away, but it isn't having an effect.

Code: Select all

#IfWinActive ahk_class CabinetWClass
#z::
Send {Esc}
Send,^c
;Sleep 10
Loop, parse, clipboard, `n, `r
{
FileMove,%A_LoopField%,L:\PES\PES Work Orders\Delain WOs\U&E Requests\To be done
}
Return
#IfWinActive    ;this line must remain or scripts below here will not load properly -dg
Suggestions?

weg
I say this optimistically . . . One day I'll understand it.
But today is not that day!
hunter99
Posts: 129
Joined: 20 Jan 2014, 17:57

Re: Move File to Folder has Unwanted Delay

27 Jun 2016, 16:23

Hi wideeyedguy:
Give this a try.

Code: Select all

#IfWinActive ahk_class CabinetWClass
#z::
clipboard =   ;start with empty clipboard
Send,^c       ;copy selected file to clipboard
sleep 300     ;longer time for larger files to copy clipboard
Loop, parse, clipboard, `n, `r  ; Specifying `n prior to `r allows both Windows and Unix files to be parsed.
{
FileMove,%A_LoopField%,L:\PES\PES Work Orders\Delain WOs\U&E Requests\To be done    ;your file and path destination
sleep 300     ;longer time to move larger files
}
return

#IfWinActive    ;this line must remain or scripts below here will not load properly -dg
EDIT code 6/28/16 20:21 EST
good luck, hunter99
Last edited by hunter99 on 28 Jun 2016, 19:22, edited 1 time in total.
wideeyedguy
Posts: 60
Joined: 11 Feb 2016, 11:49

Re: Move File to Folder has Unwanted Delay

27 Jun 2016, 17:32

hunter99,
Appreciate your help and let me clarify if you have a moment since I may not have been clear in OP.

I'm not wanting a file selection window to open so I can select a file to move. At this point where the code is used, I'm already working within an open Explorer window through a process of combining some PDF's into a single PDF. Now, I'm ready to move the finished PDF to the destination folder.
The PDF file (or any other file type; not important on type) is already selected/highlighted.
I hit Win-z and the script moves it to the destination folder in the script. The code I have works.

The problem is the delay. I am needing to activate (Win-z) twice to get the script to execute. (see original post)

Thanks for your thoughts.

weg
I say this optimistically . . . One day I'll understand it.
But today is not that day!
hunter99
Posts: 129
Joined: 20 Jan 2014, 17:57

Re: Move File to Folder has Unwanted Delay

28 Jun 2016, 06:18

Hi wideeyedguy:
Thanks for clarifying that. I thought the lag was the trouble and missed the #z key problem.
That hitting the #z twice would be a pain and is not right. So a few of more questions.
1. What OS are you running?
2. Is the code you posted the whole script file (ahk), or is it in with other code in a larger script?
3. If that is the whole script then what is the "Send {Esc}" for? Also the "#IfWinActive" after
the "Return" is useless as it would never be seen.
4. But if it is part of a larger script, have you tried a small script with just the code you posted.
5. If so did you still have to hit the hotkey twice?
6. If you had not tried just that code alone, would you try it and let me know the results.

I tried your code, as well as mine and both ran fine with no double keying needed.
Used my Dell I7 desktop running Win7 Pro and my ThinkPad Helix tablet running Win8.1.
What are you using to combine the PDF files? I use Acrobat Pro v10.1.1 and do it right in
Acrobat, never have to go into Win Explorer.
Have a good day. hunter99
wideeyedguy
Posts: 60
Joined: 11 Feb 2016, 11:49

Re: Move File to Folder has Unwanted Delay

28 Jun 2016, 11:06

So I moved the script out of my master script "stack" of scripts, put it in its own .ahk and nothing changed.
Using Win7
The Esc was just an attempt to get the tooltip type display to dismiss if that indeed was stealing the focus from AHK seeing WinExplorer as Active. But, that doesn't seem to be the problem since sometimes the popup display doesn't popup. In those scenarios, it still takes two times to activate. Also, I commented-out the Esc, just to see, and changed nothing.

PDF's
I use Acrobat Pro while keeping a WinExplorer open with my various PDF files listed. I simply drag them into the thumbnail view pane of the master file I'm combining into. This way I can easily determine the order of the docs as they go into the master PDF.

Thank you,
Delain
I say this optimistically . . . One day I'll understand it.
But today is not that day!
hunter99
Posts: 129
Joined: 20 Jan 2014, 17:57

Re: Move File to Folder has Unwanted Delay

28 Jun 2016, 13:41

Hi Delain:
Well I have a just few ideas at the moment. So I would try this if you haven't done so yet.
1. Make 2 empty folders preferably on a different drive, such as F:\TestSource and F:\TestDest.
2. Put some files, mix the extensions, in F:\TestSource. In other words you want to stay clear
of the old folders you were using. Don't even have Acrobat running. I would even do a clean rewrite
of your script, just use notepad and save as .ahk. This should only take about 10 minutes.
3. If it still fails, you could even try a different computer. If that works which it should, then (I should have
thought of this before) try a different mouse. If it is a USB one try other ports first.
4. Also have you tried hotkeys other than #z? I never liked using that modifier key, just a gut feeling.
5. Also had you tried the script I posted and did it work without clicking twice?

Out of ideas at the moment, good luck. hunter99
wideeyedguy
Posts: 60
Joined: 11 Feb 2016, 11:49

Re: Move File to Folder has Unwanted Delay

28 Jun 2016, 16:36

Before I go through all of that, what is your suspicion?

I did try your script but it brings up the file selection window and that is not what I am wanting. Easier than that, is simply to keep a shortcut of the destination folder in my working folder and drag/drop the file onto that shortcut and the file will quickly disappear through the shortcut "tunnel" to the destination folder - which is what I was doing before I created the script.

Thanks for your time & effort.

weg
I say this optimistically . . . One day I'll understand it.
But today is not that day!
hunter99
Posts: 129
Joined: 20 Jan 2014, 17:57

Re: Move File to Folder has Unwanted Delay

28 Jun 2016, 19:41

Hi Delain:
I was finally able to duplicate your problem, was using too small files for testing. I edited the code in my 1st post.
Added a clipboard clear and 2 sleeps. Needs time to copy to clipboard and then time to move the file.
The 300ms sleep works for me with i.5 gig files. Adjust time to suit file size.
I hope you try this and have not given up completely on it. Personally the way you did it originally is just as easy if not too many files.
Myself I sometimes move them right from the Acrobat dialog. Anyway good luck and happy scripting.
hunter99
just me
Posts: 9492
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Move File to Folder has Unwanted Delay  Topic is solved

29 Jun 2016, 03:35

ClipWait ?
Requires to clear the clipboard before Send, ^c.
hunter99
Posts: 129
Joined: 20 Jan 2014, 17:57

Re: Move File to Folder has Unwanted Delay

29 Jun 2016, 10:52

Hi wideeyedguy and just me:
First just me thanks for reminding me of "ClipWait", I had tried it here at one point but at the time it didn't help. Another senior moment I guess.
In my post just before yours, I mentioned "Added a clipboard clear and 2 sleeps". Also that I had updated my 1st post to reflect that. Using "ClipWait", no longer need the sleeps.
Thanks for the nudge to take another peek.

wideeyedguy, here is the new script. It's not much different than your original, just replaced the commented out sleep with "ClipWait".

Code: Select all

#IfWinActive ahk_class CabinetWClass
#z::
clipboard =   ;start with empty clipboard
Send,^c       ;copy selected file name/names to clipboard
ClipWait, 1  ; wait up to 1 sec. for clipboard to to get data
Loop, parse, clipboard, `n, `r  ; Specifying `n prior to `r allows both Windows and Unix files to be parsed.
{
FileMove,%A_LoopField%,L:\PES\PES Work Orders\Delain WOs\U&E Requests\To be done    ;your file and path destination
}
return
 
#IfWinActive    ;this line must remain or scripts below here will not load properly -dg
What I tested it with. On my Dell I7 desktop running Win7 Pro.

Moved between 2 physical hard drives a selection of 40 files totaling 8.16GB.
Containing types pdf, doc, zip, avi, ini, bak, mpg, docx, chm, and txt
Smallest @ 1KB to Largest @ 4.6GB took about 1 to 2 minutes.
During that time checked and D/L my email, then looked a a few Web sites.
Of course you can just pick 1 selection with a just noticeable lag, but no apparent difference between 1K and 25M in my view.

On my ThinkPad Helix tablet running Win8.1.
Ran script from a mem. stick moved files between folders with no problem.

hunter99
wideeyedguy
Posts: 60
Joined: 11 Feb 2016, 11:49

Re: Move File to Folder has Unwanted Delay

29 Jun 2016, 13:49

Had trouble getting onto the forum; seemed to be a web site issue.

Yep, this seems to have fixed the need for double-hit of the keyboard shortcut. And to be clear, the original issue was not about length of time in waiting for the Move of the selected file. It was having to hit the hotkey twice for some reason.
I appreciate all of your efforts, both of you, and your interest.

weg

hunter, I mis-tagged the wrong post as "accepted answer"; I acknowledge yours as the post that incorporated the idea and did the heavy lifting.
I say this optimistically . . . One day I'll understand it.
But today is not that day!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: popdeg, Spawnova and 159 guests