Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
Dear Members,
I have a question about adding a time stamp to a mapkey. We use a mapkey (seen below) to quickly make .jpg-files in an specific folder. We would like to make multiple files of the same part number, but this gives a failure because it cannot give the new file the same name as the previous one. We would like to add a time stamp (DD-MM-YYYY & Time) behind the file like : partnumer_11-02-2015_12:05.
mapkey jpg ~ Select `main_dlg_cur` `appl_casc`;\
mapkey(continued) ~ Select `main_dlg_cur` `appl_menu.left_pane.prepare_casc`;\
mapkey(continued) ~ Close `main_dlg_cur` `appl_casc`;~ Command `ProCmdRibbonOptionsDlg`;\
mapkey(continued) ~ Select `ribbon_options_dialog` `PageSwitcherPageList` 1 `colors_layouts`;\
mapkey(continued) ~ Open `ribbon_options_dialog` `colors_layouts.Color_scheme_optMenu`;\
mapkey(continued) ~ Close `ribbon_options_dialog` `colors_layouts.Color_scheme_optMenu`;\
mapkey(continued) ~ Select `ribbon_options_dialog` `colors_layouts.Color_scheme_optMenu` 1 `2`;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `OkPshBtn`;\
mapkey(continued) ~ Close `main_dlg_cur` `appl_casc`;~ Command `ProCmdModelSaveAs`;\
mapkey(continued) ~ Open `file_saveas` `type_option`;~ Close `file_saveas` `type_option`;\
mapkey(continued) ~ Select `file_saveas` `type_option` 1 `db_566`;\
mapkey(continued) ~ Activate `file_saveas` `mydocs_pb`;\
mapkey(continued) ~ Select `file_saveas` `ph_list.Filelist` 1 `Creo 2`;\
mapkey(continued) ~ Activate `file_saveas` `ph_list.Filelist` 1 `Creo 2`;\
mapkey(continued) ~ Select `file_saveas` `ph_list.Filelist` 1 `JPG`;\
mapkey(continued) ~ Activate `file_saveas` `ph_list.Filelist` 1 `JPG`;\
mapkey(continued) ~ Activate `file_saveas` `OK`;~ Open `shd_img_param` `o_dpi`;\
mapkey(continued) ~ Close `shd_img_param` `o_dpi`;~ Select `shd_img_param` `o_dpi` 1 `dpi600`;\
mapkey(continued) ~ Activate `shd_img_param` `OK`;~ Close `main_dlg_cur` `appl_casc`;\
mapkey(continued) ~ Command `ProCmdRibbonOptionsDlg`;\
mapkey(continued) ~ Select `ribbon_options_dialog` `PageSwitcherPageList` 1 `colors_layouts`;\
mapkey(continued) ~ Open `ribbon_options_dialog` `colors_layouts.Color_scheme_optMenu`;\
mapkey(continued) ~ Close `ribbon_options_dialog` `colors_layouts.Color_scheme_optMenu`;\
mapkey(continued) ~ Select `ribbon_options_dialog` `colors_layouts.Color_scheme_optMenu` 1 \
mapkey(continued) `Custom`;~ Activate `ribbon_options_dialog` `OkPshBtn`;
Thank you in advance!
Steffen,
I think that mapkey functionality does not enable you to do such trick.
AutoHotkey or AutoIt can help you. But you will need some time to learn these tools.
Martin Hanak
This can be done witha batch file that's called as part of the mapkey sequence. It's not hard, but you'll need to know some batch file programming.
Here's some snippets that might help you (we have batch files that create dated folders as well as rename exported files to append the revision or a custom suffix)
This creates a date based folder:
rem ** create destination folder
date /t > fulldate.txt
for /F "tokens=2 delims= " %%i in (fulldate.txt) do set today=%%i
set today > date.txt
for /F "tokens=2 delims=/=" %%i in (date.txt) do set MONTH=%%~i
for /F "tokens=3 delims=/=" %%i in (date.txt) do set DAY=%%~i
for /F "tokens=4 delims=/=" %%i in (date.txt) do set YEAR=%%~i
SET destination_folder=%YEAR:~-2%%MONTH%%DAY%_%long_type%
md %destination_folder%
del fulldate.txt
del date.txt
This finds the file name of a give type of file, assuming the %type% and %long_type% variables are set earlier in the file. It also assumes that there is only one file of that type in the folder (we use a temp folder for file processing):
rem ** generate list of %long_type% files
dir /b *.%type% > dir.txt
rem ** extract the %long_type% file name
findstr ".%type%" dir.txt > %type%.txt
for /F "tokens=1 delims=. " %%i in (%type%.txt) do set FILENAME=%%~ni
del dir.txt
del %type%.txt
This renames a file with a suffix, again assuming the variables are set earlier in the file:
rem ** rename file with suffix
rename %FILENAME%.%type% %FILENAME%%suffix%.%type%
This is the line from one of our mapkeys that calls a batch file:
mapkey(continued) @SYSTEMP:\\config\\00_design_central\\export\\dcex_temp_dir;\
dcex_temp_dir is a batch file with a .bat extension.
That should get you started, but you'll need to read up on batch files to piece this into something useful for your organization.
Doug,
Sorry for the late response, but this was very helpful!
Thanks very much.
I like Dougs answer very much. I too agree that Creo's mapkeys functionality doesn't have this manipulation capability. I made a small Pro/Web.Link page as a trial with our userbase some time back which would snap a picture (or pictures of all views) and paste/resize it into the active PowerPoint (and enter some properties about the static image to enable automatic future updating). Using a bit of J.Link it's easy to put your Pro/Web.Link apps underneath real buttons on your ribbons. Our users didn't really want automation and continue today using a variety of third party image capture tools though.
You may try with Autoit too. It's a nice tool to do this kind of stuff.
I would introduce a pause in your mapkey, call the autoit script to insert the timestamp, and then continue the mapkey.
Your mapkey modified:
mapkey jpg @SYSTEMStartc:\\creo-macros\\datestamp.exe; ~ Command `ProCmdRibbonOptionsDlg`;\
mapkey(continued) ~ Select `ribbon_options_dialog` `PageSwitcherPageList` 1 `colors_layouts`;\
mapkey(continued) ~ Select `ribbon_options_dialog` `colors_layouts.Color_scheme_optMenu` 1 `2`;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `OkPshBtn`;\
mapkey(continued) ~ Close `main_dlg_cur` `appl_casc`;~ Command `ProCmdModelSaveAs`;\
mapkey(continued) ~ Activate `file_saveas` `mydocs_pb`;\
mapkey(continued) ~ Activate `file_saveas` `ph_list.Filelist` 1 `Creo 2`;\
mapkey(continued) ~ Activate `file_saveas` `ph_list.Filelist` 1 `JPG`;\
mapkey(continued) ~ Select `file_saveas` `type_option` 1 `db_566`;@MANUAL_PAUSEpause;\
mapkey(continued) ~ Activate `file_saveas` `OK`;~ Open `shd_img_param` `o_dpi`;\
mapkey(continued) ~ Close `shd_img_param` `o_dpi`;~ Select `shd_img_param` `o_dpi` 1 `dpi600`;\
mapkey(continued) ~ Activate `shd_img_param` `OK`;~ Close `main_dlg_cur` `appl_casc`;\
mapkey(continued) ~ Command `ProCmdRibbonOptionsDlg`;\
mapkey(continued) ~ Select `ribbon_options_dialog` `PageSwitcherPageList` 1 `colors_layouts`;\
mapkey(continued) ~ Select `ribbon_options_dialog` `colors_layouts.Color_scheme_optMenu` 1 \
mapkey(continued) `Custom`;~ Activate `ribbon_options_dialog` `OkPshBtn`;
Autoit script:
Opt("WinTitleMatchMode", 2)
;create the datestamp string
$DateStamp = "_" & @MDAY & "-" & @MON & "-" & @YEAR & "_" & @HOUR & ":" & @MIN & ":" & @SEC
;Interaction with Creo windows
WinWaitActive("Mapkey Paused")
WinActivate("Save a Copy")
ControlClick("Save a Copy", "", "TextArea4", "", 2)
Send($DateStamp)
WinActivate("Mapkey Paused")
ControlFocus("Mapkey Paused", "", "")
ControlClick("Mapkey Paused", "", "Layout1", "primary")
Send("{ENTER}")
If the script doesn't work, your antivirus or firewall may be blocking it.
Have fun.
Jose