Sign in to follow this  
Followers 0
CodyBarrett

Gui isn't on top.. but takes focus

9 posts in this topic

hi lol im making a CPU usage Gui... and taking the easy way out im afraid.. but the GUI doesn't let me interact with other programs... it always has the Focus... BUT it won't let me stick it on top.. Winsetontop doesn't work... Guiseststate ($GUI,$WS_EX_TOPMOST ) doesn't work.. im looking to have it always on top.. but unfocused

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#NoTrayIcon
HotKeySet ('{ESC}', '_Exit_')
Opt ('GUIoneventmode',1)
$Gui = GUICreate (@ScriptName, 200,100, -1 ,-1, $WS_POPUPWINDOW)
GUISetBkColor (0xFFFFA2, $Gui)
$lStatus = GUICtrlCreateLabel ('', 1, 1, 198,98, $SS_CENTER)
GUICtrlSetBkColor (-1, 0x000000)
GUICtrlSetFont (-1, 60, '', '', 'Fixedsys')
GUICtrlSetColor (-1, 0xFFFFA2)
GUICtrlSetOnEvent (-1, '_Win_Move_')
GUISetOnEvent ($GUI_EVENT_CLOSE,'_exit_',$Gui)
GUISetState()
WinSetTrans ($Gui, '', 100)
While 1
    If Not ProcessExists ('Taskmrg.exe') Then Run(@SystemDir & '\taskmgr.exe', '', @SW_HIDE)
    $iStatus = StatusbarGetText ('Windows Task Manager', '', 2)
    GUICtrlSetData ($lStatus, StringTrimLeft ($iStatus, 10))
    Sleep (300)
WEnd

Func _Win_Move_ ()
    $MouseXY = MouseGetPos ()
    $WinXY = WinGetPos ($Gui)
    $xOff = $MouseXY[0] - $WinXY[0]
    $yOFF = $MouseXY[1] - $WinXY[1]
    While _IsPressed ('01')
        WinMove ($Gui, '',MouseGetPos (0) - $xOff ,MouseGetPos (1) - $yOFF)
        Sleep (100)
    WEnd
EndFunc

Func _Exit_ ()
    Exit
EndFunc

Share this post


Link to post
Share on other sites



#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Global $hGui = GUICreate("Click-through topmost GUI", -1, -1, -1, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_TRANSPARENT, $WS_EX_LAYERED)) ; you can omit WS_EX_LAYERED
WinSetTrans($hGui, 0, 170)
GUISetState()


While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop ; yeah right 
WEnd
;by trancexx

http://www.autoitscript.com/forum/index.ph...mp;#entry672609

guys really... it takes 5 saconds to make a search... it's the 3 time the question is beeing asked in a week!


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

thats not what i was looking for.. you have to click the GUI to move it...

i've never encountered this problem... and i've been using popups for a month or so now so i have no idea whats wrong...

Edited by CodyBarrett

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

edit:

nevermind i get it

Edited by lordicast

[Cheeky]Comment[/Cheeky]

Share this post


Link to post
Share on other sites

While 1

If Not ProcessExists ('Taskmrg.exe') Then Run(@SystemDir & '\taskmgr.exe', '', @SW_HIDE)

$iStatus = StatusbarGetText ('Windows Task Manager', '', 2)

GUICtrlSetData ($lStatus, StringTrimLeft ($iStatus, 10))

Sleep (300)

WEnd

Unless you have some other process you didn't mention, 'Taskmrg.exe' will never be running, so you keep re-launching 'taskmgr.exe'.

Since it only allows one instance, it activates itself when you relaunch the exe.

If it were some other process, you'd have a million stray processes and run out of memory fast.


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

Haha :) good eyes.

Use this to reduce flickering and to force window the never gain focus:

Const $WS_EX_NOACTIVATE = 0x08000000
Const $WS_EX_COMPOSITED = 0x02000000

$hDll = DllOpen('user32.dll') ; For _IsPressed

$Gui = GUICreate (@ScriptName, 200,100, -1 ,-1, $WS_POPUPWINDOW, BitOR($WS_EX_NOACTIVATE, $WS_EX_COMPOSITED, $WS_EX_TOPMOST))
GUISetBkColor (0xFFFFA2, $Gui)
$lStatus = GUICtrlCreateLabel ('', 1, 1, 198,98, $SS_CENTER, BitOR($WS_EX_NOACTIVATE, $WS_EX_COMPOSITED))

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

well.. i want it to gain focus for the user to move the window around the screen :) but thanks ill test it out and get back to you

EDIT... flicker is gone.. but it still focuses itself.. i can't type on another window

Edited by CodyBarrett

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Don't know why but it's working perfectly for me. I've changed the transparency and disabled $WS_POPUPWINDOW so you can see the title bar becomes blue, noting it's taking the focus but nop, 909090.

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#NoTrayIcon
HotKeySet ('{ESC}', '_Exit_')
Opt ('GUIoneventmode',1)

Const $WS_EX_NOACTIVATE = 0x08000000
Const $WS_EX_COMPOSITED = 0x02000000

$hDll = DllOpen('user32.dll') ; For _IsPressed

$Gui = GUICreate (@ScriptName, 200,100, -1 ,-1, -1, BitOR($WS_EX_NOACTIVATE, $WS_EX_COMPOSITED, $WS_EX_TOPMOST))
GUISetBkColor (0xFFFFA2, $Gui)
$lStatus = GUICtrlCreateLabel ('', 1, 1, 198,98, $SS_CENTER, BitOR($WS_EX_NOACTIVATE, $WS_EX_COMPOSITED))
GUICtrlSetBkColor (-1, 0x000000)
GUICtrlSetFont (-1, 60, '', '', 'Fixedsys')
GUICtrlSetColor (-1, 0xFFFFA2)
GUICtrlSetOnEvent (-1, '_Win_Move_')
GUISetOnEvent ($GUI_EVENT_CLOSE,'_exit_',$Gui)
GUISetState()
WinSetTrans ($Gui, '', 200)
While 1
    If Not ProcessExists ('taskmgr.exe') Then Run('taskmgr.exe', '', @SW_HIDE)
    $iStatus = StatusbarGetText ('Windows Task Manager', '', 2)
    GUICtrlSetData ($lStatus, StringTrimLeft ($iStatus, 10))
    Sleep (100)
WEnd

Func _Win_Move_ ()
    $MouseXY = MouseGetPos ()
    $WinXY = WinGetPos ($Gui)
    $xOff = $MouseXY[0] - $WinXY[0]
    $yOFF = $MouseXY[1] - $WinXY[1]
    While _IsPressed ('01', $hDll)
        WinMove ($Gui, '',MouseGetPos (0) - $xOff ,MouseGetPos (1) - $yOFF)
        Sleep (100)
    WEnd
EndFunc

Func _Exit_ ()
    GUIDelete()
    ProcessClose('taskmgr.exe')
    DllClose($hDll)
    Exit
EndFunc
Edited by Authenticity

Share this post


Link to post
Share on other sites

could it be the POPup type?

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  
Followers 0