Jump to content
Sign in to follow this  
timmalos

Create Gui Without focus

Recommended Posts

timmalos

hi guys. i cound't found an answer in the forum so i create a new topic.

My questioin is quite simple : I wante to create a TopMost Windows that doesn't take focus.

In fact, i create an application which runs in background and displays answer like a notification, ie 'Windows Live Messenger', as shown below:

http://usb-online.fr/file-download-c30MTA0Mg.html (Direct link image)

The fast is i want this window to be 'Always on top', but i don't want her to take the focus.

If would be quite simple if i had no controls in my GUI.

Using this code : If i add GUISetState(@SW_SHOW) , then i can use my controls but the GUI take the focus when created.

If i delete this line, then it's perfect, GUI is shown 'top most', doesn't take the focus, but I CAN't INTERACT with my controls.

DllCall("user32.dll", "int", "AnimateWindow", "hwnd", WinGetHandle($gui), "int", 600+4*$h, "long", 0x00040008);Slide In Bottom
    GUISetState(@SW_SHOW)
    $t = TimerInit()
    While (TimerDiff($t) <= $duration*1000) ANd (Not $ExitGui)
        Sleep(10)
    WEnd
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", WinGetHandle($gui), "int", 1000, "long", 0x00050004);Slide Out Bottom
    GUIDelete($gui)

Is someone has an idea?

Thx a lot for help,

Tim

There is the full function :

Func Tip($title,$msg,$duration = 8,$icone = 1) ;duration in seconds
    Global $total_width,$total_height,$ExitGui = FALSE
    Local $h = 70, $w = 400 ;Hauteur et Largeur

    ;Maintenant on trouve la hauteur de la barre des taches
    $hMonitor = GetMonitorFromPoint(0, 0)
    If $hMonitor <> 0 Then
        GetMonitorInfos($hMonitor)
    EndIf
    $Nb = StringSplit($msg,@CRLF)
    $h = $h+$Nb[0]*8

    ;On demarre notre fonction
    $gui=GUICreate("",$w,$h,$total_width-$w-4,$total_height-$h+4,0x80880000,$WS_EX_TOPMOST)
    $n2 = GUICtrlCreateIcon("shell32.dll", -28, $w-18, 2, 16, 16)
    GUICtrlSetCursor(-1,3)
    GUICtrlSetOnEvent(-1,"ExitGui")

    If $icone = 3 Then
        $icon = GUICtrlCreateIcon("ieframe.dll", -88, 10, 6)
    Else
        $icon = GUICtrlCreateIcon("ieframe.dll", -89, 10, 6)
    EndIf
    GUICtrlCreateLabel($title,50,10,$w-70,20)
    GUICtrlSetFont(-1, 14, -1, -1, "Trebuchet MS")


    ;$label = _GuiCtrlTexte_Create(50,40,$w-50,$h-40-20,"white","black","Arial",8)
    ;_GuiCtrlTexte_Write($label,$msg)
    $label=GUICtrlCreateLabel($msg,50,40,$w-50,$h-40-20)
    GUICtrlSetFont(-1, 8, -1, -1, "Arial")

    Global $link=GUICtrlCreateLabel("Cliquez ici pour plus de détails",50,$h-20,$w-50,20)
    GUICtrlSetOnEvent($link,"PlusDeDetails")
    GUICtrlSetCursor($link,5)
    GUICtrlSetColor($link, 0x0000FF)



    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", WinGetHandle($gui), "int", 600+4*$h, "long", 0x00040008);Slide In Bottom
    GUISetState(@SW_SHOW)
    $t = TimerInit()
    While (TimerDiff($t) <= $duration*1000) ANd (Not $ExitGui)
        Sleep(10)
    WEnd
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", WinGetHandle($gui), "int", 1000, "long", 0x00050004);Slide Out Bottom
    GUIDelete($gui)
EndFunc
Edited by timmalos

Share this post


Link to post
Share on other sites
Melba23

timmalos,

You need to set the GUI state to @SW_SHOWNOACTIVATE initially and then reactivate the previously active GUI when you action a control on yours. :)

This shows how you might do it:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 200, 100)

$hButton = GUICtrlCreateButton("Press", 60, 40, 80, 30)

WinSetOnTop($hGUI, "", 1)

; Create the GUI but do not activate it
GUISetState(@SW_SHOWNOACTIVATE)

While 1

    ; If our GUI is not active then save the handle of the GUI that is
    If Not WinActive($hGUI) Then
        $hLastActive = WinGetHandle("[ACTIVE]")
    EndIf

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            ConsoleWrite("Button pressed!" & @CRLF)
            ; And reactivate the GUI that was just active
            WinActivate($hLastActive)
    EndSwitch

WEnd

Does that help? :mellow:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
timmalos

Ohh, really don't know how i could miss this.

Thx a lot !

Share this post


Link to post
Share on other sites
Melba23

timmalos,

Il n'y a pas de quoi! :mellow:

M23

Trans: No problem.


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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.