copy file name and paste to field

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ted_drink_beer
Posts: 8
Joined: 30 May 2018, 03:28

copy file name and paste to field

Post by ted_drink_beer » 09 Dec 2021, 06:33

I created the script but there is a problem. The thing is that each file that needs to be opened has a different name. The script will be run from Coreldraw. How to create variable to get full file name from c:\graphics folder and paste into edit1 field

Code: Select all

SetTitleMatchMode, slow
DetectHiddenWindows, On
WinClose,  RIP Pro 
WinHide, RIP Pro
Run, C:\RIPPro\RIPPro.exe,, hide, PID
WinMinimize, RIP Pro
WinWait ahk_pid %PID%,, 3000
Process, Priority, %PID%, High
ID := WinExist( "ahk_pid" PID )
WinHide, RIP Pro, , 50
SetKeyDelay, 0
ControlSend,, Send ^o, ahk_id %ID%,
WinWaitNotActive, Open, ahk_id %ID%
ControlFocus, Edit1, ahk_exe RIPPro.exe
WinWait Open
WinHide
ControlSetText, Edit1 <- put file name 
WinHide % ahk_pid PID
ControlSend,,  {enter}, ahk_class #32770 ahk_exe RIPPro.exe

User avatar
mikeyww
Posts: 26596
Joined: 09 Sep 2014, 18:38

Re: copy file name and paste to field

Post by mikeyww » 09 Dec 2021, 07:05

Here are a few ideas.

Code: Select all

app = C:\RIPPro\RIPPro.exe
dir = C:\graphics
If !WinExist(winTitle := "ahk_exe " app) {
 Run, %app%
 WinWaitActive, %winTitle%
} Else WinActivate
Loop, Files, %dir%\*.*
{ Send ^o
  WinWaitActive, ahk_class #32770
  ControlSetText, Edit1, %A_LoopFilePath%
  Break
}

ted_drink_beer
Posts: 8
Joined: 30 May 2018, 03:28

Re: copy file name and paste to field

Post by ted_drink_beer » 09 Dec 2021, 07:28

works great :) but can you still add a feature that will open files by creation date ?

User avatar
mikeyww
Posts: 26596
Joined: 09 Sep 2014, 18:38

Re: copy file name and paste to field

Post by mikeyww » 09 Dec 2021, 07:42

Code: Select all

app = C:\RIPPro\RIPPro.exe
dir = C:\graphics
If !WinExist(winTitle := "ahk_exe " app) {
 Run, %app%
 WinWaitActive, %winTitle%
} Else WinActivate
Loop, Files, %dir%\*.*
{ FileGetTime, created, %A_LoopFilePath%, C
  If !(created ~= "^20210917")
   Continue
  Send ^o
  WinWaitActive, ahk_class #32770
  ControlSetText, Edit1, %A_LoopFilePath%
  Break
}

ted_drink_beer
Posts: 8
Joined: 30 May 2018, 03:28

Re: copy file name and paste to field

Post by ted_drink_beer » 09 Dec 2021, 08:03

works great :) thank you for your help

ted_drink_beer
Posts: 8
Joined: 30 May 2018, 03:28

Re: copy file name and paste to field

Post by ted_drink_beer » 09 Dec 2021, 08:26

thank you for your help

User avatar
mikeyww
Posts: 26596
Joined: 09 Sep 2014, 18:38

Re: copy file name and paste to field

Post by mikeyww » 09 Dec 2021, 09:14

You are welcome. Enjoy!

ted_drink_beer
Posts: 8
Joined: 30 May 2018, 03:28

Re: copy file name and paste to field

Post by ted_drink_beer » 22 Dec 2021, 16:33

mikeyww wrote:
09 Dec 2021, 07:42

Code: Select all

app = C:\RIPPro\RIPPro.exe
dir = C:\graphics
If !WinExist(winTitle := "ahk_exe " app) {
 Run, %app%
 WinWaitActive, %winTitle%
} Else WinActivate
Loop, Files, %dir%\*.*
{ FileGetTime, created, %A_LoopFilePath%, C
  If !(created ~= "^20210917")
   Continue
  Send ^o
  WinWaitActive, ahk_class #32770
  ControlSetText, Edit1, %A_LoopFilePath%
  Break
}
I recently had more time to test this macro and it turns out it doesn't quite work as I would like. What I want is to open files with creation date time and hour. At this moment my macro opens by name instead of time and date

User avatar
mikeyww
Posts: 26596
Joined: 09 Sep 2014, 18:38

Re: copy file name and paste to field

Post by mikeyww » 22 Dec 2021, 16:56

What is a detailed example?

ted_drink_beer
Posts: 8
Joined: 30 May 2018, 03:28

Re: copy file name and paste to field

Post by ted_drink_beer » 23 Dec 2021, 05:36

https://ibb.co/KKMm9Vc

As you can see in the attached image, the macro selects the file after the earlier time. I want to select a file that was created later

User avatar
mikeyww
Posts: 26596
Joined: 09 Sep 2014, 18:38

Re: copy file name and paste to field

Post by mikeyww » 23 Dec 2021, 06:37

You haven't specified which part the script should do, and which part you do. Does the script open files, or only display certain files for selection, or display all files but open only some of them, or.... ??? Explain step by step, one step at a time.

Post Reply

Return to “Ask for Help (v1)”