How move Message window or Pause Window?

Started by pguild, April 24, 2021, 11:10:18 PM

Previous topic - Next topic

pguild

GRR! Third time trying to post this question.  >:(
How can I move the window created by the pause command or the message command?
If not possible is there a workaround?

kdmoyers

If your need is just functional, not cosmetic, then this is a cheap hack:
Code (winbatch) Select
  #definefunction askmessage(x,y,width,height,title,mess)

    ; this controls placement of certain AskXxxx functions
    intcontrol(63, x, y, x+width, y+height)

    AskTextBox( title, "", mess, 2, 0)

  #endfunction

  message("hey","there")

  askmessage(110,110,400,400,"hey","there")
The mind is everything; What you think, you become.

td

Or if you don't mind a little more work you could use the WIL Dialog function to create your own message box.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

kdmoyers

Attached is a cool bunch of code that demonstrates a number of techniques for making specialized message boxes.

it contains these functions:
Code (winbatch) Select

#DEFINESUBROUTINE MessageUdfProc(dlgMessageUdfHandle,dlgMessageUdfEvent,dlgMessageUdfEventControlID,dlgMessageUdfParam4,dlgMessageUdfParam5)

#DEFINEFUNCTION udfMessage(Title,Text,TextJust,Timeout,Buttons,PositionBox)

The mind is everything; What you think, you become.

cssyphus

In addition to Sean Dorn's udfMessage() function that Kirby posted, do not miss IFICantBYTE's Rube-Goldberg-All-In-One-Super-Fragalistic Message Box, here:
https://forum.winbatch.com/index.php?topic=1556.0


It is also nice to know about this simple WSH messagebox implementation (although it doesn't help with repositioning the dialog window):


#DefineFunction udfWSHMessage(Timeout,TitleText,MessageText,DisplayFlags) ;-------------------
    oWSHShell = ObjectCreate("WScript.Shell")
    Ret = oWSHShell.popup(MessageText,Timeout,TitleText,DisplayFlags)
    oWSHShell = 0
    Return(Ret)

    ;EXAMPLES:
    ;Test1 = udfWSHMessage(5,"Test 1","5 second timeout with STOP icon and OK button.",16)
    ;Test2 = udfWSHMessage(7,"Test 2","7 second timeout with QUESTION MARK icon and OK and CANCEL buttons.",32|1)
    ;Test3 = udfWSHMessage(8,"Test 3","8 second timeout with EXCLAMATION icon and ABORT RETRY IGNORE buttons. IGNORE has been made the DEFAULT option.",48|2|512)
    ;Test4 = udfWSHMessage(4,"Test 4","4 second timeout with NO icon and just an OK button.",0)
    ;0==OK, 1==OK|Cancel, 2==Abort|Retry|Ignore, 4==Yes|No, 8==nothing, 16==RedX, 32==?mark, 64==info, 128==blank spot, 256==noIcon
    ;timeout= -1, OK==1, Cancel==2, abort==3, retry==4, yes==6, no==7
#EndFunction ;udfWSHMessage ------------------------------------------------------------------
Test2 = udfWSHMessage(7,"My Dlg Title","7 second timeout with QUESTION MARK icon and OK and CANCEL buttons.",32|1)
   

I would have thought that this would work, but sadly no:


Test2 = udfWSHMessage(7,"My Dlg Title","7 second timeout with QUESTION MARK icon and OK and CANCEL buttons.",32|1)
winPlace(50,50,100,300,`My Dlg Title`)


But the 20 minutes that you spend experimenting with IFICantBYTE's and Sean Dorn's udfMessage() functions will pay many future dividends.
Is this a pandemic... or an IQ test? newz.icu

rw_baker

Place the bare-bones script below on the Desktop and run with:

run("C:\Users\user\Desktop\bare bones.WBT","'try it' 30 173 159 338")
pause("try it","")

;
win_title = param1
ok = WinWaitExist(win_title,3)
terminate(!ok,"Window did not show!",param1)
for i = 1 to 4
   j = i + 1
   coord%i% = param%j%
next
WinPlace(coord1,coord2,coord3,coord4,win_title)
exit
;
Generalize the script by using "WinPlaceGet" to find the original coordinates, adjust these to get the target
location and use "WinPlace" to finish.


RW Baker

cssyphus

That's an interesting demo, RW, and it does work as advertised -- but it requires an external script to reposition the message() or pause() dialogs, which is not strictly what is being asked.

On the other hand, your example proves that one could spawn such an external app -- it needn't even pre-exist (one could filePut() it into existence, run() it, and fileDelete() it when done) -- and solve the problem that way.

Good idea, sir.
Is this a pandemic... or an IQ test? newz.icu

rw_baker

Thanks for your comments.  I have used the full script for many years, it is stored in my utilities directory.  The following gives the full script's comments and an example of its use:

;Script: Delayed WinPlace.WBT - A script to move a window on the screen.
;  param1:  is the partial window title.
;  param2:  if it has the format x-ulc,y-ulc,x-brc,y-brc then the window is moved to these coordinates,
;           example: 100,200,300,400
;           if its first character is + or - then the format should be: +/-xdisp,+/-ydisp, example: +100,-100
;           this example would move the window x-coord right 100 units and the y coord up 100 units.
;           In this format the window always remains the same size.

; Sample run to move the message window right 100 and up 100 units:
run("F:\WBT\Utilities\Delayed WinPlace.WBT",'"a test" +100,-100')
message("a test","")
exit

RW Baker

cssyphus

I used that trick today, RW, and it worked poifectly. Thanks again for the great idea. What I did was this:

1. Created the entire MoveMsgWindow .wbt script as a string in a variable (using %@CRLF% between lines)

2. filePut() the string into a file on disk, preserving the file name in a variable

3. Used run() to run the script just saved to disk

4. Executed the message (in my case, calling an instance of Sean Dorn's _udfMessage)

5. The message was instantly relocated, with no visible flash or movement

6. fileDelete() the .wbt that moved the message window

Here's the code:


_killMe = udfMoveAlarmToMon2(_almTitle) ;only moves alarm if _zoomActive and _numMons > 1 (both defined inside udf)
    _udfMsgTitle = _almTitle
    _udfMsgText = _alarmMsg
    _udfMsgJust = `Center`
    _udfTimeOut = 8
    _udfButtons = `OK|Remind 5m|Remind 15m|Remind 30m|Msg2ClipBd|Reschedule|Cancel`
    _udfPositon = `0,0,1000,1000`
_almUserClick = udfMessage(_udfMsgTitle,_udfMsgText,_udfMsgJust,_udfTimeout,_udfButtons,_udfPositon)
if _killMe != 0 then fileDelete( dirScript() : _killMe : `.wbt` )


and the udf:


#DEFINEFUNCTION udfMoveAlarmToMon2(_almTitle) ;---------------------------------------
    debugTrace(22)
    _numMons = winMetrics(80)
    _zoomActive = winExist(`ConfMeetingNotfiyWnd`)
    IF _numMons > 1 && _zoomActive
        ;debugTrace(22)
        _dtCode = timeFormat(timeYmdHms(), `yyMMdd_hhmmss`)
        _f = `_st = timeYmdHms()` : @CRLF : `while 1` : @CRLF : `if winExist('%_almTitle%')` : @CRLF : `_pp = arrayize(winPosition('%_almTitle%'), ",")` : @CRLF : `_tx = _pp[0] - 1000` : @CRLF : `_bx = _pp[2] - 1000` : @CRLF : `winPlace( _tx, _pp[1], _bx, _pp[3],  '%_almTitle%' )` : @CRLF : `return` : @CRLF : `endif` : @CRLF : `yields(250)` : @CRLF : `if timeDiffSecs(timeYmdHms(), _st) > 20 then Break` : @CRLF : `endwhile`
        filePut(dirScript() : _dtCode : `.wbt`, _f)
        yields(20)
        run(dirScript() : _dtCode : `.wbt`, ``)
        return _dtCode
    ENDIF
    return 0
#ENDFUNCTION ;udfMoveAlarmToMon2() ---------------------------------------------------


PS: You might wonder why I prefix my varnames with an underscore... It just makes them easier to search for... e.g. searching for _message will not return all instances of message()
Is this a pandemic... or an IQ test? newz.icu

rw_baker