P.I. Engineering User Forum

Product Support, Technical Questions and Answers, and Examples for P.I. Engineering Products

You are not logged in.

#1 2017-03-14 14:20:14

skmcrodgers
Member
Registered: 2017-03-14
Posts: 15

Shortcut Key says file already open

I have a monitor in our foundry conference room connected to a pc down the hall and I have the xkeys keypad mounted beside the monitor.  the general manager and plant manager wanted to be able to just press the key on the keypad to open different exel sheets to show graphs of different foundry readings etc.. I have each key programmed as shortcut to open the separate excel sheets (graphs) and each time you press to view each graph (file) it works great for the first round. but say they want to go back and view one they already viewed it pops up and says this file is already been opened if you continue it will not be saved and basically you open a new sheet again.. we do not want this .. is there a way to write the shortcut or add a macro to tell it that if the file is already open to just select it when the key is pressed instead of it trying t open a new file that is already opened? and honestly most always the file will always be open for all the files so the shortcut for each should always just bring the file to the front for the key pressed instead of attempting to open a new file.. hopefully this makes sense and is not confusing.  is there a way to do this? thank you for any and all input...

Offline

#2 2017-03-16 07:37:56

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 196
Website

Re: Shortcut Key says file already open

Hi,

To do something like this would take some custom scripted logic (you would need to edit our script file by hand). This uses Visual Basic. There's no way to program something like this through our interface.

If you would like more information on how to do this (if you're familiar with VB), check out the Advanced Help file through the Help menu. There is a "Window to Front" command you can use to bring a window forward.


Amber from P.I. Engineering

Offline

#3 2017-03-16 08:34:17

skmcrodgers
Member
Registered: 2017-03-14
Posts: 15

Re: Shortcut Key says file already open

Sounds great... I will look into that.. yes I have done VB programming a few years ago... will have to do a little refreshing but good to know it is possible.. thank you !!

Offline

#4 2017-03-16 09:54:35

skmcrodgers
Member
Registered: 2017-03-14
Posts: 15

Re: Shortcut Key says file already open

quick question where do you edit ya'lls  script? where would I insert the code for my script? thanks

Offline

#5 2017-03-16 10:30:25

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 196
Website

Re: Shortcut Key says file already open

No problem. Go to Window > Script Code within MacroWorks 3.1, which is the recommended way to edit.

Your script also lives in a hidden location in Windows:
C:\Users\YOUR USERNAME\AppData\Local\PI Engineering\MacroWorks 3\MyScripts\YOUR DEVICE\Script_PID_UID.mw3

If you edit outside of MacroWorks by directly opening the file you will need to restart MacroWorks completely for your changes to show.


Amber from P.I. Engineering

Offline

#6 2017-03-16 13:54:27

skmcrodgers
Member
Registered: 2017-03-14
Posts: 15

Re: Shortcut Key says file already open

thank you.. I have the window to front working great.. I have another quick question though...  most of the time the file will always be pen and not minimized.. however, say the file was not open is there a way to program the script for the same button to use the shortcut to open the file if it is not open and if it is open it just brings to the front?  can you program 2 separate programs for the same button?   I was wondering if you can put the code in for the window to front then have the else statement next with the shortcut key then after it have the release code?  I am probably way out of line here just trying to insure this program is full proof.. 90% of the time the sheets will always be open and not minimized so not a bg problem if this is not possible but if it is I would like to ode it that way.. thanks again for all your input..

Offline

#7 2017-03-16 14:24:33

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 196
Website

Re: Shortcut Key says file already open

There's two variables we already track: AppName and AppTitle

Using those you can create a decision structure similar to our application sensitive programming. Syntax not guaranteed to be actual code (it's from memory and has not been explicitly tested). All of this goes under the "If State 'Pressed" part of your button:

MW3.WindowToFront("My Title Text")
MW3.Delay("500")

If (AppTitle = "My Title Text")
     'the keystroke action that needs to be performed
Else
     'if your title text didn't match
     MW3.Shortcut("file\path\to\document")
     MW3.Delay("500")

     'the keystroke action that needs to be performed
End If


Amber from P.I. Engineering

Offline

#8 2017-03-16 14:27:30

skmcrodgers
Member
Registered: 2017-03-14
Posts: 15

Re: Shortcut Key says file already open

i'll give that a shot..thank you...!

Offline

#9 2017-03-16 16:18:36

skmcrodgers
Member
Registered: 2017-03-14
Posts: 15

Re: Shortcut Key says file already open

I got it working kinda.. it looks like it is opening it every time not just bringing it to the front but at least it is no longer prompting me that the file is already open .. I couldn't get the example you had exactly working but I used it and played around to get what I have going for a successful build.. here is the code if you happen to see anything that jumps out at you that would be great if not I can live with this and I appreciate all the help !!!

If State 'Pressed    [MWTAG10]
MW3.WindowToFront("Foundry Lab Report - Green Strength.xlsm")
If (AppTitle = "Foundry Lab Report - Green Strength.xlsm")
     'the keystroke action that needs to be performed
Else
     'if your title text didn't match'<Shortcut[P:\lab\CHARTING SAND\Foundry Lab Report - Green Strength.xlsm]>
                MW3.RunApp("P:\lab\CHARTING SAND\Foundry Lab Report - Green Strength.xlsm","")
                '</Shortcut[P:\lab\CHARTING SAND\Foundry Lab Report - Green Strength.xlsm]>
         'the keystroke action that needs to be performed
End If
Else 'Released       [MWTAG11]
      End If 'Press-Release [/MWTAG10/MWTAG11]

Offline

#10 2017-03-16 16:46:16

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 196
Website

Re: Shortcut Key says file already open

I think you need delays in the spots I mentioned in order for it to work properly. Without the first delay it probably doesn't have time to bring the window to front before testing if it's in front.


Amber from P.I. Engineering

Offline

#11 2017-03-16 16:49:24

skmcrodgers
Member
Registered: 2017-03-14
Posts: 15

Re: Shortcut Key says file already open

ok thnx... will try it again.. I tried it first time and got an error about delay not macro or something but I probably did it wrong.. thnx for the input and I will give it another shot..

Offline

#12 2017-03-16 16:52:11

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 196
Website

Re: Shortcut Key says file already open

Sorry about that, it was all from memory. My syntax was incorrect:


MW3.insertDelay(500)


Amber from P.I. Engineering

Offline

#13 2017-03-17 09:05:44

skmcrodgers
Member
Registered: 2017-03-14
Posts: 15

Re: Shortcut Key says file already open

I am trying that again and I am trying it just like you have it to see if it will prevent the re-opening , even though that works .. my question is it tells me 'Shortcut' is not a member of 'Interfaces'.MW3'  is there another way to do the MW3.shortcut ? the way I did it before was the same as if you simply did a shortcut but I was wondering in your example if I could try it with just the line shortcut.MW3 and the path ..  I have tried to search in the advanced help for the correct syntax for the shortcut but couldn't find anything other than these 3 lines for a simple shortcut.. is there another part I need to add to the wording on this one? MW3.shortcut ? thank you again... if not I have it working regardless.. I have corrected the delay by adding insert and it builds successfully but still reopens the file instead of just bringing to the front, but again it does not prompt for file already open so I am ok with it.. but if I could get it to check if the file is open and just bring to front if not then open it, then it would be wrinkle free ! :)

Offline

#14 2017-03-17 10:02:45

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 196
Website

Re: Shortcut Key says file already open

Sorry, again what I sent was not real code -- that's why I had a disclaimer. You will use MW3.RunApp just as you did. There is no other shortcut function.

If it is still reopening the file I would double-check your title text and make sure you haven't skipped anything or left anything off. It has to be whole and exact.


Amber from P.I. Engineering

Offline

#15 2017-03-17 10:08:45

skmcrodgers
Member
Registered: 2017-03-14
Posts: 15

Re: Shortcut Key says file already open

trust me your suggestions have been huge help.. I understood the disclaimer and I do apologize for bugging you.. I appreciate all the help..

Offline

#16 2017-03-17 10:23:37

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 196
Website

Re: Shortcut Key says file already open

No problem at all and definitely no bugging. :)


Amber from P.I. Engineering

Offline

#17 2017-03-28 16:49:35

skmcrodgers
Member
Registered: 2017-03-14
Posts: 15

Re: Shortcut Key says file already open

is it possible to program these functions on windowtofront in hardware mode? I had this working good on my pc but then moved it to another pc and did the script the exact same and it will not work on the other pc.. wiped it out and reprogrammed it and it still wont work right.. not sure if it marries the pc it is setup on in software mode or not? but if I can do it in hardware mode so it wont matter what pc is used that would be best anyway.. just not sure how to edit the script in hardware mode or do you do it the same in hardware mode by going to windows script code? thank you again !

Offline

#18 2017-03-28 17:06:53

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 196
Website

Re: Shortcut Key says file already open

Unfortunately no, that kind of detection of a window requires software mode. The best bet would be to try to troubleshoot it on the specific computer it's not working on.

When you reprogram it, try starting with nothing in your script, then choose your program from the drop down. Likely the name we're looking for has changed on your other PC, so it does not fully carry over. This can be different from OS to OS and from software version to software version, but once we have the name of your new one a search and replace in Notepad can edit your entire script file.


Amber from P.I. Engineering

Offline

#19 2017-04-04 09:40:51

skmcrodgers
Member
Registered: 2017-03-14
Posts: 15

Re: Shortcut Key says file already open

once i have this script working on my pc is it possible to copy the entire script to another pc and it work? or does it need to be edited for a different pc name or anything? the files they will be using this script for is the exact same files I programmed it for on my pc.. so the exact same thing needs to be on the other pc.. my question is can I copy the script to the other users location or do I have to reprogram the entire script? f i can copy it here is the script located? I was thinking in the app data folder or somewhere? thanks again !!

Offline

#20 2017-04-04 09:45:15

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 196
Website

Re: Shortcut Key says file already open

You need to go to File > Save Copy and it will generate a copy of the script file for you to carry to a new PC.

Note that the program name (how application specific programming works) can change depending on OS or the version of the software you are using. That would break it. However, it's not a given and should be transferable if the name is the same. If application specific programming is not working correctly, it's likely because the name of the application in Windows has changed (not the same as its marketing name) and we can work to figure out how to solve it so you do not need to reprogram completely, as I mentioned before.


Amber from P.I. Engineering

Offline

#21 2017-04-04 10:02:40

skmcrodgers
Member
Registered: 2017-03-14
Posts: 15

Re: Shortcut Key says file already open

they both are win 7 pro... and thank you!

Offline

#22 2017-04-04 10:47:01

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 196
Website

Re: Shortcut Key says file already open

Are you still having problems? Let me know if you continue to have any issues.


Amber from P.I. Engineering

Offline

#23 2017-04-04 12:07:25

skmcrodgers
Member
Registered: 2017-03-14
Posts: 15

Re: Shortcut Key says file already open

i'm not sure.. will be this afternoon before I can test it again.. thank you for checking !

Offline

#24 2017-04-07 16:05:25

skmcrodgers
Member
Registered: 2017-03-14
Posts: 15

Re: Shortcut Key says file already open

quick question is there a way to simulate remotely the buttons being pressed to test the key pad without actually being at the key pad? if not no big deal just curious if I could do that? I am working on fixing the issue and haven't been able to work on it till now and was going to see if I could do remotely.. thank you

Offline

#25 2017-04-10 07:37:51

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 196
Website

Re: Shortcut Key says file already open

No, we do not have a way to simulate a button press.


Amber from P.I. Engineering

Offline

Board footer

Powered by FluxBB