BWin - Mouse GUI with windows - move,scale,maximize,close,tab,animate

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Mouse GUI with windows - move,scale,maximize,close,tab,animate

#16 Post by misol101 » 19 May 2018 09:07

Woooh! Another archive update.

This one brings greatly improved speed, because the whole thing (almost) was converted to Javascript!

The old version is still kept in the Batch folder, while the new fast version is in the JScript folder (run BWin.bat in both cases).

At first it seemed to be only about 4 times faster, but then it turned out that string concatenation of very long strings was slowing Javascript down. When I split the cmdgfx input to several steps per frame (and thus, much shorter strings), speed increased dramatically, and is now 10+ times faster than the batch version!

So, on my Win7 machine, this means I can now have 90-100 windows open before I see any lag. On my WIn10 machine it is 30-40 (depending a lot on if Windows10 decides to run other programs like antimalware checkers in the background :? ).

With this newfound speed, this script is almost starting to look like a real window manager :mrgreen: . Therefore, the program was renamed to BWin :)

It's also easier to decipher the met files now. For example, the mouse-controlled game.met went from this:

Code: Select all

set W[]_NAME="Game \80(SPACE to restart)"
set /a W[]_W=60, W[]_H=30
set /a W[]_X=28, W[]_Y=31
set /a W[]_XA=1, W[]_YA=1
set /a W[]_ACTIVE=1, W[]_CLOSE=1, W[]_SIZE=1, W[]_CLEAR=1, W[]_SCROLL=0, W[]_EXP=6
set W[]_INIT="set /a DELT[]=1, REPL1_[]=0, BX[]=12, BY[]=2, BDX[]=1, BDY[]=1, SCO[]=0"
set W[]_UPDATE="set /a XWALL=W[]_W-3, YWALL=W[]_H-5, REPL1=REPL1_[],REPL2=OFF_Y+YWALL+1, BX[]+=BDX[], BY[]+=BDY[] & (if ^!FOCUSWIN^!==[] (if ^!KEY^!==32 set /a SCO[]=0, BX[]=2+^!RANDOM^!%XWALL, BY[]=2, BDX[]=1-^!RANDOM^!%2*2, BDY[]=1) & (if ^!M_X^! gtr 0 set /a LMX[]=M_X) & set /a REPL1_[]=OFF_X+LMX[]-W[]_X-4, REPL1=REPL1_[]) & (if ^!BX[]^! lss 1 set /a BDX[]=1) & (if ^!BX[]^! gtr ^!XWALL^! set /a BDX[]=-1) & (if ^!BY[]^! lss 1 set /a BDY[]=1) & (if ^!BY[]^! == ^!YWALL^! set /a TMPX=OFF_X+BX[]-4, CMPX=REPL1-TMPX & (if ^!CMPX^! lss 0 set /a CMPX=-CMPX) & (if ^!CMPX^! leq 4 set /a BDY[]=-1, SCO[]+=1)) & set /a REPL3=OFF_X+BX[], REPL4=OFF_Y+BY[], SCORE=SCO[]"
set W[]_CONTENT="fbox a 0 db REPL1,REPL2,8,0 & pixel c 0 @ REPL3,REPL4 & text e 0 0 \n_Score:^!SCORE^! OFF_X,OFF_Y"
to this:

Code: Select all

w.name="Game \\80(SPACE to restart)"
w.x=28, w.y=31
w.width=60, w.height=30
w.xa=1, w.ya=1
w.closeable=true, w.resizeable=true, w.scrollable=false
w.init="w.bx=12, w.by=2, w.bdx=1, w.bdy=1, w.oldMx=-100, w.score=0"

w.update="xWall = w.width-3, yWall = w.height-5;" + 
	"w.bx += w.bdx, w.by += w.bdy;" +
	"if (w == focusWin) {" +
		"if (KEY==32) w.score=0, w.bx = GetRandom(0,xWall), w.by=2, w.bdx = 1-GetRandom(0,1)*2, w.bdy=1;" +
		"if (M_X > 0) { w.oldMx = OFF_X + M_X - w.x - 4 }" +
	"}" +
	"if (w.bx < 1) w.bdx = 1;" +
	"if (w.bx > xWall) w.bdx = -1;" +
	"if (w.by < 1) w.bdy = 1;" +
	"if (w.by == yWall) { cmpx = Math.abs(w.oldMx - (OFF_X+w.bx-4)); if (cmpx <= 4) w.bdy=-1, w.score+=1; }" +
	"REPL1 = w.oldMx, REPL2 = OFF_Y + yWall + 1, REPL3 = OFF_X+w.bx, REPL4 = OFF_Y+w.by, REPL5 = w.score"
			
w.content="fbox a 0 db REPL1,REPL2,8,0 & pixel c 0 @ REPL3,REPL4 & text e 0 0 \\n_Score:REPL5 OFF_X,OFF_Y"

EDIT: Classic Snake.met game added (Javascript version only)

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: BWin - Mouse GUI with windows - move,scale,maximize,close,tab,animate

#17 Post by misol101 » 06 Jun 2018 20:06

Archive was updated due to the fact that the speed of cmdgfx_gdi was improved (especially for fullscreen, try it if fullscreen seemed sluggish before!)

Also, BWin now accepts files with spaces in their names being dropped on BWin.bat either at start or while running.

As mentioned above, a Snake game was added to the JScript version (drop snake.met on BWin.bat). Also, the "notepad" met file is now a lot more efficient for the JScript version since it keeps the text in memory until it is manually saved

Here's a screenshot showing about 60 text windows running simultaneously, fullscreen (they cannot all be seen). A game of snake just ended in the upper-left part of the screen.

Image

One more thing: to fully experience this script on Win10, I would strongly suggest to disable "Antimalware Service Executable" if it is running in the background.I have seen it eat more than 50% CPU and seems more of malware software itself than anything else.

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: BWin - Mouse GUI with windows - move,scale,maximize,close,tab,animate

#18 Post by misol101 » 23 Jul 2018 17:02

The archive was updated once more.

This time I added a file explorer (only to the Jscript version). It opens automatically if running BWin.bat without input.

That makes it much easier to browse and open other files inside BWin. The file explorer has no other functions than to browse between folders and open files (using either keys or mouse). Several instances of the explorer can be active at once of course, just open explorer.met from the file explorer.

Image

Oh, and also, on Win10, fullscreen is now truly full screen (no bottom task bar visible)

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: BWin - Mouse GUI with windows - move,scale,maximize,close,tab,animate

#19 Post by misol101 » 24 Aug 2018 19:48

And here is a new version of BWin, the difference being that the window will now respond to mouse resizing of the cmd window (utilizing the whole draw area).

Post Reply