AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can AHK (GUI) create a window with a wide border?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Ron1



Joined: 20 Dec 2007
Posts: 39
Location: United States of America

PostPosted: Sun Jul 13, 2008 9:23 am    Post subject: Can AHK (GUI) create a window with a wide border? Reply with quote

QUESTION: Can AHK (GUI) create a window with a wide border of controllable width and controllable color, and also transparent inside this special border?

I realize that AHK (GUI) can create a window with a thin black border that is also transparent within this border. However, this border is so thin as to be ineffective for the intended application.

MOTIVATION: In Assistive Technology low-vision applications, it is helpful to have overt methods of signaling users about changes in the system state. A substantial border, surrounding an otherwise transparent window, could be used to signal any number of possible changes of state, such as the pressing of a shift key.

IDEAS TO DATE: I have found no way yet to create this border with a single GUI. But I realize that it is likely possible to use four GUIs, all created (or removed) at the same time, one for each of the four rectangular "bars" that would make up such a border. At the same time, this approach would leave the region inside the bars transparent, as desired. But is there a more direct method?

All suggestions will be received with appreciation.

Ron1
Back to top
View user's profile Send private message
BoBo²
Guest





PostPosted: Sun Jul 13, 2008 10:44 am    Post subject: Reply with quote

[Drawing a rectangle] ?
Back to top
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Sun Jul 13, 2008 1:29 pm    Post subject: Reply with quote

how do you plan on moving the window?
Back to top
View user's profile Send private message
Guest






PostPosted: Sun Jul 13, 2008 2:09 pm    Post subject: Reply with quote

Thank you Bobo2 and Tic,

I am studying the thread to which Bobo2 pointed me.

I do not need to move the rectangle, just to create it (say, when a shift key is pressed) and then to delete it (say, when that shift key is released)

The rectangle will always be along the outside border of the display, but must be thick enough to be seen by a person with low vision and of a color easily spotted.

Ron1
Back to top
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Sun Jul 13, 2008 10:34 pm    Post subject: Reply with quote

I still dont really understand what this is going to be used for, but do you mean something like this:

Code:
#SingleInstance, Force
#NoEnv
SetBatchLines, -1

#Include, Gdip.ahk
pToken := Gdip_Startup()

Width := 300, Height := 250
BorderWidth := 6

pBitmap := Gdip_CreateBitmap(Width, Height), G := Gdip_GraphicsFromImage(pBitmap)
pPen := Gdip_CreatePen(0xff000000, BorderWidth)
Gdip_DrawRectangle(G, pPen, BorderWidth//2, BorderWidth//2, Width-BorderWidth, Height-BorderWidth)
hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)

Gui, 1: -Caption
Gui, 1: Add, Picture, % "x0 y0 w" Width-10 " h" Height-6 " 0xE hwndImage"      ;%
SetImage(Image, hBitmap)
Gui, 1: Show

Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), Gdip_DeleteBrush(hBrush), DeleteObject(hBitmap)
Gdip_Shutdown(pToken)
Return


you must also have Gdip
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 6264

PostPosted: Mon Jul 14, 2008 12:03 am    Post subject: Reply with quote

Code:
BorderThickness:=3, BorderColor:="0000FF",  TW:=320, TH:=240

Gui, Margin, %BorderThickness%, %BorderThickness%
Gui, Color, %BorderColor%
Gui, Add, Text, w%TW% h%TH% 0x6 ; Draw a white static control
Gui +LastFound
WinSet, TransColor, FFFFFF
Gui -Caption +AlwaysOnTop +ToolWindow
Return

~Control::
  Gui, Show, NoActivate ; The Gui will not steal keyboard focus
  Loop {                ; Wait until Control key is released
        If Not GetKeyState( "Control", "P" )
        Break
        Sleep 50
       }
  Gui, Hide
Return


Run the above code and press either of the <Control> key to show the Rectangle

Smile
_________________
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Mon Jul 14, 2008 2:17 am    Post subject: Reply with quote

Here's also a very simple example with a timer making the border thicker:

Code:
#SingleInstance, Force
DetectHiddenWindows, On
#NoEnv
SetBatchLines, -1

#Include, Gdip.ahk
pToken := Gdip_Startup()
OnExit, Exit

Width := 300, Height := 250

Gui, 1: +LastFound +AlwaysOnTop
Gui, 1: Color, EEAA99
hwnd1 := WinExist()
WinSet, TransColor, EEAA99, ahk_id %hwnd1%
Gui, 1: -Caption
Gui, 1: Margin, 0, 0
Gui, 1: Add, Picture, % "x0 y0 w" Width-10 " h" Height-6 " 0xE hwndImage BackgroundTrans"            ;%
Gui, 1: Add, Edit, % "x" (Width-150)//2 " y" (Height-20)//2 " w150", Here is an edit box            ;%
Gui, 1: Show
OnMessage(0x201, "WM_LBUTTONDOWN")
SetTimer, IncreaseBorder, 800
Return

;#######################################################################################

IncreaseBorder:
BorderWidth++
ChangeBorderWidth(Image, BorderWidth, 0xff000000)
If (BorderWidth >= 20)
SetTimer, IncreaseBorder, Off
Return

;#######################################################################################

ChangeBorderWidth(hwnd, Width, ARGB)
{
   WinGetPos,,, w, h, ahk_id %hwnd%   
   pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap)
   pPen := Gdip_CreatePen(ARGB, Width)
   ;Gdip_DrawRectangle(G, pPen, Width//2, Width//2, w-Width, h-Width)
   Gdip_DrawRoundedRectangle(G, pPen, Width//2, Width//2, w-Width, h-Width, 15)
   hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
   SetImage(hwnd, hBitmap)
   Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), Gdip_DeleteBrush(hBrush), DeleteObject(hBitmap)
}

;#######################################################################################

WM_LBUTTONDOWN()
{
   PostMessage, 0xA1, 2
}

;#######################################################################################

Exit:
Gdip_Shutdown(pToken)
ExitApp
Return


I suggest you look into the Gdip library if you want more impressive things than this, as it would look much nicer as a layered window
Back to top
View user's profile Send private message
Ron1



Joined: 20 Dec 2007
Posts: 39
Location: United States of America

PostPosted: Mon Jul 14, 2008 4:28 pm    Post subject: Can AHK (GUI) create a window with a wide border? Reply with quote

Tic and SKAN,

Thank you so much for your very helplful suggestions. I am learning much by studying them. The depth of AHK continues to amaze me as a relative beginner. And the knowledge, and helpfulness, of other users, like yourselves, is most appreciated.

Tic, it is good to know about Gdip. I shall explore its capabilities further, and I shall experiment with your suggested code. Clearly, using Gdip could be very useful in meeting many needs.

SKAN, your approach is very direct and attractive. I expanded the size of the border created in your model to just touch the four edges of the display, as required for my application. I then observed just two oddities that I am addressing and that I hope to resolve:

(1) When the border is triggered, in this case with the CTRL key, a flicker occurs in the central area of the screen, which puzzles me. It is almost as if the GUI is being implemented in two steps, where a solid fill is used in the central area and then that fill is made transparent in a second step. Since the single SHOW command does all implementation, the reason for this puzzles me. Perhaps it has something to do with the fact that the WinSet command it coming from outside the GUI family of commands. Fortunately, no such flicker occurs when the CTRL key is released to HIDE the border.

(2) The bottom of the border goes under the WinXP taskbar with "Start" on it, rather than on top of the taskbar as required in my application, despite the "AlwaysOnTop" command.

I may then go on to see if I can make the border itself translucent, so that the image under will show through just slightly. I realize that the "Transparent" feature, with appropriate 0-255 number, may be what is needed.

Again, my HUGE appreciation to both of you for excellent help. My project is the development of a scanner-based document magnification system for individuals with low vision.

Regards,

Ron1
Back to top
View user's profile Send private message
rani



Joined: 18 Mar 2008
Posts: 95

PostPosted: Fri Aug 22, 2008 11:47 am    Post subject: multi rectangels in a image Reply with quote

multi rectangels
how I make multi rectanges on same Image ?
so:
by mouse up the rectange remain
on on next mouse down/drag it wil create another rectangel ?
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Fri Aug 22, 2008 3:09 pm    Post subject: Reply with quote

gdi+ and setimage()
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group