AutoHotkey Community

It is currently May 27th, 2012, 12:02 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: October 3rd, 2009, 10:19 am 
Offline

Joined: October 1st, 2005, 11:26 pm
Posts: 43
Location: Finland
Dear fellow coders,

So, it's easy to make a window transparent, for example...
Code:
WinSet, Transparent, 200, A

...makes a window transparent. Now, say this is a "Save As..." dialog box (doesn't really matter in which programme). These boxes have an Edit1 control (check for yourself with Winspy). Is there a way to change the transparency of this control separately?

What I would like to do is to have the "Save As..." dialog box transparent, this often helps me seeing what's underneath and construct a useful filename, but have the Edit1 control opaque, so that I can still see what I am typing. I have been looking around the help files and the fora but I can't find anyway to change the transparency of a *control*, as opposed to a window.

Any suggestions?

_________________
For the music lover who can sit and enjoy the sound of someone else's evolving nightmare.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: REl Transparent Control
PostPosted: October 3rd, 2009, 9:36 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
Hi songsoverruins

What you want to do has been asked a number of times.

There are various solutions depending on EXACTLY what you want to do.

Vxe suggested
Quote:
set gui's transcolor to the edit control's background
http://www.autohotkey.com/forum/viewtopic.php?t=47876

A more complex solution is here:
GDI Library
http://www.autohotkey.com/forum/topic32238.html

and here:
GDI Examples
http://www.autohotkey.com/forum/topic37859.html

Other solutions:
http://www.autohotkey.com/forum/topic24628.html

http://www.autohotkey.com/forum/topic4535.html

You can search on various topic combinations:
(transcolor, transparent, + Gui, +Control, Background) and other combinations.

Code TESTED
Code:
; TransparentEditBox

; Here's an edit control solution

; http://www.autohotkey.com/forum/topic41720.html

#singleinstance force
#NoEnv
 
Gui, Color, , Black
Gui, Font, cYellow s12 , Calibri
Gui, Add, Edit, -VScroll -0x40 w400 h200
Gui +Lastfound
WinSet, TransColor, Black 255 ; set editbox transparency
Gui, Show,, test window
Return


Have Fun :lol:

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 3rd, 2009, 10:52 pm 
Offline

Joined: October 1st, 2005, 11:26 pm
Posts: 43
Location: Finland
Hi txquestor, thanks for all the suggestions. I don't think they quite cover what I mean though. The point is that I want the "Save As..." dialog box to become transparent, but _not_ the Edit1 control (which is where you specify the filename).

Making the dialog box transparent is easy as I said, but to then change the transparency of the Edit1 control again, so as to make that opaque is not possible with Winset, nor with transcolor. What I have in mind is actually the opposite of what transcolor does.

Please note, I am also not talking about GUis created by AutoHotkey itself. It probably would be much easier to achieve in that case. I'm talking about dialog boxes in programmes (like notepad or word or... whatever) that you call up when you want to open a file or do a "save as..."

I will poke around with this GDI though, I have not used this in my scripting before and it seems what I want requires more than just a simple command :D

_________________
For the music lover who can sit and enjoy the sound of someone else's evolving nightmare.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 3rd, 2009, 11:10 pm 
Offline

Joined: June 8th, 2006, 9:38 pm
Posts: 307
How about a different approach:

Code:
#NoEnv
#SingleInstance force
#Persistent

OnExit exit

WinWait Save As
ControlGetPos, x, y, w, h, Edit1
WinSet, Region, %x%-%y% w%w% h%h%
return

esc::
exit:
WinSet, Region,, Save As
exitApp


Report this post
Top
 Profile  
Reply with quote  
 Post subject: RE: Transparent Dialog
PostPosted: October 3rd, 2009, 11:15 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
Besides GDI the only other suggestion is using Window API to
control Transparency.

Look for C#, C++ or VB projects that someone has already written
to make a control transparent.

Then convert it to AHK through the Win API or DllCall functions.

There are WinAPI calls using the STANDARD windows dialog box.
Go to MSDN to search for keywords on your topics of interest

Once you find something that fits. Then search Autohotkey forum for
more specifics on how to use the Win Api and DllCall functions.

Good Luck :lol:

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2009, 1:28 am 
Offline

Joined: October 1st, 2005, 11:26 pm
Posts: 43
Location: Finland
Hello again and thanks for the suggestions. After some doodling I came up with two workarounds / solutions

Solution 1 is what Roland already suggests, that is query for the size and position of the Edit1 control and then resize the whole window down to just the Edit1 control. Simple and effective.

Solution 2, is really more of a workaround. Query for the size and position of the Edit1 control and spawn a white GUI without a title bar that is the size of the Edit1 control on the position of the Edit1 control.

Initially it didn't work for me as dialog boxes are part of their parent window (e.g. notepad) and either those two sit on top of your little GUI, or your little GUI sits on top of them all, but you can't squeeze it in between. Some toying with WinSet did the trick.

Try this code on any dialog box with an Edit1 control (e.g. the one you call up with Ctrl+o). I admit it's not perfect, e.g. it will mess up as soon as you start moving around your dialog box, but for me it does the trick alright 8)

Code:
WinGetTitle, Title, A
ControlGetFocus, CurrentDialog, A
WinSet, Transparent, 200, A                   ; Make the window transparent.
WinGetPos, X1, Y1,,, A                        ; Determine the position of the window...
ControlGetPos, X2, Y2, Width, Height, Edit1, A ; ... and of the Edit1 control. The latter is relative to the parent
                                              ; window, not the screen...
X = % X1 + X2                                 ; ...so you have to add the two to get the screen coordinates of where
Y = % Y1 + Y2                                 ; to position your GUI.
WinSet, AlwaysOnTop, On, A                    ; Make your dialog box stay on top of all other windows.
Gui 10: +ToolWindow -Caption                  ; Make a GUI without taskbar button and Alt-Tab menu entry (the
                                              ; +Toolwindow option) and without title bar (the -Caption option).
Gui, 10:Color, 0xFFFFFF                       ; Make it white.       
Gui, 10:Show, W%Width% H%Height% X%X% Y%Y%, TransBackground    ; And show it on the position of the Edit1 control.
WinSet, AlwaysOnTop, On, TransBackground      ; Put your GUI on top
WinSet, AlwaysOnTop, On, %Title%              ; Make your dialog box stay on top of that again.   
Send, !{TAB}                                  ; Restore input focus to the Edit1 control by send an Alt-Tab.

_________________
For the music lover who can sit and enjoy the sound of someone else's evolving nightmare.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 4th, 2009, 7:56 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
Great simplle workaround! :D

Suggest a couple mods.

On script exit reset Transparent to Normal Window

Limit the scripts action to ONLY window & controls intended for Transparency.

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 5th, 2009, 5:46 am 
Offline

Joined: October 1st, 2005, 11:26 pm
Posts: 43
Location: Finland
Hi Txquestor,

Agreed, actually I have only posted the relevant part of the script now. It is bound to a hotkey and made specific to a few dialog boxes in the script I have running here :wink:

_________________
For the music lover who can sit and enjoy the sound of someone else's evolving nightmare.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 5th, 2009, 9:42 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
songsoverruins wrote:
it will mess up as soon as you start moving around your dialog box,
You could probably fix that by docking the GUI to the dialog box.

Quote:
X = % X1 + X2
That's rather unconventional. Were you aware of the expression-assignment (:=) operator?
Code:
X := X1 + X2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 5th, 2009, 12:33 pm 
Offline

Joined: October 1st, 2005, 11:26 pm
Posts: 43
Location: Finland
Hey Lexikos,

Thanks for the tip about docking, I'll have to look into that as it might come in handy for other parts of my main script too.

And yes, I know the expression assignment operator. I think it's more a habit that I use the first method. Is there actually any advantage of one over the other? (Other than I guess being more easy to read and understand...)

_________________
For the music lover who can sit and enjoy the sound of someone else's evolving nightmare.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 5th, 2009, 1:52 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
songsoverruins wrote:
(Other than I guess being more easy to read and understand...)
That pretty much covers it...


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Leef_me, Pulover, rbrtryn, XstatyK, Yahoo [Bot] and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group