Author Topic: [XP][VX][VXA] Prevent Window Deactivation  (Read 8809 times)

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
[XP][VX][VXA] Prevent Window Deactivation
« on: July 11, 2014, 08:11:15 PM »
Prevent Window Deactivation
Authors: ForeverZer0
Version: 1.1
Type: Game Utility
Key Term: Game Utility

Introduction

Normally, when the RGSS Player window is no longer the foreground window, the game becomes "paused", and only the music continues while the game is suspended. This small library will prevent that action, and the game will not be suspended.

Features

  • Compatible with ALL RPG Maker version
  • Very small (only 10.8 kB)
  • Very efficient, does not constantly check every millisecond, simply filters Windows message events being processed on the window
  • Two lines of actual Ruby code

Screenshots

None.

Demo

None.

Script

Download NoDeactivate.dll and place in your game folder.

The following two lines of code will need added to main:
Code: [Select]
Win32API.new('NoDeactivate.dll', 'BeginMonitor', '', '').call
Code: [Select]
Win32API.new('NoDeactivate.dll', 'EndMonitor', '', '').call
(click to show/hide)
(click to show/hide)
(click to show/hide)


Instructions

See above.

Compatibility

Should now be compatible with ALL version of RGSS, including RMXP, RMVX, and RMVX Ace.
If you are having difficulties getting it to function correctly, first try to copy the library defined in Game.ini to the path defined there.

Although the likelihood is near nothing, scripts that completely change the Input module COULD have an effect, though I am not aware of any existing Input module rewrite that does.

Credits and Thanks

  • ForeverZer0, for the "script" and library.

Author's Notes

Please report any bugs or suggestions.

Source code is available at SourceForge.
In order to post-process the library after build, you will need to recompile the assembly with the Rpg.NET Export Tool I had previously made.
« Last Edit: July 12, 2014, 06:42:22 PM by ForeverZer0 »
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline LiTTleDRAgo

  • Astral Trancist
  • *****
  • Posts: 841
  • LV: 514
  • Gender: Male
    • View Profile
    • ~
Re: [XP] Prevent Window Deactivation
« Reply #1 on: July 11, 2014, 08:35:04 PM »
could you release the dll source code as well?
I'm interested how do you accomplish that O.o

RGSS102E

this means, can't be used in XPA?

Offline KK20

  • Master Scripter Fixer
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3041
  • LV: 372
  • Gender: Male
  • Bringer of Salt
    • View Profile
Re: [XP] Prevent Window Deactivation
« Reply #2 on: July 11, 2014, 09:00:49 PM »
I'd like to know too (seeing as I started that topic and all). The reason Drago mentioned it was to be used for the XP Ace conversion project we have going on--so support for that would be perfect.



Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!


NNID: KK20-CP
Discord: KK20 Tyler#8901
Join the CP Discord Server

Offline Spaceman McConaughey

  • Legit Poo Poo Man
  • Lexima Warrior
  • *******
  • Posts: 2002
  • LV: 46
  • Gender: Male
  • muh murph
    • View Profile
    • Titties, titties, and more titties!
Re: [XP] Prevent Window Deactivation
« Reply #3 on: July 11, 2014, 09:07:44 PM »
F0, I love you.
Now I can make full screen optional in my project! :D

Offline PhoenixFire

  • Moderator
  • Astral Trancist
  • ***
  • Posts: 918
  • LV: 6
  • Gender: Female
  • ~That's an interesting notion, in it's own way~
    • View Profile
Re: [XP] Prevent Window Deactivation
« Reply #4 on: July 12, 2014, 12:28:43 AM »
Yeah, I kind of would love to see this in action with XPA too. The idea behind it is great, and if we ever get RMX-OS working with XPA, it wouild be neat to see a game that allows stuff to keep going on even while you're not there; this assumes that I understand correctly. This simply makes sure the game doesn't pause, correct? As in, you can shift the window focus on something else such as, say, a web browser to check in on chaos project, but the game will continue to run? Unless of course RMX-OS already supports this type of behavior >.>
Next off, how to create a first person shooter using microsoft excel.

<Remember when computers had turbo buttons?

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Prevent Window Deactivation
« Reply #5 on: July 12, 2014, 01:18:14 AM »
Yes, exactly.

The source code is available on SourceForge where the download link is. I can make it work for any of the rgss libraries, just have not done it yet. I still need to add support for using alt and tab to activate the window, not just the mouse.

I used my RpgExport tool to export the functions. I should be able to update tomorrow.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline finalholylight

  • Awakened Visionist
  • **
  • Posts: 77
  • LV: 0
    • View Profile
Re: [XP] Prevent Window Deactivation
« Reply #6 on: July 12, 2014, 09:55:40 AM »
Am I do right ?
Code: [Select]
begin
  Win32API.new('NoDeactivate.dll', 'BeginMonitor', '', '').call
  # Prepare for transition
  Graphics.freeze
  # Make scene object (title screen)
  $scene = Scene_Title.new
  # Call main method as long as $scene is effective
  while $scene != nil
    $scene.main
  end
  # Fade out
  Graphics.transition(20)
rescue Errno::ENOENT
  # Supplement Errno::ENOENT exception
  # If unable to open file, display message and end
  filename = $!.message.sub("No such file or directory - ", "")
  print("Unable to find file #{filename}.")
  Win32API.new('NoDeactivate.dll', 'EndMonitor', '', '').call
end

when I active other window, window explorer crash and reset.

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Prevent Window Deactivation
« Reply #7 on: July 12, 2014, 01:09:32 PM »
You don't want to add it only the "rescue" portion, since that only gets called if the game crashes. Adding an "ensure" to the block would be ideal, since it will get called no matter what.  I will update the instructions a bit to explain that.
(click to show/hide)

I was just adding support for all versions of RGSS###.dll, and I made a mistake when doing some last minute refactoring, and have it setting a low-level keyboard hook instead of a low-level mouse hook.  :facepalm:

I have fixed that, so if you have experienced not being able to regain control of the game after switching back to the game window, this is why, and I will soon have an updated fix, just as soon as I finish multi-library support.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Sylphe

  • Transcended Spirit
  • ***
  • Posts: 119
  • LV: 3
  • Gender: Male
  • Huunngrryyyy *o*
    • View Profile
Re: [XP] Prevent Window Deactivation
« Reply #8 on: July 12, 2014, 06:22:54 PM »
this is soo good for rmx-OS games :o I'm waiting for the RGSS104E.dll compatibility ! Lvl + !
blindly follow his heart can lead to the loss
(click to show/hide)
Sylphe, descendant of Zoldik Family.
Quote from: TedBear
TRY KEEP UP

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Prevent Window Deactivation
« Reply #9 on: July 12, 2014, 06:28:44 PM »
this is soo good for rmx-OS games :o I'm waiting for the RGSS104E.dll compatibility ! Lvl + !


Your wish has been granted.

** UPDATES TO VERSION 1.1 **

  • Fixed bug with wrong hook being set that would cause window to not reactivate correctly
  • Added dynamically loading RGSS###.dll to make compatible with all existing versions of RPG Maker XP, VX, and VXA. As long as Enterbrain does not change functions they have been reusing since RPG Maker XP, it should also continue to work with future versions.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline finalholylight

  • Awakened Visionist
  • **
  • Posts: 77
  • LV: 0
    • View Profile
Re: [XP][VX][VXA] Prevent Window Deactivation
« Reply #10 on: July 12, 2014, 07:35:21 PM »
I am still getting error when active other window :(

Offline KK20

  • Master Scripter Fixer
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3041
  • LV: 372
  • Gender: Male
  • Bringer of Salt
    • View Profile
Re: [XP][VX][VXA] Prevent Window Deactivation
« Reply #11 on: July 12, 2014, 09:19:38 PM »
Confirms that it works with the hacked RGSS300, and thus with XPA :D
Simply awesome, my man~
(click to show/hide)



Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!


NNID: KK20-CP
Discord: KK20 Tyler#8901
Join the CP Discord Server

Offline LiTTleDRAgo

  • Astral Trancist
  • *****
  • Posts: 841
  • LV: 514
  • Gender: Male
    • View Profile
    • ~
Re: [XP][VX][VXA] Prevent Window Deactivation
« Reply #12 on: July 12, 2014, 10:39:10 PM »
....it seems for some computer didn't work as expected:

computer1 (Win7 Starter) : worked
computer2 (WinXP SP3) : when clicked other window (ex: Firefox), that program will close & windows explorer crashed
« Last Edit: July 12, 2014, 10:41:17 PM by LiTTleDRAgo »

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP][VX][VXA] Prevent Window Deactivation
« Reply #13 on: July 13, 2014, 03:27:54 AM »
Just out of curiosity, what are the OS and system CPU architectures?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5131
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: [XP][VX][VXA] Prevent Window Deactivation
« Reply #14 on: July 13, 2014, 07:14:45 AM »
F0, I'm crying. I went to look at your code in the repo and I certainly could. but you must of mixed tabs and spaces because your indentation is all over the place! I cried in agony! the last time I saw it this bad I was working with the Pokemon essentials starter kit.

As for things that actually matter. this is awesome great work man.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19930
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP][VX][VXA] Prevent Window Deactivation
« Reply #15 on: July 13, 2014, 08:12:55 AM »
The same keeps happening to my boss. He uses XCode and that thing just loves switching to spaces instead of tabs for no reason. >_>
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline LiTTleDRAgo

  • Astral Trancist
  • *****
  • Posts: 841
  • LV: 514
  • Gender: Male
    • View Profile
    • ~
Re: [XP][VX][VXA] Prevent Window Deactivation
« Reply #16 on: July 13, 2014, 09:46:21 AM »
@F0



(click to show/hide)

Offline finalholylight

  • Awakened Visionist
  • **
  • Posts: 77
  • LV: 0
    • View Profile
Re: [XP][VX][VXA] Prevent Window Deactivation
« Reply #17 on: July 13, 2014, 11:01:00 AM »
this is mine
(click to show/hide)
« Last Edit: July 13, 2014, 11:02:12 AM by finalholylight »

Offline Sylphe

  • Transcended Spirit
  • ***
  • Posts: 119
  • LV: 3
  • Gender: Male
  • Huunngrryyyy *o*
    • View Profile
Re: [XP][VX][VXA] Prevent Window Deactivation
« Reply #18 on: July 30, 2014, 09:01:41 PM »
small bug, when I change my window then I go back to the game, often I can't use the keyboard, unless I click several times on the game ( in the rmxos connection menu it doesn't work when I click, I have to relaunch the game)
blindly follow his heart can lead to the loss
(click to show/hide)
Sylphe, descendant of Zoldik Family.
Quote from: TedBear
TRY KEEP UP

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP][VX][VXA] Prevent Window Deactivation
« Reply #19 on: July 30, 2014, 09:08:55 PM »
Just for a test, can you try clicking the title bar of the game window instead of anywhere on the window and see if works any better?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.