GPS not showing GTKAda application on Build & Run - ada

I was wanting to play a bit with GPS am using the following program which is just from a template generated by GPS.
When I try to Build & Run I see no Window, however if I navigate to the folder where the executable was made, I can run the executable and see the window. I can see this tab was created, but I don't see my application.
with Gtk.Box; use Gtk.Box;
with Gtk.Label; use Gtk.Label;
with Gtk.Widget; use Gtk.Widget;
with Gtk.Main;
with Gtk.Window; use Gtk.Window;
procedure Main is
Win : Gtk_Window;
Label : Gtk_Label;
Box : Gtk_Vbox;
begin
-- Initialize GtkAda.
Gtk.Main.Init;
-- Create a window with a size of 400x400
Gtk_New (Win);
Win.Set_Default_Size (400, 400);
-- Create a box to organize vertically the contents of the window
Gtk_New_Vbox (Box);
Win.Add (Box);
-- Add a label
Gtk_New (Label, "Hello world.");
Box.Add (Label);
-- Show the window
Win.Show_All;
-- Start the Gtk+ main loop
Gtk.Main.Main;
end Main;
I even tried making sure my program was being ran, and put Ada.Text_IO.Put_Line("Hello, World!"); in the source, and it does seem to be running according to the Run tab.

It's because it is stuck in the Gtk.Main.Main loop.
To see the window you can use the Custom Run command (Shift + F2) and check the "Run in an external terminal" option.
Configure External 1
Click in Execute button and you gonna see the GtkWindow up and running.
Configure External 2
For more details please check:
The Build Menu - Using the GNAT Programming Studio

I had the same issue.
You need to add a “windows GUI” directive to the linker.
Go to Project/Properties, under Build/Switches/Ada Linker add this directives in the field
-Wl,--subsystem,windows
Or put it in your gpr file Linker section as follows:
package Linker is
case Library_Type is
when "static" =>
for Switches ("ada") use ("-Wl,--subsystem,windows");
when "static-pic" =>
when "relocatable" =>
end case;
end Linker;

Related

Execute command line statement in installshield / installscript

How do I execute the following command in installscript during installation?
netsh.exe advfirewall firewall show rule name="PowerSI (Release ASI 16.64)" || NETSH.EXE advfirewall firewall add rule name="PowerSI (Release ASI 16.64)" dir=in action=allow program="d:\Cadence\HIM_asi1664\ASI\Update4\SpeedXP\SpeedXP Suite x64\PowerSI.exe" enable=yes profile=any description="d:\Cadence\HIM_asi1664\ASI\Update4\SpeedXP\SpeedXP Suite x64\PowerSI.exe"
Note that the above command contains the executable name i.e. netsh.exe twice and this is where the problem is. I tried LaunchAppAndWait first by using the whole command as the name of executable and passing an empty string as argument. Next I tried was passing the first netsh.exe as program name and the remaining text as argument. Both the approaches did not work.
Since the question is regarding InstallScript specifically, here's a simple function for this purpose.
// prototype void CmdExecute( STRING );
//---------------------------------------------------------------------------
// Function: CmdExecute
//
// Purpose: Asynchronusly execute a command line statement in the background
//
//---------------------------------------------------------------------------
function void CmdExecute( szCommand )
begin
LaunchApplication( "cmd.exe", "/C " + szCommand, "",
SW_HIDE, 0, LAAW_OPTION_NOWAIT );
end;
In your specific case, if you need to execute a series of commands, or if you run into other complications, I suggest using a batch file instead. If need be, you can write one on the fly (to have a pure installscript solution without adding files to the project), run it via LaunchApplication (or the variations of that) and then delete it afterwards.
As a nice little trick, I like to make such a batch file delete itself. How? At the end of it, add this:
cmd.exe /C timeout 30 >nul & del "%0" /q
This starts a separate process, so the batch file in no longer in use. The full 30 second delay isn't really necessary, but has proven to always work for me in the past. You can adjust that time, if you want it to hurry up and finish. The point is to make sure the batch can be deleted, which it can't be if it's in use.
Custom Action Wizard --> Launch an Exectuable --> Stored in the Directory table --> SystemFolder (as source)
Then for Target do: cmd /c "SOMETHING",
where SOMETHING is replaced with your command. The only thing you would need to worry about is escaping all of the double quotes.
Then sequence the action after "Cost Finalize" in the execute sequence, and you should be good.
Haven't fully tested it, but should work.

Download file from firefox using autoit

I try to download file using Autoit from Firefox 28.0.
I try to download a exe file,popup flashed but autoit window info tool cannot recognize the save button.
how can i automate this.
My scripts looks like
Local $hWnd=WinActivate("[CLASS:MozillaDialogClass]")
WinWaitActive($hWnd)
;MsgBox(1,$hWnd,$hWnd)
;ControlClick($hWnd,"","Save")
ControlClick($hWnd,"&Save File","")
;WinClose("[CLASS:MozillaDialogClass]")
how can i automate this......
Right now both of your ControlClick attempts are incorrect. The correct syntax is ControlClick(Window title or handle, *window* text, control *id*, ...). Look at the helpfile and examples for it to see what you're not doing right currently.
The firefox download dialog is a little tricky, googling gives a lot of results for people who have tried to do the same thing and struggled.
The easiest method is to click the window at the coordinates of the button. ControlClick can be used for this (simply leave the control id blank). The AutoIt window info tool should give ControlClick coords when you try and select where the button is.
That method does assume that the button is always in the same place, which is not necessarily the case. Alternatives are to use ControlSend to send the Alt+S combination (or whatever it is for that button).
And finally, it's worth mentioning the IUIAutomation framework which has shown to be very reliable for automating windows that aren't using standard winapi controls.
The simplest way to do is as follows on mozilla:
Use the following code on autoit.au3 file
ControlFocus ( "MozillaDialogClass", "", "" )
Sleep(10)
Send("{ENTER}")
Execute the same file in selenium using:
Runtime.getRuntime().exec("C:\\Users\\Balaji\\Desktop\\autoit.exe");
Use the below code to download a file in Firefox using AutoIt.
WinWait("[TITLE:Opening ; CLASS:MozillaDialogClass]","", 10)
If WinExists("[TITLE:Opening ; CLASS:MozillaDialogClass]") Then
; Perform keyboard ALT key + s key to select Save File Radio button using keyboard shortcut.
ControlFocus ( "[TITLE:Opening ; CLASS:MozillaDialogClass]","", "" )
Send("!s")
; Wait for 2 seconds
Sleep(2000)
; Press Keyboard ENTER button.
Send("{ENTER}")
EndIf

Word wrapping in PyCharm Python Console?

Anybody here who knows, if and how I could enable word wrap in the Python console for long lines? I can't see them as a whole, I have always to scroll the window to the righit, to get all informations. I have only 5 Buttons offered: rerun, stop, close, execute current statement, help.
(in contrast to this, in Event Log, I see buttons called "Use soft wraps".)
for version 3.4.1:
View -> Active Editor -> Use Soft Wraps
I found the answer here:
File -> Settings -> Editor -> "Virtual Space" group -> Use soft wraps in console
In PyCharm version 2018.3.3 it can be found under
File -> Settings -> Editor -> General -> Console: Use soft wraps in console
In PyCharm version 2021.2.4 on OS X it can be found under
PyCharm -> Preferences -> Editor -> General -> Console
Starting with Pycharm Community Edition 2016.1, the settings mentioned in other answers are gone.
However, with the debug console opened (i.e. run your python script), click the Use Soft Wraps button there, this will also affect the python console, without any restart needed.
For PyCharm version 4.5, soft wrap can be enabled as a global default here:
File > Settings > Editor > General > Soft Wraps > "Use soft wraps in editor"
Community edition its Preferences>Editor>General>Use Soft Wraps in Editor
and then to be super cool you can go Preferences>Editor>General>Console>Use Soft Wraps in Editor
For Pycharm Professional 2016.3.2 on Windows:
Click on the upper half of the Python Console (i.e. the output half, not the input line at the bottom).
On the main menu select Help and Find Action... (shortcut: CTRL + SHIFT + A).
Type "soft" in the "Enter action or option name" search box.
Toggle "Active Editor: Use Soft Wraps" to On.
Run a new command with long output and you should see it soft wrapped in the Python Console. Note, that previous output will not be wrapped.
(None of the above methods worked for the Python Console -- though they did work for the Debug Console and Event Log)
As of 2018 - I found the setting here:
Settings -> Editor -> General -> Console -> Use soft wraps in console:

How to open a new file in vim in a new window

Is there a way to open vim in a new shell window or tab? I'm used to doing $ mate file, which opens the file in a new window.
I prefer having one 'central shell' where I issue commands and edit files in other windows or tabs, as necessary. How do people normally open vim files locally?
from inside vim, use one of the following
open a new window below the current one:
:new filename.ext
open a new window beside the current one:
:vert new filename.ext
You can do so from within vim, using its own windows or tabs.
One way to go is to utilize the built-in file explorer; activate it via :Explore, or :Texplore for a tabbed interface (which I find most comfortable).
:Texplore (and :Sexplore) will also guard you from accidentally exiting the current buffer (editor) on :q once you're inside the explorer.
To toggle between open tabs, use gt or gT (next tab and previous tab, respectively).
See also Using tab pages on the vim wiki.
I use this subtle alias:
alias vim='gnome-terminal -- vim'
-x is deprecated now. We need to use -- instead
If you don't mind using gVim, you can launch a single instance, so that when a new file is opened with it it's automatically opened in a new tab in the currently running instance.
to do this you can write: gVim --remote-tab-silent file
You could always make an alias to this command so that you don't have to type so many words.
For example I use linux and bash and in my ~/.bashrc file I have:
alias g='gvim --remote-tab-silent'
so instead of doing $ mate file I do: $ g file
I'm using the following, though it's hardcoded for gnome-terminal. It also changes the CWD and buffer for vim to be the same as your current buffer and it's directory.
:silent execute '!gnome-terminal -- zsh -i -c "cd ' shellescape(expand("%:h")) '; vim' shellescape(expand("%:p")) '; zsh -i"' <cr>
Check out gVim. You can launch that in its own window.
gVim makes it really easy to manage multiple open buffers graphically.
You can also do the usual :e to open a new file, CTRL+^ to toggle between buffers, etc...
Another cool feature lets you open a popup window that lists all the buffers you've worked on.
This allows you to switch between open buffers with a single click.
To do this, click on the Buffers menu at the top and click the dotted line with the scissors.
Otherwise you can just open a new tab from your terminal session and launch vi from there.
You can usually open a new tab from terminal with CTRL+T or CTRL+ALT+T
Once vi is launched, it's easy to open new files and switch between them.

Creating new shortcut in notepad++

I am trying to add a shortcut or a button in notepad++ to call an external program on the file I am currently editing.
For example, let's say I have the program "analyzer.jar". I would like to create a button (or shortcut) in notepad++ that would directly run the command "cmd -K java -jar analyzer.jar "$(FULL_CURRENT_PATH)".
Since I haven't found any solution yet, any help would be deeply appreciated :).
Well, in fact I found how easy it is to create a shortcut for a command:
Go in the menu and select "Run &rightarrow; Run..." (or press f5)
Type your command
Click on "Save", and select the keyboard shortcut of your choice
Sometimes, when you look for complicated solutions, you don't see the simple ones...

Resources