AutoHotkey Community

It is currently May 26th, 2012, 10:14 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: AHKOpener
PostPosted: June 23rd, 2008, 10:43 pm 
Offline

Joined: May 25th, 2007, 6:13 pm
Posts: 373
This is just something I whipped up for the h3!! of it and thought I'd share it.

Code:
/*
 A simple little tool to run whichever AHK-made program I'm working on.
   "cx" will save the clipboard info to it's ini {AHKFile.ini}.
      In PSPad, if you right-click on a tab, at the bottom of the context
      menu it has "Copy Filename to Clipboard".
   "qr" will Run the file. If your program depends on files within it's
      directory, be sure to add "a_ScriptDir" to the file/path name as
      AHKOpener will cause your file to think it's opened from a different
      path.
 I made this specifically for checking my AHK-made programs instead of
   constantly saving, compiling, then going to the file and double-clicking it.
*/
/*
 Working Name:   AHKOpener.ahk
 Created By:     Matthew "Dra'Gon" Stohler
 Begun:          18Jun08
 Completed:      23Jun08
 Email:          mattstohler@yahoo.com
 ScreenName:     Dra_Gon
 Use it however you wish and enjoy!
 -> With thanks to "IconBoy" for asking the question
       which gave me this idea.
 -------------------------------------
*/
#SingleInstance ignore
#Persistent

Menu, tray, NoStandard
Menu, tray, add, Exit, GuiClose
Menu, tray, Default, Exit

IFile := A_WorkingDir "\AHKFile.ini"

:?*:cx::
  Gosub AHKCompile
Return

:?*:qr::
  IniRead, opnFile, %IFile%, Filer, ToOpen
  IfInString, opnFile, .exe
    {
      IfExist, %opnFile%
        Run, %opnFile%
      Else
        StopMsg("That file don't exist nohow!")
    }
  Else
    StopMsg("You ain't got no file there!")
return

GuiClose:
  noData =
  IniWrite, %noData%, %IFile%, Filer, ToOpen
  ExitApp
Return

AHKCompile:
  IniRead, cmpDir, %IFile%, Filer, CompDir

  IfNotExist, %cmpDir%\ahk2exe.exe
    {
      FileSelectFolder, cmpDir, *%A_WorkingDir%, 3, Compiler Directory?
      IniWrite, %cmpDir%, %IFile%, Filer, CompDir
    }

  IfInString, ClipBoard, .ahk
    {
      StringReplace, Runner, ClipBoard, .ahk, .exe
      Run, %cmpDir%\Ahk2Exe.exe /in "%ClipBoard%"
      IniWrite, "%Runner%", %IFile%, Filer, ToOpen
      MsgBox, 48, Done!, /in %ClipBoard% `n/out %Runner%
    }
  Else
    StopMsg("You ain't got no AHK File in that there clipboard!")

Return

StopMsg(nowMsg)
{
  MsgBox, 48, Whoa!, %nowMSG%`nTry again, programmer!
}


It's quick and dirty, you can't set the icon or a password with this. I just made it for when I test a script I'm working on. Once it's done, I can do all the good stuff for final compilation. Also, it's not perfect {duh}, so if anyone has suggestions to make it better, I'll be happy to hear 'em.

Ciao,
Dra'Gon
[/code]

_________________
Image
For a good laugh {hopefully} >> megamatts.50megs.com

My WritersCafe profile>>
http://www.writerscafe.org/writers/BlueDragonFire/


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 24th, 2008, 1:04 am 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
Hehe, I appreciate the southern dialect :)

_________________
Religion is false. >_>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 24th, 2008, 4:06 pm 
Offline

Joined: May 25th, 2007, 6:13 pm
Posts: 373
I thought that might amuse someone. I like it because it doesn't seem so drab. :wink:

Ciao,
Dra'Gon

_________________
Image
For a good laugh {hopefully} >> megamatts.50megs.com

My WritersCafe profile>>
http://www.writerscafe.org/writers/BlueDragonFire/


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2008, 9:59 pm 
Offline

Joined: May 25th, 2007, 6:13 pm
Posts: 373
I just did a little revamping of this and figured I'd put it in again.

In this one:
Hovering over the tray icon will show the hotkeys used. If you decide to change those hotkeys in the script, make sure you change the "TrayTip" and "Menu, Tray, Tip," {both at the top}.
Also, I've put in a little GUI to add an icon {I keep the ones I regularly use for scripts in an AHK folder}.
The ini holds the Compiler Directory, Icon Directory and Icon Used until they are changed. The script being done is only held until you close AHKOpener.
If you use this on different computers {via flash drive, as I do} the root directory for the compiler & icon directories will change automatically to the letter of your flash drive.
I got the Splash image going for 10 seconds {sleep, 10000} just so I don't try to run it before it's finished compiling. You can change/delete the sleep to suit yourself {like you need MY permission to do that, lol}.

I think that's about it, so I'll just post the script/ini now.

Code:
/*
 A simple little tool to run whichever AHK-made program I'm working on.
   WindowsKey + "a" will compile the script.
   WindowsKey + "i" to select the icon.
   WindowsKey + "r" will Run the EXE file.
 I made this specifically for checking my AHK-made programs instead of
   constantly saving, compiling, then going to the file and double-clicking it.

 Working Name:   AHKOpener.ahk
 Created By:     Matthew "Dra'Gon" Stohler
 Begun:          18Jun08
 Completed:       22Oct08 {more or less just "adjusting" it}
 Email:          mattstohler@yahoo.com
 ScreenName:     Dra_Gon
 Use it however you wish and enjoy!
 -> With thanks to "IconBoy" for asking the question
       which gave me this idea.
 -------------------------------------
*/
#SingleInstance ignore
#Persistent
SetTitleMatchMode, 2

Menu, Tray, NoStandard
Menu, Tray, Add, Exit, ByeBye
Menu, Tray, Default, Exit
Menu, Tray, Tip, Win+A = Compile Script`nWin+I = Change Icon`nWin+R = Run EXE'd Script, 5, 17

TrayTip, HotKeys:, Win+A = Compile Script`nWin+I = Change Icon`nWin+R = Run EXE'd Script, 5, 17

IFile := A_ScriptDir "\AHKFile.ini"

IniRead, cmpDir, %IFile%, Filer, CompDir
IniRead, icnDir, %IFile%, Filer, IconDir
IniRead, useIcon, %IFile%, Filer, IconUsed

SplitPath, A_ScriptDir,,,,, tmpDrvS
SplitPath, cmpDir,,,,, tmpDrvC

If tmpDrvS <> %tmpDrvC%
  {
    StringReplace, cmpDir, cmpDir, %tmpDrvC%, %tmpDrvS%
    StringReplace, icnDir, icnDir, %tmpDrvC%, %tmpDrvS%
    IniWrite, %cmpDir%, %IFile%, Filer, CompDir
    IniWrite, %icnDir%, %IFile%, Filer, CompIcons
  }

#a::Gosub AHKCompile

#i::Gosub GetIcon

#r::
  IniRead, opnFile, %IFile%, Filer, ToOpen
  IfInString, opnFile, .exe
    {
      IfExist, %opnFile%
        Run, %opnFile%
      Else
        StopMsg("That file don't exist nohow!")
    }
  Else
    StopMsg("You ain't got no EXE file there!")

return

ByeBye:
  noData =
  IniWrite, %noData%, %IFile%, Filer, ToOpen
  ExitApp

Return

AHKCompile:
  IfNotExist, %cmpDir%\ahk2exe.exe
    {
      FileSelectFolder, cmpDir, *%A_WorkingDir%, 3, Compiler Directory?
      IniWrite, %cmpDir%, %IFile%, Filer, CompDir
    }

  IfNotExist, %icnDir%
    {
      FileSelectFolder, icnDir, *%A_WorkingDir%, 3, Icon Directory?
      IniWrite, %icnDir%, %IFile%, Filer, CompIcons
    }

  IfWinActive, PSPad
    {
      WinGetActiveTitle, ahk2Compile

      StringReplace, ahk2Compile, ahk2Compile, PSPad - [
      StringReplace, ahk2Compile, ahk2Compile, ]
      StringReplace, ahk2Compile, ahk2Compile, `*
      StringReplace, Runner, ahk2Compile, .ahk, .exe

      SplitPath, ahk2Compile, ahkFile
      SplashImage,, B2, Compiling:`n%ahkFile%,,, Copperplate Gothic Light

      SendEvent {Ctrl Down}{s}{Ctrl Up}
      Run, %cmpDir%\Ahk2Exe.exe /in "%ahk2Compile%" /icon "%icnDir%\%useIcon%"
      IniWrite, "%Runner%", %IFile%, Filer, ToOpen

      Sleep, 10000
      SplashImage, Off
    }
  Else
    StopMsg("You ain't got PSPad up 'n front, Neighbor!")

Return

GetIcon:
Gui, Add, Text, x5 y5, Double-Click Icon for Compiling script:
Gui, Add, ListView, x5 y+10 IconSmall vlvwIcons gUseIcon

Gui, Show, Center AutoSize, Get Icon(Current-%useIcon%)

Loop, %icnDir%\*.ico
  LV_Add("",A_LoopFileName)

Return

GuiClose:
  Gui, Destroy
Return

UseIcon:
if A_GuiEvent = DoubleClick
{
    LV_GetText(RowText, A_EventInfo)

    useIcon := RowText
    IniWrite, %RowText%, %IFile%, Filer, IconUsed

    Gui, Destroy
}

Return

StopMsg(nowMsg)
{
  MsgBox, 48, Whoa!, %nowMSG%`nTry again, programmer!
}


Code:
[Filer]
CompDir=D:\123\Program Files\AutoHotKey\Compiler
IconDir=D:\123\Program Files\AutoHotKey\Scripts\Icons
IconUsed=star.ico
ToOpen=


Enjoy!

Ciao,
Dra'Gon

_________________
Image
For a good laugh {hopefully} >> megamatts.50megs.com

My WritersCafe profile>>
http://www.writerscafe.org/writers/BlueDragonFire/


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: xXDarknessXx and 10 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