Trigger close event for Rebol Console? - rebol

How to trigger close event for Rebol Console to execute some custom handler before one quit the console ?

Well, I don't understand why you need this. If you're running a script from the console, then surely your script "knows" when it is about to quit.
Maybe you're after a system shutdown or similar? In that case you need to look at the system ports.
See http://www.rebol.org/ml-display-thread.r?m=rmlNFFJ
for an example of trapping the shutdown event for different OSes.

AFAIK REBOL doesn't offer a hook for that. And if you wanted to do it with a system port hook, you would have to have an event loop running.
If you have behavior you want to trigger, the first thing I would do is add a simple SHUTDOWN mezzanine, to replace QUIT, and do your work there. You could view that as a feature or a limitation, meaning the user can avoid your logic by using the close button if they want.

Related

Create a background proccess that terminates a program on KeyPress (VB 2013)

I'm look for code which can help me accomplish what the title suggests.
I want this because I have an issue with a program which is quite buggy (it's a game), and if It freezes, and results in a black screen. Even after using Shift+Ctrl+Esc, Ctrl+Alt+Del, Alt+F4 and the rest of them, I acn't seem to end the program. So I thought that a KeyPress event would work, as it doesn't require me to use the UI in any way.
However, I've never used VB for anything other than Form's, so I have no idea how to start on something which runs in the background.
Thanks :)
A background app won't help in this case.
Ctrl+Alt+Del is specail key combo that is handled directly by Windows and can't be intercepted by a running program.
What this means is that if your game locks up and Ctrl+Alt+Del doesn't bring up the Windows menu, then the game has corrupted the system. The only fix at that point would be a restart.
That being said, you can kill a running process using VB.NET like this:
For Each program As Process In System.Diagnostics.Process.GetProcesses
If program.ProcessName = "ProcessName" Then
program.Kill()
End If
Next
Read more about it on the MSDN.
Okay, so Windows isn't actually locking up, but you just need some way to kill the process. Use the above code, replacing "ProcessName" with the name of your game process, and then either:
(basic) Turn the VB.NET code into an .exe file. Then set up a keyboard macro (using your keyboard software or some freeware) to launch the .exe you made which will kill all running instances of the given process. or...
(advanced) Import "user32.dll" into the VB.NET code, call SetWindowsHookEx with a hook id of 13, a pointer to a LowLevelKeyboardProc function, the handle to your running program, and a thread id of 0. Then, whenever a key is pressed in any program, your KeyboardProc function will be invoked. If the key(s) pressed match your desired kill-key combo, then run the above process killing code. This looks like it may give you more step-by-step instructions.

Program to respond to Keycodes while minimized

I need a program to respond while not active/not selected by user or minimized to KeyCodes.
Anyone got ideas? In VB.NET.
This won't work out of the box as key messages are only sent to the active window. A minimized window is never active.
What you could try is register system-wide hotkeys. You could also try to install a keyboard hook, however, this would affect the entire system and your application would receive all the keystrokes performed. This would require efficient filtering.

how to update a Rebol3 GUI from a network event

I have written a test GUI application to see how to update a R3-GUI from a network event.
The server port receives the event from a client, but using
set-face window-inputarea msg
fails to update the GUI unless I also mouse over or otherwise generate a GUI event. This then seems to kick off outstanding event handling.
Do I need to send a simulated GUI event to allow this to happen programatically or is there another way?
There's a bug in the area style so that set-face in this instance does not update the face.
I've updated the example to show it working.

how to click on WebArea from QTP ?

In My test I want to click on object of Type WebArea which opens a webelement popup includes some fields that i need to test.
the problem that the popup not open after I click on WebArea object through the code.
the code I use as below.
Browser("WW").page("assessment").WebArea("areaassessment").Click
nothing hapens after the above line excuted.
Look into the HTML of the WebArea and see what action is triggering the popup. Normally it has something like onclick='showPopup();', but in other cases it is onmousedown or onmouseup.
If this is the case, you have to setup QTP accordingly. There are multiple roads to walk here, one is to see how you advanced web settings are configured. Go to Tools>Options>Web>Advanced and look in the Run Settings.
Setting the Replay Type to Event will replay your scripts by events (by default mousedown, mouseup and then mouseclick) or by mouse (You'll see your mouse pointer moving in this mode, QTP will replay by sending WM_* messages through the Windows api for movement to the correct screenlocation and triggering the click).
Allthough it replays a bit faster, if Run only click is checked, it is better to uncheck this to trigger all events / messages.
Events can also be fired by the FireEvent method:
Browser("WW").page("assessment").WebArea("areaassessment").FireEvent("onclick")
or through the object native methods:
call Browser("WW").page("assessment").WebArea("areaassessment").Object.click()
call Browser("WW").page("assessment").WebArea("areaassessment").Object.FireEvent("onclick")
As #AutomateChaos said there is probably an event that QTP isn't simulating, one way to work around this is to do as #AutomateChaos suggests and simulate the needed event. A simpler way is to change to device replay (as I described here and here).

NSAlertPanel problems

I am designing an application to connect remotely to another computer. I want to display an NSAlertPanel on connecting however it is 'blocking' the remote side from continuing with the session until OK is pressed with the usual NSAlertPanel setup.
Is there a way to have an NSAlertPanel which is non-blocking? Thanks.
When you run your alert panel modally, you block the run loop of the associated thread, which is the main thread in this case.
To display a window on connection, you can use custom sheets. It's easy to use and explained in the documentation page below:
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Sheets/Tasks/UsingCustomSheets.html
However, if you need to run your alert modally, an alert that is blocking interactions with the whole application, you may need to move your connection part to another thread, which is a good practice in both cases.