Sign in to follow this  
Followers 0
Achilles

Cool code

13 posts in this topic

#1 ·  Posted (edited)

This is kind of hard to explain but I'll try. It will show all the items in a folder you choose on the right of the screen when you move the mouse to the bottom right corner of the screen... Then when you move the mouse back to the corner it will hide the items... Considering that my explanation made little sense you might just want to try it :P

#include <GUIConstants.au3>
#Include <File.au3>
#include <Misc.au3>
Opt("RunErrorsFatal", 0)  
$on = False
Dim $button[999]
Dim $back, $next

$gui = GUICreate("", 480, 105, -1, -1, $WS_CAPTION, $WS_EX_TOOLWINDOW)
    GUISetBkColor (0xA29CFE)
GuiCtrlCreateLabel("This program enables you to view the files in a folder by simply moving the mouse to the bottom right corner of the screen. Please choose the directory you would like to be able to view.", 10, 5, 460, 30 )
$dir = GUICtrlCreateEdit("Click 'Browse' choose a folder...", 10,  45, 405, 15, BitOr($ES_READONLY, $ES_CENTER), $WS_EX_WINDOWEDGE)
$browse = GUICtrlCreateButton("Browse", 420,  40, 55, 25)
$exit = GuiCtrlCreateButton("Exit", 200, 70, 80, 30)
$ok = GuiCtrlCreateButton("OK", 320, 70, 80, 30)
GuiCtrlSetState(-1, $GUI_FOCUS)
GUISetState(@SW_Show)

While 1 
    $msg = GuiGetMsg()
        Select
            Case $msg = $exit 
                Exit 
            Case $msg = $browse
                $directory = FileSelectFolder("Choose the folder where you files are located.", @HOMEDRIVE)
                GuiCtrlSetData($dir, $directory)
            Case $msg = $ok
                If guictrlRead($dir) <> "Click 'Browse' choose a folder..." then
                    $numFiles = _FileListToArray($directory)
                    GuiDelete($gui)             
                    $y = 5
                    $gui = GuiCreate("Files", 250, @DesktopHeight, @DesktopWidth - 250, 0, $WS_POPUP, $WS_EX_TOOLWINDOW)
                    GUISetBkColor(0x111111)
                    WinSetTrans("Files", "", 250)
                    WinSetOnTop("Files", "", 1)
                    For $a = 1 to $numFiles[0] 
                        $temp = StringSplit($numFiles[$a], ".")
                        $tempLast = $temp[0]
                        If $temp[$tempLast] <> "db" then 
                            If $y > 980 Then
                                $next = GuiCtrlCreateButton("Next", 70, @DesktopHeight - 56, 130, 40)
                                ExitLoop
                            Else
                                $button[$a] = GuiCtrlCreateButton($numFiles[$a], 10, $y, 230, 30)
                            Endif
                        Endif
                        $y += 35
                    Next
                    WinSetTrans("Files", "", 0)
                    GuiSetState()

                    While 1
                        $pos = MouseGetPos()
                            If $pos[0] + 5 > @DesktopWidth And $pos[1] + 5 > @DesktopHeight Then
                                If $on = False Then
                                    $on = True
                                    WinSetOnTop("Files", "", 1)
                                    _WinFade($gui, 0, 250, 7, 10, 0)
                                Else
                                    $on = False
                                    _WinFade($gui, 250, 0, 7, 10, -1)
                                    WinSetOnTop("Files", "", 0)
                                EndIf
                                Sleep(300)
                            EndIf                   
                        $tempmsg = GuiGetMsg()
                            If $tempmsg <> $msg then 
                                If $tempmsg <> "0" and  $tempmsg <> "-11" then
                                    If $msg = 7 then 
                                        $pos = MouseGetPos()
                                        If $pos[0] > @DesktopWidth - 250 and $pos[1] < 200 then 
                                            ShellExecute($directory & "\" & GuiCtrlRead($button[7]))
                                        EndIf                                       
                                    Else
                                        For $a = 1 to $numFiles[0]
                                            If $msg = $button[$a] then 
                                                ShellExecute($directory & "\" & GuiCtrlRead($button[$a]))
                                            Endif
                                        Next
                                    EndIf
                                    $msg = $tempMsg
                                Endif
                            Endif                       
                            If $msg = $next then 
                                For $b = 1 to $a 
                                    GuiCtrlSetState($button[$b], $GUI_HIDE)
                                Next
                                GuiCtrlSetState($next, $GUI_HIDE)
                                $back = GuiCtrlCreateButton("Back", 70, 10, 130, 40)
                                $y = 60 
                                For $c = 29 to $numFiles[0] 
                                    $temp = StringSplit($numFiles[$c], ".")
                                    $tempLast = $temp[0]
                                    If $temp[$tempLast] <> "db" then 
                                        If $y > 1010 Then
                                            ExitLoop
                                        Else
                                            $button[$c] = GuiCtrlCreateButton($numFiles[$c], 10, $y, 230, 30)
                                        Endif
                                    Endif
                                    $y += 35    
                                Next                        
                            Endif                   
                            If $msg = $back then 
                                For $a = 29 to $numFiles[0]
                                    GuiCtrlSetState($button[$a], $GUI_HIDE)
                                Next
                                GuiCtrlSetState($back, $GUI_HIDE)
                                GuiCtrlSetState($next, $GUI_SHOW)
                                For $a = 1 to 28
                                    GuiCtrlSetState($button[$a], $GUI_SHOW)
                                Next
                            Endif                       
                            If BitAND(_IsPressed("A2"), _ISpressed("58")) or BitAND(_IsPressed("A3"), _ISpressed("58")) Then Exit
                    Wend
                Endif
        EndSelect
    Wend
    
Func _WinFade($hWnd, $iStart, $iEnd, $iStep = 3, $iSleep = 1, $iFade = 1); $iFade - 1 = Fade Out - 0 = Fade In
    If $iFade Then
        For $iCount = $iStart To $iEnd Step - $iStep
            WinSetTrans($hWnd, '', $iCount)
            Sleep($iSleep)
        Next
        Return 1
    ElseIf Not $iFade Then
        For $iCount = $iStart To $iEnd Step $iStep
            WinSetTrans($hWnd, '', $iCount)
            Sleep($iSleep)
        Next
        Return 1
    EndIf
    Return SetError(1, 0, 0)
EndFunc

EDIT: Added a fade function and made it so you can't click 'ok' without changing the directory

Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites



Might want to check out $next :P

Share this post


Link to post
Share on other sites

Thanks, it's better now. I'll be posting one that fades in and out soon...

what about a hot key to close the script ?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Cool!! :P

Try changing buttons to a tree view and create a flag to control that intermitent fade while mouse pointer still on corner.

Edited by A. Percy

Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator[center] VW Bug user[/center]Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral

Share this post


Link to post
Share on other sites

what about a hot key to close the script ?

Reply to ScriptUSER: Ctrl X

Reply to A. Percy: I'll try making one like that, and I'll fix the corner thing too

Reply to Secure_ICT: What do you mean by more like a sidebar? Like smaller or something?

To all who commented: Thanks for the input


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

I have a really cool re-work of this script... It's not done yet, but it's very nice.

I'll post it when completed.


Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite

Share this post


Link to post
Share on other sites

As promised... Sorry for ganking yoru code concept, but it was too good to resist :P

#include <GUIConstants.au3>
#Include <File.au3>
#Include <Array.au3>
#include <Misc.au3>
#include <Math.au3>

Opt("RunErrorsFatal", 0)  

$FOLDERGUI = GUICreate("Folder Select", 150, 150, @DesktopWidth - 400, @DesktopHeight-170, $WS_POPUP, $WS_EX_TOOLWINDOW)
GUISetBkColor(0xDDDDDD)

    Global $GUI_Folder[999]
    Global $GUI_FolderBG[999]
    $GUIFolderLabels = 0

WinSetOnTop('Folder Select','',1)

$GUI = GUICreate("Browser", 250, 250, @DesktopWidth - 250, @DesktopHeight - 250, $WS_POPUP, $WS_EX_TOOLWINDOW)
GUISetBkColor(0xFFFFFF)

$NoFolders = 0

GUISwitch($GUI)
    
$FolderDown = GUICtrlCreatePic('down.bmp',12,250-16,11,11)
$FolderUp = GUICtrlCreatePic('up.bmp',24,250-16,11,11)
$CurrentDir = GUICtrlCreateLabel('',36,250-17,250,24)
    
    Global $GUI_File[999]
    Global $GUI_BG[999]
    Global $GUI_Go[999]
    Global $GUI_Delete[999]
    $GUILabels = 0
    
$CurrentDirectory = ''
$NoFiles = 0

WinSetOnTop('Browser','',1)

Browse(@ScriptDir)

Do
    $msg = GUIGetMsg()
    
    $MousePos = MouseGetPos()
    
    Select
        Case $msg = $FolderDown
            If StringRight(StringLeft($CurrentDirectory,StringInStr($CurrentDirectory,'\',0,-1)-1),1) = ':' Then
                If StringLeft($CurrentDirectory,StringInStr($CurrentDirectory,'\',0,-1)) <> $CurrentDirectory Then Browse(StringLeft($CurrentDirectory,StringInStr($CurrentDirectory,'\',0,-1)))
            Else
                If StringLeft($CurrentDirectory,StringInStr($CurrentDirectory,'\',0,-1)-1) <> $CurrentDirectory Then Browse(StringLeft($CurrentDirectory,StringInStr($CurrentDirectory,'\',0,-1)-1))
            EndIf
        Case $msg = $FolderUp
            GUISwitch($FOLDERGUI)
            GUISetState()
            $CurrentDirectory = $CurrentDirectory & '\' & FolderSelect($CurrentDirectory)
            MsgBox(0,'',$CurrentDirectory)
            GUISetState(@SW_HIDE)
            GUISwitch($GUI)
            Browse($CurrentDirectory)
        Case $msg >= 8 And $MousePos[0] > @DesktopWidth - 32
            If _MathCheckDiv($msg, 2) = 1 Then
                If MsgBox(4,'Confirm recyle','Are you sure you want to recycle "' & GUICtrlRead($GUI_File[$msg/4-1]) & '"?') = 6 Then FileRecycle($CurrentDirectory & '\' & GUICtrlRead($GUI_File[$msg/4-1]))
                Browse($CurrentDirectory)
            Else
                MsgBox(0,'','Go: ' & GUICtrlRead($GUI_File[$msg/4-1]))
            EndIf
    EndSelect
Until $msg = $GUI_EVENT_CLOSE

Func Browse($Dir)
    $Files = _FileListToArray($Dir,'*.*',1)
    
    For $i = 1 To $GUILabels
        GUICtrlDelete($GUI_File[$i])
        GUICtrlDelete($GUI_BG[$i])
        GUICtrlDelete($GUI_Go[$i])
        GUICtrlDelete($GUI_Delete[$i])
    Next
    
    $GUILabels = 0

    If IsArray($Files) And $Files[0] > 0  Then
        GUICtrlDelete($NoFiles)
        
        WinMove('Browser','',@DesktopWidth - 250, @DesktopHeight-14*$Files[0]-50,250,14*$Files[0]+50)
        
        For $i = 1 To $Files[0]
            $GUILabels = $GUILabels + 1
            $GUI_BG[$i] = GUICtrlCreateLabel('',4,14*$i,250-34,12)
            GUICtrlSetBkColor(-1,0xDDDDDD)
            $GUI_File[$i] = GUICtrlCreateLabel($Files[$i],30,14*$i,180,12,$SS_RIGHT)
            GUICtrlSetBkColor(-1,0xDDDDDD)
            $GUI_Go[$i] = GUICtrlCreatePic('o.bmp',250-34+4,14*$i,12,12)
            GUICtrlSetState(-1,$GUI_SHOW)
            $GUI_Delete[$i] = GUICtrlCreatePic('x.bmp',250-22+4,14*$i,12,12)
            GUICtrlSetState(-1,$GUI_SHOW)
        Next

        If StringLen($Dir) > 35 Then
            For $l = 3 To 1 Step -1
                If StringLen(StringLeft($Dir,StringInStr($Dir,'\',0,$l)) & StringRight($Dir,StringLen($Dir) - StringInStr($Dir,'\',0,-1))) <= 35 Then
                    GUICtrlSetData($CurrentDir,StringLeft($Dir,StringInStr($Dir,'\',0,$l)) & ' ... \' & StringRight($Dir,StringLen($Dir) - StringInStr($Dir,'\',0,-1)) & '\')
                    ExitLoop
                EndIf
            Next
        Else
            GUICtrlSetData($CurrentDir,$Dir)
        Endif
        
        GUICtrlSetPos($FolderDown,12,14*$Files[0]+50-16,11,11)
        GUICtrlSetPos($FolderUp,24,14*$Files[0]+50-16,11,11)
        GUICtrlSetPos($CurrentDir,36,14*$Files[0]+50-17)
    Else
        WinMove('Browser','',@DesktopWidth - 250, @DesktopHeight-150,250,150)
        
        GUICtrlDelete($NoFiles)
        $NoFiles = GUICtrlCreateLabel('No files are in this directory',25,25)
        
        GUICtrlSetPos($FolderDown,12,150-30,11,11)
        GUICtrlSetPos($FolderUp,24,150-30,11,11)
        GUICtrlSetPos($CurrentDir,36,150-29)
    EndIf

    GUISetState()
    
    $CurrentDirectory = $Dir
EndFunc

Func FolderSelect($Dir)
    $Folders = _FileListToArray($Dir,'*.*',2)
    
    For $i = 1 To $GUIFolderLabels
        GUICtrlDelete($GUI_Folder[$i])
        GUICtrlDelete($GUI_FolderBG[$i])
    Next
    
    $GUIFolderLabels = 0

    If IsArray($Folders) And $Folders[0] > 0 Then
        GUICtrlDelete($NoFolders)
        
        WinMove('Folder Select','',@DesktopWidth - 400, @DesktopHeight-14*$Folders[0]-14,150,14*$Folders[0])
        
        For $i = 1 To $Folders[0]
            $GUIFolderLabels = $GUIFolderLabels + 1
            $GUI_FolderBG[$i] = GUICtrlCreateLabel('',4,14*$i-14,146,12)
            GUICtrlSetBkColor(-1,0xFFFFFF)
            $GUI_Folder[$i] = GUICtrlCreateLabel($Folders[$i],4,14*$i-14,146,12,$SS_RIGHT)
            GUICtrlSetBkColor(-1,0xFFFFFF)
        Next

        GUISetState()
    
        Do
            $FolderMsg = GUIGetMsg()
            
            Select
                Case $FolderMsg > 0
                    Return GUICtrlRead($FolderMsg+1)
            EndSelect
        Until $FolderMsg = $GUI_EVENT_CLOSE
    Else
        WinMove('Folder Select','',@DesktopWidth - 400, @DesktopHeight-30,150,20)
        
        GUICtrlDelete($NoFolders)
        $NoFolders = GUICtrlCreateLabel('No folders are in this directory',10,5)

        GUISetState()
        
        Sleep(1000)
    EndIf
    
    $CurrentDirectory = $Dir
EndFunc

down.bmp

o.bmp

up.bmp

x.bmp


Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite

Share this post


Link to post
Share on other sites

Josh....

it might be easier if you post a zip file with all the pics and source

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

As promised... Sorry for ganking yoru code concept, but it was too good to resist :P

That's pretty cool. For some reason the: '$msg/4-1' wasn't working for me because $msg was like 4104 or bigger. I changed it to '($msg-4107)/4 + 1' and that worked. Also there was some label ($msg number was 4104) that didn't do anything so I changed that one part too:

Case $msg >= 8 And $MousePos[0] > @DesktopWidth - 32
    If $msg <> 4104 then 
        If _MathCheckDiv($msg, 2) = 1 Then
            If MsgBox(4,'','Go: ' & $currentDirectory & "\" & GUICtrlRead($GUI_File[($msg-4107)/4 + 1])) = 6 Then ShellExecute($currentDirectory & "\" & GUICtrlRead($GUI_File[($msg-4107)/4 + 1]))
            Browse($CurrentDirectory)
        Else
            If MsgBox(4,'Confirm recyle','Are you sure you want to recycle "' & GUICtrlRead($GUI_File[($msg-4107)/4 + 1]) & '"?') = 6 Then FileRecycle($CurrentDirectory & '\' & GUICtrlRead($GUI_File[($msg-4107)/4 + 1]));$msg/4-1
            Browse($CurrentDirectory)
        EndIf
    Endif

That also switched the red x and the green swirl thing, I thought it made more sense to erase by clicking X...

Last I added a hotkey to exit by adding this:

If BitAND(_IsPressed("A2"), _ISpressed("58")) or BitAND(_IsPressed("A3"), _ISpressed("58")) Then Exit

Nice program!

Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

This isn't exactly polished very well... But it looks cool :P

As I said before, nice concept, and thanks for the idea.


Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite

Share this post


Link to post
Share on other sites

Interesting. This has inspired me to make a Firefox plugin that runs AutoIt scripts. Actually, I have a forum suggestion now...

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