Christian Blackburn

Can't get InputBox with custom Height horizontally centered

6 posts in this topic

#1 ·  Posted

Hi Guys,

I've set the vertical height of my InputBox to the screen resolution height minus the taskbar.  The height bit works great, but consequentially the window is no longer centered.  The first 0 in the InputBox parameters below is the Left property.  I can't set it to -1 nor just omit it leaving a comma as in ".. $Usable_Screen_Area[3],, 0".  Is there any easy way to get my Window centered shy of a separate program that launches just before, waits for my InputBox, an then centers it.  I would think -1 would just equate to centered, but it isn't valid input according to SciTe

;Needed to get usable screen area
#include <WinAPI.au3>

;$Usable_Screen_Area[3] = screen height minus the taskbar on the current screen which may or may not have a taskbar
Local $Usable_Screen_Area = _GetDesktopArea()
        
;The M2 means a 1-2 character value is required, $Usable_Screen_Area[3] is the screen's height minus the taskbar if there's a taskbar on the current screen
$Response = InputBox("Simulator", "Please enter the index you'd like to simulate?" & @CR & $Options, "", " M2", -1, $Usable_Screen_Area[3],0, 0)

Thanks for your help,

Christian


Thanks,Christian BlackburnHTTP://www.RawSeattle.org

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

;Needed to get usable screen area
#include <WinAPI.au3>

;$Usable_Screen_Area[3] = screen height minus the taskbar on the current screen which may or may not have a taskbar
Local $Usable_Screen_Area = _GetDesktopArea()
        
;The M2 means a 1-2 character value is required, $Usable_Screen_Area[3] is the screen's height minus the taskbar if there's a taskbar on the current screen
$Response = InputBox("Simulator", "Please enter the index you'd like to simulate?" & @CR & $Options, "", " M2", -1, $Usable_Screen_Area[3],Default, 0)

Have you tried this? I can't really test it because I don't have the desktop area part of your code.

EDIT: I tested it, seems to work.

Edited by anthonyjr2
1 person likes this

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

#3 ·  Posted

This example is for one monitor.  
For an input box to appear on either of two monitors, see the example of _WinAPI_GetMonitorInfo function in AutoIt help file.

#include <WinAPISys.au3>

$Response = InputBox("Simulator", "Please enter the index you'd like to simulate?", "", " M3", _
         - 1, DllStructGetData(_WinAPI_GetMonitorInfo(1)[1], 4), Default, 0)

 

1 person likes this

Share this post


Link to post
Share on other sites

#4 ·  Posted

Hi Malkey,

Thank you very much.  I wish "-1" was acceptable, but your "default" keyword that I didn't know about worked like a charm. 

Thanks,
Christian Blackburn


Thanks,Christian BlackburnHTTP://www.RawSeattle.org

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Damn, looks like I got no credit :'(

Edited by anthonyjr2

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

#6 ·  Posted

Hi Malkey and AnthonyJr2,

Thank you both very much for your tips.  Anthony's code worked great.  Sorry I failed to give credit where it was plainly due. 

Thanks,
Christian Blackburn

 


Thanks,Christian BlackburnHTTP://www.RawSeattle.org

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now