Sign in to follow this  
Followers 0
eHrgo

AutoHide GUI: Without CursorGetPos?

6 posts in this topic

#1 ·  Posted (edited)

Hi guys, I've codded this script to apply it to another script, I though I would just put Loop this part:

$Curspos=MouseGetPos()
    $WinPos=WinGetPos('WinTest')
        If $Curspos[1]<40 Then ;If the cursor is located in a specific area 
            Call('Appear')
        Else 
            Call('Disapear')
        EndIf
GUISetState(@SW_SHOW)oÝ÷ Ú)í¢Ø^{¬µéí)nëHq©í!ò¢ØZ¶Ø^­è¬jZ-¡óh­ x{ô¡£bæÞq«¬zߺw-ÜjYpÈmjG{rÝ°KÞ¯-t±ç,¨ºIèÂ'Èq©Ý¢ØZ·­­¶¬)Z+a¶½éí^J¶§X¤xéĽéí
ê좹hq«^v)Ú²øj·jëh×6#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

Global $Curspos
Global $WinPos
Global $spd=10

GUICreate('WinTest', 400, 20, @DesktopWidth/2-200 , -20, $WS_POPUP,$WS_EX_TOPMOST ) ;Create a centered GUI on top [hidden] of the screen.

;QUIT BUTTON
$quit=GUICtrlCreateButton('Quit', 350, 1, 50, 20)
GUICtrlSetOnEvent($quit, 'Quit')

;LOOP TO CHECK CURSOR POS-------------------------------------------------------------
While 1
    $Curspos=MouseGetPos()
    $WinPos=WinGetPos('WinTest')
        If $Curspos[1]<40 Then ;If the cursor is located in a specific area 
            Call('Appear')
        Else 
            Call('Disapear')
        EndIf
GUISetState(@SW_SHOW)
Wend
;/LOOP TO CHECK CURSOR POS-------------------------------------------------------------

Func Appear()
    While $WinPos[1]<0
        $WinPos=WinGetPos('WinTest')
        WinMove('WinTest', '', $WinPos[0], $WinPos[1]+1)
        Sleep($spd) ;Speed modification
    WEnd
EndFunc
    
Func Disapear()
    While $WinPos[1]>-20
        $WinPos=WinGetPos('WinTest')
        WinMove('WinTest', '', $WinPos[0], $WinPos[1]-1)
        Sleep($spd) ;Speed modification
    WEnd
EndFunc


Func Quit()
    Exit 0
EndFunc

Thanks for your precious help

Edited by eHrgo

Sorry for my Bad English.

Share this post


Link to post
Share on other sites



Wow.. You didn't read half of my script.

My two funcs Appear/disapear move the windows like a Autohide window.

Try it I cant really explain it.


Sorry for my Bad English.

Share this post


Link to post
Share on other sites

Wow.. You didn't read half of my script.

My two funcs Appear/disapear move the windows like a Autohide window.

Try it I cant really explain it.

This is a way to amke the window move but only 1 pixel for every loop of the main while loop. This means that other things can be done while the window is moving but then the window movement will be jerky.

The other way to do it is to have a seperate script which you call to set the window position.

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

Global $Curspos
Global $WinPos
Global $spd=10
Global $startpd, $startpu

GUICreate('WinTest', 400, 20, @DesktopWidth/2-200 , -20, $WS_POPUP,$WS_EX_TOPMOST );Create a centered GUI on top [hidden] of the screen.

;QUIT BUTTON
$quit=GUICtrlCreateButton('Quit', 350, 1, 50, 20)
GUICtrlSetOnEvent($quit, 'Quit')
GUISetState(@SW_SHOW)
$pulleddown = False
$pullingdown = False
$pullingup = False
$pulledup = True
While 1

    setposition()
;do other things here
    

Wend


Func setposition()
    $Curspos=MouseGetPos()
    $WinPos=WinGetPos('WinTest')
    If $Curspos[1]<40 And Not $pulleddown And Not $pullingdown  Then
        $startpd = TimerInit()
        $pullingdown = True;If the cursor is located in a specific area
        $pullingup = False
        $pulledup = False
    Else
        If $Curspos[1] > 40 And Not $pulledup And Not $pullingup Then
            $pullingup = True
            $pulleddown = False
            $Pullingdown = False
            $startpu = TimerInit()
        EndIf
    EndIf
    
    If $pullingdown Then
        if TimerDiff($startpd) > $spd Then
            If $WinPos[1] > -1 Then
                $pullingdown = False
                $pulleddown = True
            Else
                WinMove('WinTest', '', $WinPos[0], $WinPos[1]+1)
                $startpd = TimerInit()
            EndIf
        EndIf
        
        
    Else
        If $pullingup Then
            If TimerDiff($startpu) > $spd Then
                If $WinPos[1] < -20 Then
                    $pullingup = False
                    $pulledup = True
                Else
                    WinMove('WinTest', '', $WinPos[0], $WinPos[1]-1)
                    $startpu = TimerInit()
                EndIf
                
                
            EndIf
            
        EndIf
    EndIf
    
EndFunc
#cs
Func Appear()
    While $WinPos[1]<0
        $WinPos=WinGetPos('WinTest')
        WinMove('WinTest', '', $WinPos[0], $WinPos[1]+1)
        Sleep($spd);Speed modification
    WEnd
EndFunc

Func Disapear()
    While $WinPos[1]>-20
        $WinPos=WinGetPos('WinTest')
        WinMove('WinTest', '', $WinPos[0], $WinPos[1]-1)
        Sleep($spd);Speed modification
    WEnd
EndFunc
#ce

Func Quit()
    Exit 0
EndFunc

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Have AdlibEnable() do your window check independently of the rest of the script.

This will check it twice per second:

AdlibEnable("_CheckMousePos", 500)

Func _CheckMousePos()
    $Curspos = MouseGetPos()
    ; $WinPos = WinGetPos('WinTest') ; <--- Variable $WinPos doesn't get used in this function?
    If $Curspos[1] < 40 Then ;If the cursor is located in a specific area
        Appear()
    Else
        Disapear()
    EndIf
EndFunc   ;==>_CheckMousePos

P.S. You don't normally need Call() to run a function (see above). That's only for the rare occasions when you have to specify the function name with variables.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Have AdlibEnable() do your window check independently of the rest of the script.

This will check it twice per second:

AdlibEnable("_CheckMousePos", 500)

Func _CheckMousePos()
    $Curspos = MouseGetPos()
    ; $WinPos = WinGetPos('WinTest') ; <--- Variable $WinPos doesn't get used in this function?
    If $Curspos[1] < 40 Then ;If the cursor is located in a specific area
        Appear()
    Else
        Disapear()
    EndIf
EndFunc   ;==>_CheckMousePos

P.S. You don't normally need Call() to run a function (see above). That's only for the rare occasions when you have to specify the function name with variables.

:)

PsaltyDS,

that's a better idea than mine. I was trying to stop the window move taking the time from other functions but still give a smooth movement, but I see that I was getting things round the wrong way!


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thanks a lot, i'm gonna try it.


Sorry for my Bad English.

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