ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Finished Programs

DONE: autohotkey - reload script on screen number change

(1/4) > >>

nudone:
a few credits are awaiting if you can just write a bit of a script that does the following, please...

1. monitor number of screens (physical LCD monitors) currently enabled.

2. when number of screens changes - RELOAD a specific ahk script - or, list of scripts.

3. keep monitoring number of screens ready for next reload of script(s).


the problem is that i swap between single screen enabled and multi-screen enabled quite often and i forget to reload my autohotkeyscripts. this means that one of the scripts, DialogMove, isn't aware that the screen number has changed and so doesn't work correctly (until i reload it).

i'd ask Jgpaiva if he'd modify the DialogMove script but:

a: i think he's far to busy.
b: i think that the script i'm requesting might be useful with other scripts that need reloading (or programs that need reloading that i don't know of right now). so, just asking for DialogMove to be modified wouldn't help with other, potential, script problems.

thanks.

edit:
i've just realised i've another program running that doesn't appreciate when enabled screens has changed. it's a small util called "Y'z Shadow".

so, it would be very helpful if the script i've requested above does also have the ability to load in exe files and not just scripts.

thanks again.

cthorpe:
Looks like this is where one will need to start:

http://www.autohotkey.com/docs/commands/SysGet.htm

Parameters
OutputVar    The name of the variable in which to store the result.
Sub-command    See list below.
Param3    This parameter is omitted except where noted below.
Sub-commands

MonitorCount: Retrieves the total number of monitors. Unlike SM_CMONITORS mentioned in the table below, MonitorCount includes all monitors, even those not being used as part of the desktop. On Windows 95/NT the count is always 1.

MonitorPrimary: Retrieves the number of the primary monitor, which will be 1 in a single-monitor system. On Windows 95/NT the primary monitor is always 1.

Monitor [, N] : Retrieves the bounding coordinates of monitor number N (if N is omitted, the primary monitor is used). The information is stored in four variables whose names all start with OutputVar. If N is too high or there is a problem retrieving the info, the variables are all made blank. For example:
SysGet, Mon2, Monitor, 2
MsgBox, Left: %Mon2Left% -- Top: %Mon2Top% -- Right: %Mon2Right% -- Bottom %Mon2Bottom%.

Within a function, to create a set of variables that is global instead of local, declare Mon2 as a global variable prior to using this command (the converse is true for assume-global functions).

MonitorWorkArea [, N]: Same as the above except the area is reduced to exclude the area occupied by the taskbar and other registered desktop toolbars.

MonitorName [, N]: The operating system's name for monitor number N (if N is omitted, the primary monitor is used).

(Numeric): Specify for Sub-command one of the numbers from the table below to retrieve the corresponding value. The following example would store the number of mouse buttons in a variable named "MouseButtonCount":
SysGet, MouseButtonCount, 43
--- End quote ---

nudone:
okay, thanks, cthorpe.

there is an example at the bottom of that page that seems straightforward. i'll try to work something out, later in the week, if no one else jumps in with a quick solution (it will take me all day trying to get the if statements set up i'm sure).

Target:
how do you intiate the switch between the...errr....2?

I'm thinking this is the point you'd probably want to look at

nudone:
i'm using ActualWindowManager http://www.actualtools.com/windowmanager/ to control the number of monitors/screens enabled at any one time.

this is done through a tray icon's context menu - which provides the options of enabling or disabling any 1 of the four monitors plugged in.

if i could remember, i'd simply manually reload Dialogmove (etc.) when i change the number of monitors that are enabled. i just don't make the change often enough to remember - not until i expect Dialogmove to do its magic and i realise it hasn't because of the screen change.

i suppose, Dialogmove could be modified to work in the "all screens enabled" mode at all times. well, maybe, as i really don't know if that's remotely possible.




i think all the new script needs to do is constantly monitor the "desktop" size using the SysGet properties. when it detects a change in the previously stored "desktop" size the script reloads whatever programs and scripts are in the preset list. i'm assuming that it is a simple matter for one script to reload another script that is already running - or kill a program running in the tray and restart it.

or, it could monitor the number of screens active instead of desktop size. not sure which is more likely to work or run into trouble.

Navigation

[0] Message Index

[#] Next page

Go to full version