Jump to content
Sign in to follow this  
Michel Claveau

Desktop message

Recommended Posts

Michel Claveau

Hi!

Only a little example, for display short text on desktop.

#include <StaticConstants.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <WINAPI.au3>


;when message is displayed, {Esc} or {Alt}{F4} exit  (or wait for $dureemax ms)
topmessage(2000,"Essai de texte - éèêë")
topmessage(3000,"Try text","with TWO lines")
topmessage(4000,"Première ligne","Second line","Tercera linea")
Exit





Func topmessage($dureemax=2000,$l1="",$l2="",$l3="")
Local $gui
$gui = GUICreate("trans", @DesktopWidth+20, @DesktopHeight+100, -1, -1, -1, $WS_EX_LAYERED)
GUISetFont(48,600)
lignes3($l1,$l2,$l3)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($gui, 0xABCDEF);rend fenêtre transparente
GUICtrlSetState($gui, $GUI_DISABLE) 
GUISetStyle($WS_POPUP, -1, $gui)
GUISetState()
While 1
  $msg = GUIGetMsg($gui)
  If $msg = $GUI_EVENT_CLOSE Then
   ExitLoop
  EndIf
  $dureemax-=21
  If $dureemax<0 Then
   ExitLoop
  EndIf
  Sleep(20)
WEnd
GUIDelete($gui)
EndFunc
Exit



Func lignes3($l1="",$l2="",$l3="")
Local $pasv,$v
$pasv=int((@DesktopHeight-100)/4)
$v=$pasv*3
If $l3<>"" Then
  txt($l3,$v)
EndIf
$v-=$pasv
If $l2<>"" Then
  txt($l2,$v)
  $v-=$pasv
EndIf
If $l1<>"" Then
  txt($l1,$v)
  $v-=$pasv
EndIf
EndFunc


Func txt($txt,$v)
Local $t1,$t1g,$t1n
$t1g=GUICtrlCreateLabel($txt, 10-1, $v-1, @DesktopWidth-40, 100, $SS_CENTER)
GUICtrlSetColor($t1g,0xFFFFFF)
GUICtrlSetBkColor($t1g, $GUI_BKCOLOR_TRANSPARENT)

$t1n=GUICtrlCreateLabel($txt, 10+3, $v+3, @DesktopWidth-40, 100, $SS_CENTER)
GUICtrlSetColor($t1n,0x000000)
GUICtrlSetBkColor($t1n, $GUI_BKCOLOR_TRANSPARENT)

;GUICtrlSetColor($t1n,0x000000)
$t1=GUICtrlCreateLabel($txt, 10, $v, @DesktopWidth-40, 100, $SS_CENTER)
GUICtrlSetColor($t1,0xFF0000)
GUICtrlSetBkColor($t1, $GUI_BKCOLOR_TRANSPARENT)
EndFunc


Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03
If Not $isColorRef Then
  $i_transcolor = Hex(String($i_transcolor), 6)
  $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
EndIf
Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
Select
  Case @error
   Return SetError(@error, 0, 0)
  Case $Ret[0] = 0
   Return SetError(4, _WinAPI_GetLastError(), 0)
  Case Else
   Return 1
EndSelect
EndFunc;==>_WinAPI_SetLayeredWindowAttributes


Func _WinAPI_GetLayeredWindowAttributes($hwnd, ByRef $i_transcolor, ByRef $Transparency,$asColorRef = False)
$i_transcolor = -1
$Transparency = -1
Local $Ret = DllCall("user32.dll", "int", "GetLayeredWindowAttributes", "hwnd", $hwnd, "long*", $i_transcolor, "byte*", $Transparency, "long*", 0)
Select
  Case @error
   Return SetError(@error, 0, 0)
  Case $Ret[0] = 0
   Return SetError(4, _WinAPI_GetLastError(), 0)
  Case Else
   If Not $asColorRef Then
    $Ret[2] = Hex(String($Ret[2]), 6)
    $Ret[2] = '0x' & StringMid($Ret[2], 5, 2) & StringMid($Ret[2], 3, 2) & StringMid($Ret[2], 1, 2)
   EndIf
   $i_transcolor = $Ret[2]
   $Transparency = $Ret[3]
   Return $Ret[4]
EndSelect
EndFunc;==>_WinAPI_GetLayeredWindowAttributes

Edit: add a screenshoot (3st line of the example, reduce to 50%)

post-5540-1245041748_thumb.jpg

Edited by Michel Claveau

Share this post


Link to post
Share on other sites
picea892

Wow, great work. A really nice effect. I'll have to look into this further. I appreciate you sharing

Share this post


Link to post
Share on other sites
Phodexis

i like it, Thanks for Sharing bro.

Share this post


Link to post
Share on other sites
Michel Claveau

Hi!

Thanks, all.

I appreciate your congratulations.

(but, I published, in past, more complete/complex examples, without reaction).

I had a screenshoot in the first message.

Good day!

Share this post


Link to post
Share on other sites
storme

(but, I published, in past, more complete/complex examples, without reaction).

Yeah I know how that feels.

I think from observing the board for a while that the small examples get comments because members can quickly try it and comment without a lot of thought. Larger examples don't get comments because they won't take the time to look through the code or they just don't understand it. OR maybe because it takes a while to read anf understand and by the time they have they have moved on past the forum.

Of course if it's a FULL running program it will get comments from people wanting you to ADD features. It doesn't matter if they understand how it works or not.

My 2c worth

John Morrison

Share this post


Link to post
Share on other sites
ynbIpb

Very good it looks.

But how to remove the strip on top?

post-46851-1245079015_thumb.jpg

Share this post


Link to post
Share on other sites
GEOSoft

Yeah I know how that feels.

I think from observing the board for a while that the small examples get comments because members can quickly try it and comment without a lot of thought. Larger examples don't get comments because they won't take the time to look through the code or they just don't understand it. OR maybe because it takes a while to read anf understand and by the time they have they have moved on past the forum.

Of course if it's a FULL running program it will get comments from people wanting you to ADD features. It doesn't matter if they understand how it works or not.

My 2c worth

John Morrison

You left out the obvious one. If it's posted in Example scripts and I have no use for it then I just ignore the thread totally.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
Michel Claveau

Hi!

But how to remove the strip on top?

It is abnormal that you have this piece of title...

I changed a little trick, for delete your problem. Take again the code of the 1rst message, and try it, please.

Share this post


Link to post
Share on other sites
Michel Claveau

Hi!

> Storm

Certain persons look for the efficiency above all. They will have then the behavior which you describe.

> Geosoft

Your point of view (position?) is, also, on a way of efficience...

***Sorry for my approximative english***

Share this post


Link to post
Share on other sites
ynbIpb

and try it, please.

Now all is OK. Thanks

Share this post


Link to post
Share on other sites
mesale0077

hi

Line 80 Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)

Error:Duplicate function name

why dont worked?

Share this post


Link to post
Share on other sites
Michel Claveau

Hi!

Line 80 Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)

Error:Duplicate function name

why dont worked?

Perhaps a problem with Copy & Paste? The code run OK for many people. I don't see another explanation.

Share this post


Link to post
Share on other sites
BrettF
mesale0077

hi

ı changed WinAPI.au3 in the Include,now no problem but ,"ş,ü,ğ,"İ,Ş,Ü,Ğ," letter is problem and ı changed in the code

GUISetFont(48,600), changed but problem

GUISetFont(48,600,"Microsoft Sans Serif"),

why problem,it cant write ,"ş,ü,ğ,"İ,Ş,Ü,Ğ," not be

Share this post


Link to post
Share on other sites
Michel Claveau

Hi!

If you have Arial-Unicode-MS installed (come with MS-Office), try:

GUISetFont(48,600,0,"Arial Unicode MS")

@-salutations

--

Michel Claveau

Share this post


Link to post
Share on other sites
mesale0077

thank you

GUISetFont(48,600,0,"Microsoft Sans Serif")

changed no problem,worked

nice code

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.