rename files as quickly as possible

Get help with using AutoHotkey and its commands and hotkeys
Posts: 9
Joined: 08 Feb 2019, 18:14

rename files as quickly as possible

26 Jun 2019, 10:08

I wrote the following loop (with a lot of help from this forum) to run when when I press the hot keys when the first in a long line of photos is selected:

Code: Select all

   Send {F2}						;Issue RENAME command
   Send MSC 184						;Send text xxxxxxxxxx
   KeyWait RETURN,D					;Waits for the return key to be pushed down
      GetKeyState, State, Shift		;Get the state of a shift key. (U)p or (D)own?
   If State = D
      Break							;Exit the loop if a shift key is down
      Send {RIGHT}					; Keep going, issue right arrow
Its purpose is to allow me to rename these files as quickly as possible. Initially it worked great but it seemed that when I had to change the beginning of the new filename (MSC 184 in this case), after a (short) random number of files, the ENTER key will start outputting MSC 184 before the SEND MSC 184. The result is that after entering two numerical characters following the MSC 184, pressing ENTER will jump to the next file and output MSC 184 before the SEND MSC 184 command resulting in MSC 184MSC184, sometimes even MSC 184MSC 184MSC 184.

This sequence of events was proved by starting a .txt file (while still in the loop) and seeing MSC 184 printed every time I pressed ENTER. That will stop only after exiting the loop (SHIFT>ENTER), even while still in the .txt file. Going back to renaming files, if I spot the extra text in the new filename before I press ENTER and backspace it out then adding my two numerical characters, I can press ENTER to jump to the next file and it may or may not repeat the extra characters on the next file. It will however always pop up again some random number of files later.

After several days of no response to my problem I was forced to start thinking again. It finally dawned on me that the above paragraph is actually self-explanatory. As long as the script was running, the return key will always print MSC 184 each time it's pressed. My apologies for being so obtuse.

Past experience has taught me that sometimes keystrokes delivered by a running script are output too fast. With this in mind I found the SetKeyDelay, command and decided to try it and put it after the SEND {F2} command. I set the delay at 100 ms so I could see if it even worked. It did work and I can actually visually follow the MSC 184 keystrokes as they are outputted. This SEEMED to work. "Seemed" being the operative word here as the problem appears to have gone away.

So, besides the fact that the problem seems to have stopped, did I fix it and if so, how/why?

Any help in this will of course be greatly appreciated.

[Mod edit: Topic name added]

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], boiler, LadyGamer, Odlanir, roysubs, vsub and 372 guests