 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
songsoverruins
Joined: 01 Oct 2005 Posts: 43 Location: Finland
|
Posted: Sat Oct 03, 2009 9:19 am Post subject: Can a control be made transparent? |
|
|
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. |
|
| Back to top |
|
 |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
Posted: Sat Oct 03, 2009 8:36 pm Post subject: REl Transparent Control |
|
|
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  _________________
"Man's quest for knowledge is an expanding series whose limit is infinity" |
|
| Back to top |
|
 |
songsoverruins
Joined: 01 Oct 2005 Posts: 43 Location: Finland
|
Posted: Sat Oct 03, 2009 9:52 pm Post subject: |
|
|
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  _________________ For the music lover who can sit and enjoy the sound of someone else's evolving nightmare. |
|
| Back to top |
|
 |
Roland
Joined: 08 Jun 2006 Posts: 307
|
Posted: Sat Oct 03, 2009 10:10 pm Post subject: |
|
|
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 |
|
|
| Back to top |
|
 |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
Posted: Sat Oct 03, 2009 10:15 pm Post subject: RE: Transparent Dialog |
|
|
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  _________________
"Man's quest for knowledge is an expanding series whose limit is infinity" |
|
| Back to top |
|
 |
songsoverruins
Joined: 01 Oct 2005 Posts: 43 Location: Finland
|
Posted: Sun Oct 04, 2009 12:28 am Post subject: |
|
|
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
| 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. |
|
| Back to top |
|
 |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
Posted: Sun Oct 04, 2009 6:56 pm Post subject: RE: SOLVED-Transparent Dialog |
|
|
Great simplle workaround!
Suggest a couple mods.
On script exit reset Transparent to Normal Window
Limit the scripts action to ONLY window & controls intended for Transparency. _________________
"Man's quest for knowledge is an expanding series whose limit is infinity" |
|
| Back to top |
|
 |
songsoverruins
Joined: 01 Oct 2005 Posts: 43 Location: Finland
|
Posted: Mon Oct 05, 2009 4:46 am Post subject: |
|
|
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  _________________ For the music lover who can sit and enjoy the sound of someone else's evolving nightmare. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Mon Oct 05, 2009 8:42 am Post subject: |
|
|
| 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.
That's rather unconventional. Were you aware of the expression-assignment (:=) operator?
|
|
| Back to top |
|
 |
songsoverruins
Joined: 01 Oct 2005 Posts: 43 Location: Finland
|
Posted: Mon Oct 05, 2009 11:33 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Mon Oct 05, 2009 12:52 pm Post subject: |
|
|
| songsoverruins wrote: | | (Other than I guess being more easy to read and understand...) | That pretty much covers it... |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|