How to open a file in an external program? - labview

All I want is to open a file, test.txt, in notepad and keep it open. Although, this is proving more difficult than I'd expect. I run the code and expect the file to open; however, nothing appears. I experimented with opening the file in the terminal but this will not work in the larger context of my program. Please point out the obvious if I'm missing it
Here's the block diagram

The code you posted opens a file as a reference for read/write inside the LabVIEW program, not with notepad. To open it in notepad, you have to issue an exec, with System Exec.vi that launches notepad.exe, and give the file as an argument:
Also instead of looping on listening to the stop button, use an event loop, it's better when you'll write more complex code.

Related

Why does my VBA procedure sometimes stop in debug mode?

I have a button click event in an Access form that sometimes opens the VBA editor with the 'On Error...' line highlighted as if it is in debug mode. I can F5 to continue the rest of the procedure and it works fine.
It doesn't happen everytime. It seems random except there seems to be a pattern that it happens on the first click of this button right after the file is opened. Not everytime though.
Any thoughts on this or previous experience with the same thing happening and subsequent solution? What might be causing this? It's a terrible user experience.
Well, before running any code (hold down shift key during startup to prevent any code from running).
Now, ctrl-g (jump to VBA IDE). Now from tools. Choose
debug->Clear all Breakpoints
Like this:
Now, open up any code module - hit enter key to "dirty" the code. Now choose debug->Compile (first menu option). It will say Compile "my app name".
Make sure the code compiles. If it does not, then stray break points can still exist.
Next up, you need to check/change the default behavior for a error.
While STILL in VBA editor/IDE
From menu bar choose tools->options. The default is "Break on Unhandled errors"
If you have break on ALL Errors? Well then code that even assumed to trap or even on-error resume next code it BLOW UP and stop. Often developers will say try for existence in a collection, and we error tap to "mean" the element is not in that list. However, the THIS assumes that the default Error trapping setting was not change.
So, double, and then triple check this setting. You can develop for years, and even have some code ASSUME to error out. But that years of development code assumed the default (break on unhandled Errors. If you have break on all errors, then your are toast, and you find all kinds of breaking of code. (the idea of that option is to LET you debug code with error handling without having to disable errors. And with say on-error resume next, you in effect can't debug parts of code anymore.
Now, if above steps don't fix your issues?
Then the next step is to de-compile your application. This will remove the compiled (binary) part of the application. Once you do this, then you do a full re-compile.
To de-compile, you can't do this from the IDE, and you have to use a FULL qualified path to your existing version of access. Say like this:
"C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE"
"c:\MyCoolApp\Invoice.accDB" /decompile
Now, when you run above, you REALLY must not let any startup forms or code run. (hold down shift key. Now exit access/application. Now re-launch (and again no code to run on startup).
Now, at this point I high recommend a Compact+ Repair (and AGAIN no startup or code to run). So even on the C+R, you have to hold down shift key.
If you during the decomp, start application, then C+R allow ANY code to run, then you have to start over again at the first decompile step.
Ok, now you done the C+R. Now ctrl-g, and now debug-compile.

Is there a method for script file loading control in labview?

first, I cannot attach my vi files, sorry. I'm not allowed, but I can attach snippets.
I've got a vi that opens and executes functions from a script file, and I'd like to be able to continuously click a button to reload the script file without having to restart the program. Currently the script file commands sit outside my main while loop and and uses a case statement to put the system in idle mode (manual control) when the button is not depressed before launching the program, or if it is, it will instantly open a dialog box looking for a script file upon program launch. I'd like to be able to open a script file numerous times during the execution of my program, but don't fully understand how, and this may be my own misunderstanding of what's going on with the code if I move it inside the main while loop. how is this best accomplished?
If you put your code outside of the loop, it is only executed once (very important: "dataflow"). You need to put the code into a loop to execute it multiple times.
You can insert the vi-snippet into your vi by drag&drop.
My vi contains two different options. You can change the vi as you need it, my vi is incomplete. I inserted a simple 2D-Array because I'm not sure if the vi you use after building the path is selfmade or given by LabVIEW.
For both options you should let the code run in some kind of state machine and use an Event Structure (I think you already implemented your program this way since you wrote about a main loop).
Version 1:
Everytime you click the button, the event is triggered and the code inside the event structure is executed.
Version 2:
Here you set a boolean if the button is pressed and handle the event with that value.
Since you wrote that you already have a main while loop, this option might be better four you. The first loop would be your main-loop, second one would be the loop in Version 2. You just need to add another case for the script to be loaded in.
VI:
I hope this is helpful for your problem.
Feel free to ask if you need more help or if you have any questions :)

How to use SendKeys. Send("UP") to sending "up" arrow key to applications except notepad?

I am using line code under detail for up arrow key to type "UP" in notepad
SendKeys.Send("UP");
This is working exactly in My notepad process but
I need use The above Line code in another application except notepad like games
I had guess The notepad process should be change to another process that i would like work on it but
was not good and not work in my game process
Any suggestion can be useful

How can i automate my computer?

On windows 10.
I need to automate the repeated process of these steps.
1. Open up an image in GIMP. Scale it to 110%.
2. Export as somefile name(for example input001.jpg).
3. Go to http://deepdreamgenerator.com/ in a browser. click on button, browse to the exported file.
4. Wait for it to generate result, save image as result file (for example dream001.jpg).
then repeat from step 1 with the result file from step 4...but keep increasing the filename number so export it as input002.jpg...
What software would allow me to do this?
the only software i know of that * MIGHT * be able to automate that process is AutoHotKey
You would need to keep the windows which you're automating static (ie. make sure they don't move) and then write keyboard and mouse macros in autohotkey to press the buttons and do the things you want.
I tried AutoHotKey but didn't feel like learning a whole new scripting language so I found something simpler called GhostMouse.
It just has record,play,stop buttons.
after recording and closing out of program it asks if i want to save script. clicked yes gave it a name, and then edited the script file..and copied and pasted as many times as i wanted the script to run (before copying and pasting i deleted the last 3 lines which has to do with clicking the stop button which i didn't want the script to do).
You can also try Sikuli for same. It's an image comparator
http://www.sikuli.org/
Reference :-
http://doc.sikuli.org/tutorials/

Ms Access CHM Help File Can't Get Focus

I'm opening a custom help file (CHM) using VBA and the api 'HtmlHelp', eg:
hWnd = HtmlHelp(Application.hWndAccessApp, sFile, HH_HELP_CONTEXT, context_id)
The Help file opens, but it's hidden behind the Access window, and although it's icon is displayed in the Taskbar, clicking the icon still does not bring it to the foreground - it remains hidden behind Access.
When I first started testing the Help file (on a Win8.1 machine), it opened correctly in front of the Access window, but now it won't. Does anyone have any suggestions as to what is causing this behaviour?
Some thoughts only - but be careful with the first hint:
Which purpose does the file hh.dat serve?
The hh.dat file stores user-specific information on all the HTMLHelp files (*.CHM) on your system (position, favourite topics, search history, etc.), and can cause a error if it has somehow been corrupted.
Delete or rename the file hh.dat to reset all (!) CHM windows on your system to their default settings.
You should find hh.dat in this directory:
\Documents and Settings\%username%\Application Data\Microsoft\HTML Help
Windows will create a new version of hh.dat when you next open any .chm file.
According to Microsoft's HTML Help API documentation (http://msdn2.microsoft.com/en-us/library/ms644703(VS.85).aspx):
Any help window that you create through the HTML Help API is owned by the calling, or parent, program. This allows the help window to stay on top of its parent, yet not be on top of any other program that has focus.
So the fact that the help window retains focus is actually the standard behaviour.
If you look at a typical HTML Help API call, you'll see that the first parameter specifies the "handle" of the window from which help is called:
HtmlHelp(hwndCaller,"YourHelpFile.chm",HH_HELP_CONTEXT,1001);
If the developer passes "null" rather than the window handle as the first parameter of the call, the help window is no longer owned by the calling program, and so does not retain focus. Here is an example of a modified call:
HtmlHelp(0,"YourHelpFile.chm",HH_HELP_CONTEXT,1001);
There's a drawback to this, though: when called in this way, the help window is no longer bound by the actions of the calling program. So if the user closes or minimises the program, the help window isn't closed or minimised as well.
I see you have hWnd – do you think you can add a code to send the help window to the foreground programmatically?
You can call SetForegroundWindow() to do the job. Someone has solved similar problem already, you just need to port call to SetForegroundWindow() or SetForegroundWindowNative() into the VBA.
EDIT: You report weird behavior that SetForegroundWindow() makes help window to flash only briefly.
Try issuing VBA's AppActivate command – it has helped someone else.
If this problem persists, you can try some workaround like resizing your app and help window to show them side-by-side.