Ruby and GTK3 without console window in background - ruby

Hello Stackoverflow user's. this is my first question. :)
I'm using ruby and gtk3 to make a few GUI's for scripts that I use a lot. The problem I'm having is that when I run the script it opens the console window as well as the GUI, which in my mind defeats the purpose of a GUI.
I'm currently trying to run the scripts by executing them on my desktop.
I tried packaging it inside OCRA but that generated a lot of errors. I don't mind packaging or running the script directly as long as it doesn't open a console window, or at the very least closes it when it launches.
I'm using windows, and ruby 2.0.x.
Basically I don't want a DOS console window to open when I run my script.
I'm intermediate with ruby so please, clear instructions and simple solutions.
Thanks in advance.

Found a simple solution. Save the script with .rbw extension instead of .rb extension.
Hopefully this will help other newbies.

Related

Is it possible hide the console window of a JXCore packaged exe?

I've successfully packaged an exe application using JXCore
But, since such application will be called from another app, I need that when executed, the window console shouldn't appear
Is it possible?
This is not natively supported yet, but you may want to check the discussion Run executable in the background on that subject.
Someone made a VBS script for this, while someone else wrapped the app.exe into windows-service-like tool.

Livecode standalone program takes 30 seconds to load

I've run into an issue with a program I created using Livecode, and now I'm looking for some help from the experts. My Google-fu is strong, yet the answer eludes me...
So here's the deal. I made a very basic note-taking program for Windows only, using very noob skills. I've been using it daily for work for the past month at least. It functions exactly as it should, except for these few things that don't make sense:
When loading the program, it takes 25-30 seconds to load. Not convenient considering it's pretty basic; one button and 5-6 text input fields, with the same number of label fields. And one background. The button just clears the text input fields.
I started to notice a problem when I went to create a batch file to load all my work programs. When the program is loaded thru Command Prompt, if I close CMD it will close the program too. I tried the same using Powershell, and it still closes as soon as the Powershell window closes. Really really strange.
I managed to find another standalone program made with Livecode, downloaded it and tested the CMD command to see if the same thing happened. It didn't, that program loaded instantly and it is ENORMOUS. It also didn't close when I closed the CMD window. I even tried this: opened my program and the downloaded program using the same CMD session, and when I closed CMD, my program closed but the downloaded one did not.
Then, I downloaded the source code for the program that was working correctly. I created a standalone for it, and tried to open that. It acts the same way as my note program does.
I don't get it. It's got to be something in my Standalone Application Settings considering what happened in the last step I mentioned, and I've been over and over those settings for hours, but I just don't have the knowledge of LC to know what to look for. I've scoured the web looking for answers to this, but it seems to be just me having this issue (story of my life, lol).
I'll be happy to post any codes, scripts, or files needed, please let me know. I just don't know which things to post =P
Any suggestions are very much appreciated!! Thank you. =)
If you call the program from the prompt directly, e.g. using
C:\program files (x86)\your_standalone.exe
the app is treated as a command line app. I have also noticed that a LiveCode app can sometimes close if the invoking command line prompt is closed, while it may sometimes continue to run. Perhaps the handling of the relaunch message has to do with it, since this message basically handles commands from the command line.
If you want the command line process to finish independently from the invoked LiveCode application, you can use the start command:
start "" "C:\program files (x86)\your_standalone.exe"
don't have enough info to be able to tell what your issue is. But that much of a delay is not usual for LiveCode apps so something is definitely wrong. How long does your app take to load if you open the stackfile in the IDE?
Not sure what StackOverflow allows but if you could upload your scripts and if possible stackfile that will give us more to go on
This has nothing to do with Windows, Batchfiles, or CMD.
CMD can workaround your problem, if it's a GUI program. See Start command, and read the help as it explains the starting behaviour of CMD and CMD's Start.
Explorer has different rules. Anything else that starts programs call CreateProcessExW which has it's own rules.

Disable Terminal for Command Line Tool

I programm an artificial life simulation on my mac with Xcode in C++/OpenGL.
Due to the fact that my programm has a visual output in a seperated window,
I do not need the terminal, while running the concrete programm.
Nevertheless the terminal opens when I run my application throwing '/path/programm ; exit;' at its user. I guess that is for debuging? Or maybe standard because it is a command line tool?
So if I want to make a proper looking application out of it, which does not bother its users with command line outputs, what do I have to do?
If it is inherent of the command line tool to open the terminal do I have to migrate the source code to a cocoa app or Qt even though I yet do not need these build interfaces?
Thank you for your effort.
If I understood your question right, you don't want the terminal to be shown when the user double-click your app ?
In this case you should create a .app bundle and embed your binary into it.
I just tested with the basic "Hello world" Xcode command line template, it works fine.
You can use
#echo off
In the part off your code that requires the terminal.

When I try to launch a script, it opens and then immediately closes

I am trying to make a simple ruby script. However, when I run it, the command line opens, and closes almost immediately. I had the same problem with a visual basic console application, so I'm not sure if this is a problem with command prompt.
I am running Windows 8 with Ruby 1.9.3. Any help is appreciated.
This is a common symptom when developing command line applications on Windows, especially when using IDEs.
The correct way to solve the problem is to open the command line prompt or PowerShell manually, navigate to the directory where the program is located and execute it manually via the command line:
ruby your_program.rb
This is how command line programs were designed to be executed from the start. When you run your code from an IDE, it opens a terminal and tells it to execute your program. However, once your program has finished executing, the terminal has nothing to do anymore and thus closes.
However, if you open the terminal, then you the one telling it what to do, not the IDE, and thus the terminal expects more input from you even after the program has finished. It doesn't close because you haven't told it to close.
You can also use this workaround at the end of your Ruby script:
gets
This will read a line from standard input and discard it. It prevents your program, and thus the terminal, from finishing until you've pressed return.
Similar workarounds can be used in any language such as C and C++, but I don't think they are solving the actual problem.
However, don't let this discourage you! Feel free to use gets while you are learning. It's a really convenient workaround and you should use it.
Just be aware that these kinds of hacks aren't supposed to show up in production code.
Are you running from the command line or as an executable. Try placing a busy loop at the end to see the output or wait for keyboard input. If you run outside a command line the command line exits upon completion of the script.

Ruby compiler for mac?

so I made a program in ruby (using FXRuby as well if that changes anything) and I was wondering how I would compile it so that another person could download and use the program? Thanks
You don't need to compile it you can just run it as a ruby script,
start your file with #!/path/to/your/ruby/interpreter/bin
after changing it to the appropriate file and it should just launch from the command line
$ chmod +x ./my_ruby_script
$ ./my_ruby_script
However if you are devloping a full fledged application in ruby for the mac then consider using MacRuby which provides ruby-cocoa bridge. It can be found here
Ruby is interpreted, not compiled. The code itself will be what runs on another person's computer, provided they have a Ruby interpreter.
A quick Google search, however, turned up this. I've never used it, but it's an interesting idea. Basically it wraps the Ruby application code with the executable(s) and library(s) needed to run it into one single all-encompassing application.

Resources