Just a little tidbit to offer

Just a little tidbit to offer

Post by Lee Peedi » Thu, 02 Dec 2004 05:18:50


Watch for line wraps

/* popup.rex */

WS = .oleobject~new("Wscript.Shell")
WS~Popup("This Popup Will Stay On The Screen 3 Seconds or Until OK Is
Pressed", 3)

WS~Popup("This Popup Will Stay On The Screen Until OK Is Pressed",-1)
 
 
 

Just a little tidbit to offer

Post by Lee Peedi » Thu, 02 Dec 2004 11:10:25

On Tue, 30 Nov 2004 20:18:50 GMT, Lee Peedin


Here was Mark Hessling's response to this - decided I post it before
he did :-)


Sorry, couldn't resist ;-)

Using Patrick's W32Util and Regina:

/* popup.rex */
Call rxfuncadd 'w32loadfuncs','w32util','w32loadfuncs'
call w32loadfuncs

ws = w32createobject('Wscript.Shell')
call w32callproc ws, 'Popup', 'si' , 'This Popup Will Stay On The
Screen 3 Seconds or Until OK is Pressed', 3
call w32callproc ws, 'Popup', 'si' , 'This Popup Will Stay On The
Screen Until OK is Pressed', -1

call w32olecleanup

Cheers, Mark

 
 
 

Just a little tidbit to offer

Post by Anthony Bo » Thu, 02 Dec 2004 15:44:07

Lee Peedin" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...

Mark, and all,

<SNIP>

Your small example actually highlights, I think, one of REXX's great
strengths, that of allowing an author to create simple-to-use interfaces to
system functionality, thus helping, among other things, REXX script authors
avoid the need to resort to lower level languages like C to provide this
access.

I only recently downloaded the W32Util package and have been happily
experimenting with it. In my explorations of this package I was especially
taken by the w32FuncAdd function which allows for adhoc access to DLL-based,
Win32 API.. Despite warnings in the documentation about it being untested
and so forth, based on issuing a dozen-odd Win32 API calls, it appears to
work quite well. Once again, a simple-to-use, really quite handy piece of
code that has the potential to avoid much work.

It is in my experiments with the w32FuncAdd function that I've lately
encountered problems. Specifically, I wanted to access the 'MapVirtualKey'
and 'keybd_event' API's, using the combination to pump keystrokes [well,
techically, keyboard events :)] to a another console window; the keystrokes
would invoke the window's menu, and select and store all window text in the
clipboard. The invoking script would then be able to use the W32Util
clipboard function(s) to retrieve the copied text.

Now, this is an exceedingly trivial task, and can easily be coded in C; an
excerpt from working C code:

HWND currentWnd;
...
currentWnd = GetConsoleWindow();

SetForegroundWindow(
FindWindow("ConsoleWindowClass","XYZ"));

/* ALT-SPACE */
keybd_event(VK_MENU,
MapVirtualKey(VK_MENU,0),0,0);
keybd_event(VK_SPACE,
MapVirtualKey(VK_SPACE,0),0,0);
keybd_event(VK_SPACE,
MapVirtualKey(VK_SPACE,0),KEYEVENTF_KEYUP,0);
keybd_event(VK_MENU,
MapVirtualKey(VK_MENU,0),KEYEVENTF_KEYUP,0);

/* E-S */
keybd_event('E',
MapVirtualKey(VK_E,0),0,0);
keybd_event('E',
MapVirtualKey(VK_E,0),KEYEVENTF_KEYUP,0);
keybd_event('S',
MapVirtualKey(VK_S,0),0,0);
keybd_event('S',
MapVirtualKey(VK_S,0),KEYEVENTF_KEYUP,0);

/* ENTER */
keybd_event(VK_RETURN,
MapVirtualKey(VK_RETURN,0),0,0);
keybd_event(VK_RETURN,
MapVirtualKey(VK_RETURN,0),KEYEVENTF_KEYUP,0);

SetForegroundWindow(currentWnd);
...

The REXX implementation follows the same logic; excerpts below:

/* REXX wrappers to these Win32 API's */
call w32FuncAdd 'MapVirtualKeyA',
'user32.dll', 'MapVirtualKey', 'ii', 'i'

call w32FuncAdd 'keybd_event',
'user32.dll', 'KeyboardEvent', 'hhii'
...
...

/* Core Logic */
KEYEVENTF_KEYUP = 2
VK_MENU = C2D('12'X) /* Same as: VK_MENU = 18 */
VK_SPACE = C2D('20'X)
...
call KeyboardEvent VK_MENU,
MapVirtualKey(VK_MENU, 0), 0, 0
call KeyboardEvent VK_SPACE,
MapVirtualKey(VK_SPACE, 0), 0, 0
call KeyboardEvent VK_SPACE,
MapVirtualKey(VK_SPACE, 0), KEYEVENTF_KEYUP, 0
call KeyboardEvent VK_MENU,
MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0
...

The REXX version was easily implemented, but does not work. Specifically:

* The 'KeyboardEvent' call meant to invoke the target window's
menu [i.e. mimic pressing of ALT-SPACE] does not work.
The target window seems to receive an ALT, then a SPACE,
but this is not interpreted as
 
 
 

Just a little tidbit to offer

Post by Wim Dirk » Fri, 03 Dec 2004 22:35:43


"Lee Peedin" < XXXX@XXXXX.COM > schreef in bericht


Just out of curiosity:
How do I give a MsgBox at the start of the program and remove it at the end
of the program, without any user intervention?
Wim Dirks
 
 
 

Just a little tidbit to offer

Post by Lee Peedi » Fri, 03 Dec 2004 23:38:19

Wim,
I have a version of the standard Time Message Dialog, that has not
buttons and will stay on the screen until you "quit" the dialog. I
have to leave for a while, but I will get you a copy of this either
this afternoon or first thing in the morning.

Lee

On Thu, 2 Dec 2004 14:35:43 +0100, "Wim Dirks" < XXXX@XXXXX.COM >
 
 
 

Just a little tidbit to offer

Post by Lee Peedi » Sat, 04 Dec 2004 07:36:21

Here you go - WATCH for line wraps

/* static_popup.rex */

title = 'Wim Dirk Static Popup Message'
tdlg = .StaticInfoBox~New('Loading Data - Please Stand By',title,-1)
tdlg~execute
rv = SysSleep(3) --Replace this with program code
tdlg~stopit

tdlg = .StaticInfoBox~New('Sorting Data - Please Stand By',title,-1)
tdlg~execute
rv = SysSleep(3) --Replace this with program code
tdlg~stopit

tdlg = .StaticInfoBox~New('Application Completed',title,2000)
-- Will stay on screen 2 seconds and then automatically stop
tdlg~execute
exit

::REQUIRES OODPLAIN.CLS
::CLASS StaticInfoBox subclass TimedMessage public
::METHOD init
expose message title sleeping
use arg message, title, sleeping
self~init:super(message,title,sleeping)

::METHOD DefineDialog
expose message sx sy
self~AddText(10,10,sx+2,sy,message)

::METHOD execute
expose message title sleeping sx sy
parse value GetStdTextSize(message) with sx sy
parse value GetScreenSize() with scrx scry .
self~create(trunc((scrx-sx) /2),trunc((scry - sy - 20) /2), sx+20,
sy + 20, ,
title,"NOMENU",,,1 )
self~startit
self~show("SHOWTOP")
if sleeping >= 0 then
do
reply
call sleepms sleeping
self~stopit
end




On Thu, 02 Dec 2004 14:38:19 GMT, Lee Peedin