AutoHotkey Community

It is currently May 26th, 2012, 7:51 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Launcher 1.2
PostPosted: May 17th, 2009, 5:25 pm 
I just started learning how to program with autohotkey and the reason that I started was simply that I wanted a program which was linked to my middle click and basically just dropped a menu listing program links that I could launch without having to go to my start button.

The code I am working with is shown below. All you have to do to add items to the launchers list is simply drop a .lnk to the exe in the Launcher subfolder of your MyDocuments folder, which, you can access directly from the launcher by hitting the edit button. After adding or subtracting a link file simply press update and the list will be updated. There is a check box which indicates to the program if it should close or stay open in response to a left click outside of the main window...

yeah so my newbieness might show but, what do you think?

Code:
--------------------------------------------------------------------------
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

#NoTrayIcon





Start2:


Gui, Add, ListView , Grid 0x800000 -Hdr r15 w90 gMyListView , Programs

Gui, Add, Checkbox, VOpen, Stay Open

Gui, Add, Button,, Edit

Gui, Add, Button, xp+44 yp, Update

Gui, -SysMenu

Gui, Font,, MS sans serif


Loop, %A_MyDocuments%\Launcher\*.*
{

StringTrimRight, Loop, A_LoopFileName, 4

LV_Add( "", Loop )

LV_ModifyCol(-1)
}
IfEqual, a, 1
 {
 Gui, Show, X%mX% Y%mY% AutoSize, Launcher
 IfEqual, c, 1
  {
  GuiControl, , Stay Open, 1
  }
 a = 0
 c = 0
 }
return



~LButton::

Gui, Submit, NoHide

IfWinNotActive, Launcher
 {

  IfLess,Open, 1
   {
    Gui, destroy
    Goto, Start2
   }
 }

Return

~MButton::

MouseGetPos, mX, mY
Gui, Show, X%mX% Y%mY% AutoSize, Launcher


MyListView:
if A_GuiEvent = doubleclick
{
    LV_GetText(RowText, A_EventInfo)

    Run, %A_MyDocuments%\Launcher\%RowText%
    Gui, destroy
    Goto, Start2
}

return

ButtonEdit:
GuiControl, , Stay Open, 1
Run, %A_MyDocuments%\Launcher
return

ButtonUpdate:
IfEqual, open, 1
c = 1
a = 1
Gui, Destroy
GoTo, Start2
return


Report this post
Top
  
Reply with quote  
 Post subject: screen shot
PostPosted: May 17th, 2009, 8:01 pm 
Image


Report this post
Top
  
Reply with quote  
PostPosted: May 17th, 2009, 9:02 pm 
I think this model is a bit better as it will allow you to switch between the programs you have launched from the menu by double clicking their menu entries and also it excludes anything but .lnk files from the menu even if they are present in the default list directory

Code:
;

#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

#NoTrayIcon





Start2:


Gui, Add, ListView , Grid 0x800000 -Hdr r15 w90 gMyListView , Programs

Gui, Add, Checkbox, VOpen, Stay Open

Gui, Add, Button,, Edit

Gui, Add, Button, xp+44 yp, Update

Gui, -SysMenu

Gui, Font,, MS sans serif


Loop, %A_MyDocuments%\Launcher\*.lnk
{

StringTrimRight, Loop, A_LoopFileName, 4

LV_Add( "", Loop )

LV_ModifyCol(-1)
}
IfEqual, a, 1
 {
 Gui, Show, X%mX% Y%mY% AutoSize, Launcher
 IfEqual, c, 1
  {
  GuiControl, , Stay Open, 1
  }
 a = 0
 c = 0
 }
return



~LButton::

Gui, Submit, NoHide

IfWinNotActive, Launcher
 {

  IfLess,Open, 1
   {
    Gui, destroy
    Goto, Start2
   }
 }

Return

~MButton::

MouseGetPos, mX, mY
Gui, Show, X%mX% Y%mY% AutoSize, Launcher


MyListView:
if A_GuiEvent = doubleclick
{
    LV_GetText(RowText, A_EventInfo)
    SetTitleMatchMode, 2
    SetTitleMatchMode, Slow
    IfWinExist, %RowText%
    {
      WinActivate, %RowText%
     IfLess, Open, 1
     {
       Gui, Destroy
      Goto, Start2
     }
    }
    Run, %A_MyDocuments%\Launcher\%RowText%
    IfLess, Open, 1
    {
     Gui, destroy
     Goto, Start2
    }
}

return

ButtonEdit:
GuiControl, , Stay Open, 1
Run, %A_MyDocuments%\Launcher
return

ButtonUpdate:
IfEqual, open, 1
c = 1
a = 1
Gui, Destroy
GoTo, Start2
return


Report this post
Top
  
Reply with quote  
 Post subject: new version
PostPosted: May 18th, 2009, 9:05 pm 
I got rid of most of the controls and was able to make everything automated except the possible drag and drop into the window itself
the edit button instead opens a directory to where the ".lnk" files which make up the launcher list are stored. The screen shot above is updated to show the new version/



Code:




#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

;#NoTrayIcon





Start2:

Gui, Add, ListView , Grid 0x800000 -Hdr r15 w90 gMyListView, Programs

Gui, Add, Button,, %A_Space%%A_Space%Edit%A_Space%%A_Space%

Gui, -SysMenu


Gui, +ToolWindow
Open = 0


Loop, %A_MyDocuments%\Launcher\*.lnk
{

StringTrimRight, Loop, A_LoopFileName, 4

LV_Add( "", Loop )

LV_ModifyCol(-1)
}
IfEqual, a, 1
 {
 Gui, Show, X%mX% Y%mY% AutoSize, %A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%Launcher
 IfEqual, c, 1
  {
  Open = 1
  }
 a = 0
 c = 0
 }
return



~LButton::

Gui, Submit, NoHide
SetTitleMatchMode, 2
SetTitleMatchMode, Slow
IfWinNotActive, %A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%Launcher
 {

  IfLess,Open, 1
   {
    Gui, destroy
    Goto, Start2
   }
 }

Return

~MButton::

MouseGetPos, mX, mY
Gui, Show, X%mX% Y%mY% AutoSize, %A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%Launcher


MyListView:
if A_GuiEvent = DoubleClick
{
    LV_GetText(RowText, A_EventInfo)
    SetTitleMatchMode, 2
    SetTitleMatchMode, Slow
    IfWinExist, %RowText%
    {
      WinActivate, %RowText%
     IfLess, Open, 1
     {
       Gui, Destroy
      Goto, Start2
     }
    }
    else
    {
    Run, %A_MyDocuments%\Launcher\%RowText%
    }
    IfLess, Open, 1
    {
     Gui, destroy
     Goto, Start2
    }
}

return

ButtonEdit:

Run, %A_MyDocuments%\Launcher
Process, Wait, 0000, 0.1
SetTitleMatchMode, 2
 
 WinGet, we, ID, %A_MyDocuments%\Launcher

While, we
 {
 
 Open = 1
 WinGet, we, ID, %A_MyDocuments%\Launcher

 }
    Open = 0
    a = 1
    Gui, Destroy
    GoTo, Start2
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 19th, 2009, 6:30 pm 
Offline

Joined: February 23rd, 2009, 12:14 pm
Posts: 31
Location: Netherlands
Hi ExitSymbol,

The interface looks good and I would like the app much. However, either clicking the Edit button or doubleclicking an empty row results in an error, over here... :?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: ahh never noticed that
PostPosted: May 19th, 2009, 7:13 pm 
I am not having any problems with the edit button but double clicking an empty row does cause a problem, however, that part is easy to fix.
When attempting to click the edit button did you use the latest version of the code?


Report this post
Top
  
Reply with quote  
 Post subject: fixed part of it
PostPosted: May 19th, 2009, 7:53 pm 
This code got rid of the error message I was getting when double click an empty list entry, but I would like to know more about this edit button entry

Code:




#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

#NoTrayIcon





Start2:

Gui, Add, ListView , Grid 0x800000 -Hdr r15 w90 gMyListView, 0

Gui, Add, Button,, %A_Space%%A_Space%Edit%A_Space%%A_Space%

Gui, -SysMenu


Gui, +ToolWindow
Open = 0


Loop, %A_MyDocuments%\Launcher\*.lnk
{

StringTrimRight, Loop, A_LoopFileName, 4

LV_Add( "", Loop )

LV_ModifyCol(-1)
}
IfEqual, a, 1
 {
 Gui, Show, X%mX% Y%mY% AutoSize, %A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%Launcher
 IfEqual, c, 1
  {
  Open = 1
  }
 a = 0
 c = 0
 }
 
return



~LButton::

Gui, Submit, NoHide
SetTitleMatchMode, 2
SetTitleMatchMode, Slow
IfWinNotActive, %A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%Launcher
 {

  IfLess,Open, 1
   {
    Gui, destroy
    Goto, Start2
   }
 }

Return

~MButton::

MouseGetPos, mX, mY
Gui, Show, X%mX% Y%mY% AutoSize, %A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%Launcher


MyListView:

if A_GuiEvent = DoubleClick
   
    {

   
    LV_GetText(RowText, A_EventInfo)
   
    IfLess, 0, RowText
     {
      SetTitleMatchMode, 2
      IfWinExist, %RowText%
       {
        WinActivate, %RowText%
       
        }
    Else,
     {
      IfEqual, RowText, 0
       {
         Open = 1
         Goto, Start2
       }
        Else,
         {
         
          Run, %A_MyDocuments%\Launcher\%RowText%
         }
       
        }
       IfLess, Open, 1
       {
     Gui, destroy
     Goto, Start2
       }

      }
}
return

ButtonEdit:

Run, %A_MyDocuments%\Launcher
Process, Wait, 0000, 0.1
SetTitleMatchMode, 2
 
 WinGet, we, ID, %A_MyDocuments%\Launcher

While, we
 {
 
 Open = 1
 WinGet, we, ID, %A_MyDocuments%\Launcher

 }
    Open = 0
    a = 1
    Gui, Destroy
    GoTo, Start2
Return


Report this post
Top
  
Reply with quote  
PostPosted: May 19th, 2009, 8:41 pm 
You would get an edit button error of the folder "My Documents\Launcher" does not exist, if you download the installer I made from
Http://www.digitaloutsider.com/Launcher.html it will create this directory and install Launcher1.2 to run automatically at startup. With this installer Launcher1.2 begins running right as the install is finished.


Report this post
Top
  
Reply with quote  
PostPosted: May 20th, 2009, 2:20 pm 
Code:




#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

#NoTrayIcon





Start2:

Gui, Add, ListView , Grid 0x800000 -Hdr r15 w90 gMyListView, programs

Gui, Add, Button,, %A_Space%%A_Space%Edit%A_Space%%A_Space%

Gui, -SysMenu

Gui, +ToolWindow
Open = 0


Loop, %A_MyDocuments%\Launcher\*.lnk
{

StringTrimRight, Loop, A_LoopFileName, 4

LV_Add( "", Loop )

LV_ModifyCol(-1)
}
IfEqual, a, 1
 {
 Gui, Show, X%mX% Y%mY% AutoSize, %A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%Launcher
 IfEqual, c, 1
  {
  Open = 1
  }
 a = 0
 c = 0
 }
 
return



~LButton::

Gui, Submit, NoHide
SetTitleMatchMode, 2
SetTitleMatchMode, Slow
IfWinNotActive, %A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%Launcher
 {

  IfLess,Open, 1
   {
    Gui, destroy
    Goto, Start2
   }
 }

Return

~MButton::

MouseGetPos, mX, mY
Gui, Show, X%mX% Y%mY% AutoSize, %A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%Launcher


MyListView:

if A_GuiEvent = DoubleClick
   
    {

   
   
    IfGreater, A_EventInfo, 0
     {
     
      LV_GetText(RowText, A_EventInfo)
       
      SetTitleMatchMode, 2

       IfWinExist, %RowText%
       {
        WinActivate, %RowText%
       
        }
         IfWinNotExist, %RowText%
          {
            Run, %A_MyDocuments%\Launcher\%RowText%
           }}
           Open = 1
           a = 1
           Gui, Destroy
           Goto, Start2
          }       

return

ButtonEdit:

Run, %A_MyDocuments%\Launcher
Process, Wait, 0000, 0.1
SetTitleMatchMode, 2
 
 WinGet, we, ID, %A_MyDocuments%\Launcher

While, we
 {
 
 Open = 1
 WinGet, we, ID, %A_MyDocuments%\Launcher

 }
    Open = 0
    a = 1
    Gui, Destroy
    GoTo, Start2
Return


Report this post
Top
  
Reply with quote  
 Post subject: getting better
PostPosted: May 20th, 2009, 7:21 pm 
As far as I can tell this is the best code I will be able to make, it won't work right though unless you use the installer on my website to install the program and the necessary stuff that goes along with it




Code:
; <COMPILER: v1.0.48.3>
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

#NoTrayIcon

Start2:

Gui, Add, ListView , Grid 0x800000 -Hdr r15 w90 gMyListView, programs

Gui, Add, Button,, %A_Space%%A_Space%Edit%A_Space%%A_Space%

Gui, -SysMenu

Gui, +ToolWindow
Open = 0


Loop, %A_MyDocuments%\Launcher\*.lnk
{

StringTrimRight, Loop, A_LoopFileName, 4

LV_Add( "", Loop )

LV_ModifyCol(-1)
}
IfEqual, a, 1
 {
 Gui, Show, X%mX% Y%mY% AutoSize, %A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%Launcher
 IfEqual, c, 1
  {
  Open = 1
  }
 a = 0
 c = 0
 }

return


~LButton::

Gui, Submit, NoHide
SetTitleMatchMode, 2
SetTitleMatchMode, Slow
IfWinNotActive, Launcher
 {

  IfLess,Open, 1
   {
    Gui, destroy
    Goto, Start2
   }
 }

Return



~MButton::
SoundPlay, click.wav
MouseGetPos, mX, mY
Gui, Show, X%mX% Y%mY% AutoSize, %A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%Launcher







MyListView:


if A_GuiEvent = DoubleClick

    {

    i = %A_EventInfo%
    IfGreater, i, 0
     {
     
      LV_GetText(RowText, i)
     
      SetTitleMatchMode, 2

       IfWinExist, %RowText%
       {
        IfEqual, Open, 1
        {
        a = 1
        }
        Else,
           {
             C = 0
             a = 0
            }
        SoundPlay, click.wav
        WinActivate, %RowText%
         Gui, Destroy
         Goto, Start2
        }
         IfWinNotExist, %RowText%
          {
           SoundPlay, click.wav
           Run, %A_MyDocuments%\Launcher\%RowText%
           IfEqual, Open, 1
           a = 1
           Gui, Destroy
           Goto, Start2
           }
           IfEqual, Open, 1
           c = 1
           a = 1
           Gui, Destroy
           Goto, Start2
          }
      }

Return


ButtonEdit:
SoundPlay, click.wav
Run, %A_MyDocuments%\Launcher

SetTitleMatchMode, 2
WinWait, %A_MyDocuments%\Launcher
 WinGet, we, ID, %A_MyDocuments%\Launcher

While, we
 {

 Open = 1
 WinGet, we, ID, %A_MyDocuments%\Launcher

 }
    Open = 0
    a = 1
    Gui, Destroy
    GoTo, Start2
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2009, 8:01 pm 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
Why can't you just create the folder if it doesn't exist with FileCreateDir?

I think I speak for alot of people here when I say it would be preferable not to have to use a separate installer, especially when it's an exe.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2009, 12:06 am 
Well I posted the source code, you can add that yourself if you want to... otherwise use my installer


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2009, 1:22 am 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
Or you could, like just create the directory yourself. Why someone would want need an executable to do something so simple is beyond me, but hey, to each their own.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: well
PostPosted: May 21st, 2009, 3:33 pm 
The installer I made puts files in the right place, creates directory structure for the program itself, and makes an uninstaller that removes all of that data when the user no longer desires the program.


Report this post
Top
  
Reply with quote  
PostPosted: May 21st, 2009, 5:11 pm 
This code doesn't exactly do anything different than before but it looks nicer and flows a little more clearly, my being an artist means that I am all about the aesthetics of everything I do and so I spent all morning making the code better looking and functioning

Code:
; <COMPILER: v1.0.48.3>



#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

#NoTrayIcon


Start2:

Gui, Add, ListView , Grid 0x800000 -Hdr r15 w90 gMyListView, programs

Gui, Add, Button,, %A_Space%%A_Space%Edit%A_Space%%A_Space%

Gui, -SysMenu

Gui, +ToolWindow
Open = 0


Loop, %A_MyDocuments%\Launcher\*.lnk
{

StringTrimRight, Loop, A_LoopFileName, 4

LV_Add( "", Loop )

LV_ModifyCol(-1)
}
IfEqual, a, 1
 {
 Goto, Show

 }

return


~LButton::

Gui, Submit, NoHide
SetTitleMatchMode, 2
SetTitleMatchMode, Slow
IfWinNotActive, Launcher
 {

  IfLess,Open, 1
   {
    Gui, destroy
    Goto, Start2
   }
 }

Return


~MButton::
MouseGetPos, mX, mY
Show:
 IfEqual, c, 1
  {
  Open = 1
  }
 a = 0
 c = 0
SoundPlay, click.wav
AutoTrim, off
lau = Launcher
Loop, 9
{
lau = %A_Space%%lau%
}
Gui, Show, X%mX% Y%mY%, %lau%
Return



~RButton::

Gui, Submit, NoHide
SetTitleMatchMode, 2
SetTitleMatchMode, Slow
IfWinNotActive, Launcher
 {

  IfLess,Open, 1
   {
    Gui, destroy
    Goto, Start2
   }
 }

Return



MyListView:


if A_GuiEvent = DoubleClick

    {

    i = %A_EventInfo%
    IfGreater, i, 0
     {

      LV_GetText(RowText, i)

      SetTitleMatchMode, 2

       IfWinExist, %RowText%
       {
        IfEqual, Open, 1
        {
        a = 1
        }
        Else,
           {
             C = 0
             a = 0
            }
        SoundPlay, click.wav
        WinActivate, %RowText%
         Gui, Destroy
         Goto, Start2
        }
         IfWinNotExist, %RowText%
          {
           SoundPlay, click.wav
           Run, %A_MyDocuments%\Launcher\%RowText%
           IfEqual, Open, 1
           a = 1
           Gui, Destroy
           Goto, Start2
           }
           IfEqual, Open, 1
           c = 1
           a = 1
           Gui, Destroy
           Goto, Start2
          }
      }

Return


ButtonEdit:
SoundPlay, click.wav
Run, %A_MyDocuments%\Launcher

SetTitleMatchMode, 2
WinWait, %A_MyDocuments%\Launcher
 WinGet, we, ID, %A_MyDocuments%\Launcher

While, we
 {

 Open = 1
 WinGet, we, ID, %A_MyDocuments%\Launcher

 }
    Open = 0
    a = 1
    Gui, Destroy
    GoTo, Start2
Return


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: infogulch, notsoobvious, tomoe_uehara, Xx7 and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group