Wrong path while Read A_LoopFileTimeModified sheet

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
ivill
Posts: 124
Joined: 13 May 2016, 02:23

Wrong path while Read A_LoopFileTimeModified sheet

20 Sep 2017, 08:48

i'm going to create this script, it loads sheets and edit cell values one by one (read the lastest sheet in specific path, any other reliable idea for read/save .XLS sheet? ), however i met a read or save issue, see the pieces of script in the below, When the part "Loop F:\1\2b\2\*.*" starts, it won't read the true path(2\*.*), but it read the previous path(1\*.*)
i took all day to figure it out what's wrong with my script,
do i need to put

Code: Select all

file=
or other string to clear their value in each loop read path? in order to avoid wrong read situation? yes i have tried it, seems not work... please someone help! thanks

about the Sleep time: i'm trying to put some delay to test if this is the speed causing the problem
about the Clipboard:= and Sendinput, ^v : i need to input the string in uppercase(formatted in script), i found that if i use "Sendinput, string", it seems randomly input in lowercase, and i also found copy/paste might be reliable than sendinput.

Code: Select all

; something

Loop F:\1\2b\1\*.*
 If ( A_LoopFileTimeModified >= Time )
    Time := A_LoopFileTimeModified, Filename := A_LoopFileName
Sleep 300
StringTrimRight, Filename, Filename, 4
Sleep 300
if( RegExMatch(Filename, "(.*?)(\d+)$", spli) )
Sleep 300
spli2 := spli2 +1
Sleep 500
Loop F:\1\2b\1\*.*
 If ( A_LoopFileTimeModified >= Time )
    Time := A_LoopFileTimeModified, File := A_LoopFileFullPath
Sleep 200
run, %File%
WinWait, FH
WinWaitActive, FH
Sleep 1500
XL := Excel_Get()

;do something

SendInput, {F12}
WinWait, Save As
WinWaitActive, Save As
Sleep 1000
Clipboard := spli1 . spli2
Sleep 200
SendInput, ^v
Sleep 200
SendInput, {Enter}
Sleep 1500
SendInput, !{F4}
Sleep 1000
Loop F:\1\2b\2\*.*
 If ( A_LoopFileTimeModified >= Time )
    Time := A_LoopFileTimeModified, Filename := A_LoopFileName
Sleep 300
StringTrimRight, Filename, Filename, 4
Sleep 300
if( RegExMatch(Filename, "(.*?)(\d+)$", spli) )
Sleep 300
spli2 := spli2 +1
Sleep 500
Loop F:\1\2b\2\*.*
 If ( A_LoopFileTimeModified >= Time )
    Time := A_LoopFileTimeModified, File := A_LoopFileFullPath
Sleep 200
run, %File%
WinWait, FH
WinWaitActive, FH
Sleep 1500
XL := Excel_Get()

;do something

SendInput, {F12}
WinWait, Save As
WinWaitActive, Save As
Sleep 1000
Clipboard := spli1 . spli2
Sleep 200
SendInput, ^v
Sleep 200
SendInput, {Enter}
Sleep 1500
SendInput, !{F4}
Sleep 1000
Loop F:\1\2b\3\*.*
 If ( A_LoopFileTimeModified >= Time )
    Time := A_LoopFileTimeModified, Filename := A_LoopFileName
Sleep 300
StringTrimRight, Filename, Filename, 4
Sleep 300
if( RegExMatch(Filename, "(.*?)(\d+)$", spli) )
Sleep 300
spli2 := spli2 +1
Sleep 500
Loop F:\1\2b\3\*.*
 If ( A_LoopFileTimeModified >= Time )
    Time := A_LoopFileTimeModified, File := A_LoopFileFullPath
Sleep 200
run, %File%
WinWait, FH
WinWaitActive, FH
Sleep 1500
XL := Excel_Get()

;do something

SendInput, {F12}
WinWait, Save As
WinWaitActive, Save As
Sleep 1000
Clipboard := spli1 . spli2
Sleep 200
SendInput, ^v
Sleep 200
SendInput, {Enter}
Sleep 1500
SendInput, !{F4}
Sleep 1000
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Wrong path while Read A_LoopFileTimeModified sheet

20 Sep 2017, 09:35

I might have missed something, but are your Loop's really only setting those two variables (beside that it will only catch the last match that way)? I'd guess it should have been something like this ...

Code: Select all

Loop, F:\1\2b\1\*.*
{
several lines of code
}
:?:
User avatar
ivill
Posts: 124
Joined: 13 May 2016, 02:23

Re: Wrong path while Read A_LoopFileTimeModified sheet

20 Sep 2017, 09:46

BoBo wrote:I might have missed something, but are your Loop's really only setting those two variables (beside that it will only catch the last match that way)? I'd guess it should have been something like this ...

Code: Select all

Loop, F:\1\2b\1\*.*
{
several lines of code
}
:?:
Hi BOBO, are you saying i shall separate them with {}?

is that simple? ...shocked...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], mstrauss2021, robozao, TAC109 and 239 guests