Sunday, November 27, 2016

Task Lister - Portable Task Manager V1.1 - Update

Task Lister V1.1 - Update

Read update notes below.

Task Lister is a portable task manager that can be used as an alternative to the native Windows Task Manager. It is great for flash drives or disk to use on computers that have viruses that have disabled the task manager or it can be used as a lightweight alternative to your normal Task Manager. Though not full-featured, it can do the basic things that need to be done when hunting down viruses or whatever processes you might want to handle or find.

With Task Lister you can:

  • Kill any process
  • Open a processes folder location in explorer
  • Restart Windows Explorer
  • Run any file

HotKeys:

  • Alt+K - Kill the higlighted process
  • Alt+O - Open the higlighted processes folder location in explorer, if possible
  • Alt+R - Restart Windows Explorer
  • Alt+U - Run any file

Upadte Notes:

  • V1 - Intial release.
  • V1.1 - Fixes
    • Task list now only updates when there is no user input.
    • Smoother menu and task list navigation.
    • Runs at a higher priorty.
    • Added a fade transition when the gui minimizes or exits. Only seems to work in Windows 10.

Screenshots

Downloads

Script - Initial

; List all tasks in a Gui with a ComboBox

; Init
if not A_IsAdmin
{
    Run *RunAs "%A_ScriptFullPath%"
    ExitApp
}
#NoEnv
#SingleInstance, Force
SendMode Input
SetWorkingDir %A_ScriptDir%
OnMessage(0x200,"WM_MOUSEHOVER")
OnMessage(0x18,"WM_SHOWWINDOW")
OnMessage(0x2a3,"WM_MOUSELEAVE")
OnMessage(0x201,"WM_LBUTTONDOWN")
CoordMode, ToolTip, Client

; Vars
defaultWidth:=240
x:="explorer.exe"

; Build menus, intial loops and guis here
Menu, MainMenu, Add, &Run,FileOpen, +Break
Menu, MainMenu, Add, Restart &Explorer,RestartExplorer
Menu, MainMenu, Add, E&xit,GuiClose
Menu, HelpMenu, Add, &Help,Help, +Break
Menu, HelpMenu, Add, &About,About
Menu, MyMenuBar, Add, &File, :MainMenu
Menu, MyMenuBar, Add, &Help, :HelpMenu

Menu, Tray, NoStandard
Menu, Tray, Tip, % Spaces("Tab") Spaces("Tab") "Task Lister`nRight click for menu"
Menu, Tray, Add, &Run, FileOpen
Menu, Tray, Add, &Help, Help
Menu, Tray, Add, Restart &Explorer,RestartExplorer
Menu, Tray, Add, &About Task Lister, About
Menu, Tray, Add
Menu, Tray, Add, E&xit,GuiClose

tl:=TaskList(,,1)
Gui, Margin, 1, 1
Gui, Color,0xFEFEFA 0xFFFFFF
Gui, Font, s15 w500, Segoe UI
Gui, Add,Progress,Section  w%defaultWidth% Background0x0D4F82 c0x0078D7, 100
Gui, Add, Text, w%defaultWidth% +BackgroundTrans 0x200 +Center c0xFEFEFA yp, Task Lister
MinButton(200,20,"FEFEFA","FEFEFA",True)
CloseButton(220,8,"FEFEFA","FEFEFA",True)
Gui, Font, s8 w100 c0xFEFEFA, Segoe UI
Gui, Add, Progress, Background0x0D4F82 w%defaultWidth% h20 xs c0x0078D7, 100
MenuItem("&File",28,,1)
MenuItem("&About")

Gui, Font, s9 w400
Gui, Add, ComboBox, xs  Choose1 vChoice w%defaultWidth% 0x1 h250 +ReadOnly, % tl
Button("0x0D4F82","0x0078D7",defaultWidth,"&Kill Selected Task","Task Lister","FEFEFA",13)
Button("0x0D4F82","0x0078D7",defaultWidth,"&Open Process Location`n(If possible)","Task Lister","FEFEFA",13)
Button("0x0D4F82","0x0078D7",defaultWidth,"&Restart Explorer","Task Lister","FEFEFA",13)
Button("0x0D4F82","0x0078D7",defaultWidth,"R&un File","Task Lister","FEFEFA",13)
Gui, Show, , Task Lister
WinSet, TransColor, 0x123456 , Task Lister
Gui, -Caption +Border
Gui, Show, AutoSize, Task Lister
Gui, +LastFound +HwndMainHwnd
this_id:=WinExist()
ControlSend, ComboBox1,{Right}, ahk_id %this_id%
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(MainHwnd,tme,8)
DllCall( "TrackMouseEvent","uint",&tme )
SetTimer,RefreshList, 150
; End auto execute
Return

; Hotkeys
#IfWinActive, Task Lister
Alt & r::Gosub, RestartExplorer
Alt & o::Gosub, Open
Alt & k::Gosub, ButtonKillSelectedTask
Alt & u::Gosub, FileOpen
Alt & f::
 CoordMode, Mouse, Client
 MouseMove,%S2X%,%S2Y2%
 Menu, MainMenu, Show
 CoordMode, Mouse, Screen
Return
Alt & a::
 CoordMode, Mouse, Client
 MouseMove,%S2X%,%S2Y2%
 Menu, HelpMenu, Show
 CoordMode, Mouse ,Screen
Return
;$Down::Send, {Down}{Home}
#IfWinActive
; Functions
#Include, TLLib.ahk
#Include, ProcessInfo.ahk

; Classes


; Subs
RestartExplorer:
 If ProcExist(x)
  {
   Sleep, 150
   While, % ProcExist(x)
    {
     Process, Close, %  x
     Sleep, 1
    }
   WinWait, ahk_exe %x%,,10
   If ErrorLevel
    {
     MsgBox,20,Restart Explorer Error, % "Explorer.exe could not be started.`n`n"
                . "Trying opening manually?"
     IfMsgBox, Yes
      Gosub, FileOpen
     Return
    }
  }
 Else
  Run, % x
 SetTimer, CheckX, -4000
Return
CheckX:
 WinActivate, ahk_id %this_id%
 If ProcExist(x)
  TrayTip, Task Lister Info, Explorer.exe was restarted successfully.
Return
Open:
 Gui, Submit, NoHide
 DetectHiddenWindows, On
 WinGet,expid,PID, ahk_exe %Choice%
 this_path:=GetModuleFileNameEx(expid)
 SplitPath,this_path, ,ndir
 If ndir
  Run % ndir
 Else
  MsgBox,64,Task Lister Info,% "Can not get path from executable."
 DetectHiddenWindows, Off
Return
ButtonKillSelectedTask:
 Gui, Submit, NoHide
 Process, Close, % Choice
 WinWaitNotActive, ahk_class ConsoleWindowClass
 Gui, Flash
 Gosub, RefreshList
Return
RefreshList:
 IfWinActive, % "ahk_id " this_id
  {
   exe:=""
   Gui, Submit, NoHide
   Loop, Parse, % TaskList(,,1), |
    {
     exe:=(A_LoopField == Choice)?1:0
     If exe
      Break
    }
   If (!Choice || !exe)
    {
     ControlFocus,ComboBox1, ahk_id %this_id%
     ControlSend, ComboBox1,{Down}, ahk_id %this_id%
    }
   If (tl != TaskList(,,1))
    {
     IfWinActive, ahk_id %this_id%
      {
       WinActivate, ahk_id %this_id%
       GuiControl,,ComboBox1, % "|" TaskList(,,1)
       Gui, Flash
       SetTimer, TT_FADE_IN, -1
      }
     proc:=""
     proc:=TaskList(,1)
     tl:=TaskList(,,1)
    }
   ControlGetFocus,focus, ahk_id %this_id%
   If (focus != "Edit1")
    ControlSend, ComboBox1,{Right}, ahk_id %this_id%
  }
Return
TT_FADE_IN:
 ToolTip % "TaskList updated"
 ttx:=window._x("ahk_id " this_id)+(E1X-2)
 tty:=window._y("ahk_id " this_id)+(E1Y-2)
 WinMove, ahk_class tooltips_class32, ,%ttx% ,%tty%
 If TT_FADE("in",32)
  SetTimer,TT_FADE_OUT_FAST,-800
Return
TT_FADE_OUT_FAST:
 TT_FADE("out",16)
Return
TT_FADE_OUT_SLOW:
 TT_FADE("out",2)
Return
FileOpen:
 FileSelectFile,file,3, % A_WinDir "\System32"
 If file
  {
   Run, % file
   Gui, Flash
   file:=""
  }
Return
Help:
 MsgBox,68,Task Lister Help, % Spaces("Tab") "Task Lister is a simple program to view or kill`n"
          .      "Windows processes. In this portable program some`n"
          .      "process locations can not be opened in explorer,`n"
          .      "but others can.`n`n"
          .      "Hotkeys" A_Tab "Function`n"
          .      "-------" A_Tab "--------`n"
          .      "Alt+K" A_Tab "Kill selected process.`n"
          .      "Alt+O" A_Tab "Open selected processes folder location.`n`"
          .      "Alt+R" A_Tab "Restart Windows Explorer.`n"
          .      "Alt+U" A_Tab "Run a file.`n`n"
          .      "Email me with questions or suggestions?"
 IfMsgBox, Yes
  Gosub, Email
Return
About: 
 MsgBox,64,Task Lister Info, % Spaces("Tab") "Task Lister is a portable task manager for the Windows `n"
          .      "OS. It can be put on a disk or flash drive to use on systems `n"
          .      "that have been infected by viruses and the default Task `n"
          .      "Manager has been disabled.`n`n"
          . Spaces("Tab") "This is not a full-featured task manager, but feel free to`n"
          .      "use as a light-weight replacement for your task manager on`n"
          .      "your own system.`n`n"
          .      "Written in AutoHotkey by Ian Pride @ New Pride Services 2016"
Return
Email:
 Run, mailto:faithnomoread@yahoo.com
Return
KillTT:
 counters2=255
 Loop
  {
   If (counters2 <= -1)
    Break
   Sleep, 1
   SetTrans("ahk_class tooltips_class32",counters2)
   counters2-=16
  }
 ToolTip
Return
GuiClose:
 ExitApp

Friday, November 18, 2016

Auto-Hide Desktop

Auto-Hide Desktop

There is a basic feature in Windows 7 and 10 (though there are more options for tablets in 10) that allows the user to automatically hide the taskbar until you hover at the bottom. This is okay for some, but I have always wanted my desktop to behave differently and so I have written a new program that does exactly what I want.

Auto-Hide Desktop! will automatically hide the task bar and all desktop icons when no physical input has been received by a user after a user defined amount of time. Unlike the normal behavior you do not have to hover at the taskbar region, all you have to do is touch the mouse or keyboard and everything will automatically reappear for you as long as you have input.

Usage

This runs and has been tested in Windows 7 64 bit and Windows 10 32 bit tablet, but though it won't cause any issues you might not like the result mixed with the systems Windows 10 tablet mode. Though you may. ShowDesk.exe is a child process of the main program and ensures that if for some unknown reason the main program fails while all is hidden then it will show everything upon failure. I have tested on tons of force closes and works everytime. If all else fails just reboot your system.

The only gui is the settings which can be found in the system tray icon by right clicking on it and selecting 'Settings'. In settings you can set the idle delay and also choose to auto-run the program at Windows startup or not. Default idle delay is 3 seconds, but can be set up to 9999 seconds (lol) and, of course, auto-run is disabled by default.

Images & Screens

Downloads

Script - main function library

RR(path,name){
 RegRead,a,% path, % name
 Return a
}
Settings(){
 Global delay,runState
 Gui, Settings:New
 Gui, Settings: Color, 0xFFFFFF, 0xFEFEFA
 Gui, Settings:Font,s11,Segoe UI
 Gui, Settings:Add, Text,Section h24 0x200 w300,Delay before hiding the desktop in seconds: 
 Gui, Settings:Add, Edit, w65 x+8
 Gui, Settings:Add, UpDown, vdelay Range3-9999 0x80 gDelayChange, %delay%
 Gui, Settings:Add, Text, h24 0x200 xs w300,Run at Windows start up: 
 Gui, Settings:Add, Checkbox, x+8 vrunState gRunState Checked%runState%
 Gui, Settings:Show, AutoSize, Auto-Hide Desktop Settings
 ControlSend, Edit1, {End},Auto-Hide Desktop Settings
}
ShowDesk(){
 DetectHiddenWindows, on
    id:=WinExist("ahk_class Shell_TrayWnd")
    ControlGet,id2,Hwnd,,SysListView321,ahk_class Progman
    If !id2
        ControlGet,id2,Hwnd,,SysListView321,ahk_class WorkerW
 ControlGet,id3,Hwnd,,,ahk_class Button
 If !IsVisible(id)
  WinShow, ahk_id %id%
 If !IsVisible(id2)
  WinShow, ahk_id %id2%
 If !IsVisible(id3)
  WinShow, ahk_id %id3%
}
ToggleDeskIcons(idle_time){
 DetectHiddenWindows, On
    ControlGet,id,Hwnd,,SysListView321,ahk_class Progman
    If !id
        ControlGet,id,Hwnd,,SysListView321,ahk_class WorkerW
 If (A_TimeIdlePhysical >= idle_time)
  {
   If IsVisible(id)
    WinHide, ahk_id %id%
   Return "Desktop icons are hidden." 
  }
    Else
        {
   If !IsVisible(id)
    WinShow, ahk_id %id%
   Return
        }
}
ToggleTaskbar(idle_time){
 DetectHiddenWindows, on
    id:=WinExist("ahk_class Shell_TrayWnd")
 ControlGet,id2,Hwnd,,,ahk_class Button
 If (A_TimeIdlePhysical >= idle_time)
  {
   If IsVisible(id)
    WinHide, ahk_id %id%
   If IsVisible(id2)
    WinHide, ahk_id %id2%
   Return "Taskbar is hidden." 
  }
    Else
        {
   If !IsVisible(id)
    WinShow, ahk_id %id%
   If !IsVisible(id2)
    WinShow, ahk_id %id2% 
   Return
        }
}
IsVisible(id){
 Return DllCall("IsWindowVisible","UInt",id)
}

Sunday, November 13, 2016

BlueStacks Quick App Launcher

BlueStacks Quick App Launcher

For those that aren't familiar with BlueStacks (BS) it is an Android emulator for the Windows OS. BS allows you to use Android apps on your Windows computer allowing you to free up your mobile devices and also allows developers to test and create their applications while at their computers.

There are many things that can be done with BS and different ways it can be used and one feature I like is being able to run user installed apps from shortcuts in a folder. This makes it possible to run specific apps without starting BS first.

To make running apps even quicker I have created:

BlueStacks Quick App Launcher!

Usage

BlueStacks Quick App Launcher quickly lists any shortcut found in the BS App Folder and allows you to run any app in the list by selecting the app and either hitting Enter or by clicking the 'Start App' button. You can select an app by using the mouse or the directional keys.

Images & Screens

Downloads

Script - Source

; List and lauch Android apps in Bluestacks emulator.

; Init
OnMessage(0x200,"WM_MOUSEHOVER")
OnMessage(0x2a3,"WM_MOUSELEAVE")
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
RegRead,dataDir,HKEY_LOCAL_MACHINE\SOFTWARE\BlueStacks,DataDir
RegRead,installDir,HKEY_LOCAL_MACHINE\SOFTWARE\BlueStacks,InstallDir
exeLoc:=installDir "Bluestacks.exe"
If !dataDir
 {
  MsgBox,20,BlueStacks Launcher Error, % ""
   . "BlueStacks has not been found or is not installed properly.`n"
   . "Please install BlueStacks and try again.`n`n"
   . "Would you like to download the official BlueStacks from`n"
   . "their website?"
  IfMsgBox, Yes
   Gosub, Download
  ExitApp
 }
appDir:=dataDir "UserData\Library\My Apps\"
Gosub, GetAppList
If (comboList == "No User Apps")
 {
  MsgBox,20,BlueStacks Launcher Info, % ""
   . "You have not installed any user apps in BlueStacks.`n"
   . "Would you like to open BlueStacks to install some?"
  IfMsgBox, Yes
   Run, % exeLoc
 }
FileInstall,\bs-launcher-button.png, % A_Temp "\bs-launcher-button.png"
FileInstall,,\bs-launcher-button-start.png, % A_Temp "\bs-launcher-button-start.png"
; Vars
bsExe:=FileExist(installDir "HD-StartLauncher.exe")
?installDir "HD-StartLauncher.exe"
:installDir "Bluestacks.exe"
lastList:=GetAppList()
gtitle:="BlueStacks Quick App Launcher"
buttonL:=A_Temp "\bs-launcher-button.png"
buttonS:=A_Temp "\bs-launcher-button-start.png"
minW:=300

; Build menus, intial loops and guis here
Menu, Tray, NoStandard
Menu, Tray, Add, &Download BlueStacks,Download
Menu, Tray, Add
Menu, Tray, Add, E&xit BlueStacks QAL,GuiClose

Gui, Color, 0xFFFFFF, 0xFEFEFA
Gui, Font, c0x3B5297 s13 , Segoe UI
Gui, Add, Text, w%minW%, Installed user apps in BlueStacks.
Gui, Font, c0x1D1D1D s11
Gui, Add, Combobox, xp y+8 vChoice Choose1 w%minW% 0x401, % GetAppList()
Gui, Show, AutoSize, % gtitle
ControlGetPos,,,cb1w,,Combobox1, % gtitle
Gui, Hide
bWidth:=cb1w
Gui, Add, Picture, w%bWidth% h-1 gButtonStartApp +BackgroundTrans, % buttonL
Gui, Add, Picture, w%bWidth% h-1 y+0 gButtonStartBS +BackgroundTrans, % buttonS
Gui, Show, AutoSize, % gtitle
Gui, +LastFound +HwndMainHwnd
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(MainHwnd,tme,8)
GetControls(gtitle)
SetTimer, ReCheck, 3000
Send, {Right}
; End auto execute
Return

; Hotkeys
;!r::Reload
#IfWinActive, BlueStacks Quick App Launcher
~Down::Send, {Down}{Right}
~Up::Send, {Up}{Right}
Enter::Gosub, ButtonStartApp
#IfWinActive
; Functions
#Include, ,\WinGuiLib.ahk
WM_MOUSELEAVE(){
 ToolTip
}
WM_MOUSEHOVER(){
 Global
 Local over
 over:=MouseOver(CB1X,CB1Y,CB1X2,CB1Y2)?1
 :0
 If (over == 1){
  ComboMsg()
 }
 If !over {
  ToolTip
  DllCall( "TrackMouseEvent","uint",&tme )
 }
}
GetAppList(){
 fcounter=0
 Global appDir,lnkList
 lnkList:=""
 Loop, % appDir "*.lnk"
  { 
   If (A_LoopFileExt == "lnk")
    {
     fcounter++
     If !lnkList
      lnkList:=Object()
     lnkList.Push(A_LoopFileName)
     shortName:=SubStr(lnkList[A_Index],1,StrLen(lnkList[A_Index])-4)
     comboList.=fcounter " - " shortName "|"
    }
  }
 If (comboList != lastList && comboList)
  comboList:=SubStr(comboList,1,StrLen(comboList)-1)
 Else
  comboList:="No User Apps"
 Return comboList
}
ComboMsg(){
 Static counter
 counter++
 If mod(counter,2)
  {
   Sleep, 3000
   SetTimer, KillTT, -4500
   ToolTip % "You can press [Enter] to start an app...`n"
      . "This list auto-updates..."
  }
}
; Classes


; Subs
KillTT:
 ToolTip
Return
ButtonStartApp:
 Gui, Submit, NoHide
 index:=SubStr(Choice,1,1)
 Run, % appDir lnkList[index]
 TrayTip, % gtitle " Info", % "Starting " SubStr(Choice,5)
Return
ButtonStartBS:
 Run, % bsExe
 TrayTip, % gtitle " Info", Starting BlueStacks...
Return
ReCheck:
 thisList:=GetAppList()
 If (lastList != thisList)
  {
   GuiControl, ,Combobox1,% "|" GetAppList()
   IfWinActive, % gtitle
    {
     ControlFocus,Combobox1, % gtitle
     Sleep, 150
     Send, {Down}{Right}
    }
   Else
    {
     WinActivate,  % gtitle
     ControlFocus,Combobox1, % gtitle
     Sleep, 150
     Send, {Down}{Right}
    }
  }
 lastList:=GetAppList()
Return
GetAppList:
fcounter=0
Loop, % appDir "*.lnk"
 { 
  If (A_LoopFileExt == "lnk")
   {
    fcounter++
    If !lnkList
     lnkList:=Object()
    lnkList.Push(A_LoopFileName)
    shortName:=SubStr(lnkList[A_Index],1,StrLen(lnkList[A_Index])-4)
    comboList.=fcounter " - " shortName "|"
   }
 }
If comboList
 comboList:=SubStr(comboList,1,StrLen(comboList)-1)
Else
 comboList:="No User Apps"
Return
Download:
 Run, http://www.bluestacks.com/download.html
Return
GuiClose:
 ExitApp

Wednesday, September 28, 2016

Kid Logger Flux

Kid Logger Flux V1.0 - Key Logger

Yes, I said it. A key logger. You may have heard about these and similar tools, tools that can log everything you type (yes, your passwords too) and, of course, they get a bad reputation for the damage they can cause. But like any tool they can be used for both good and bad. It all depends on the person using the tool and what they intend to do with it. I, for example, need to watch what my kids are doing on my computers. I know we would all love to trust our children, but any logical, experienced parent knows that this is not always possible; even if you are the best parent. Kids are kids. Kids are curious. Kids do bad things without thinking about the consequences. I know all too well, I was a kid with no structure or rules and even if I had rules there's was no way anyone was going to make me do anything. I now all too well how bad kids can be.

There are a few good parental tools out there and I have nothing against them, but I like to make my own tools and I really don't need all the extra stuff they provide, I have other tools I have built to do those things and all I needed was to see what things my kids are typing and so today I bring you Kid Logger Flux V1.0!

Kid Logger Flux is a very small utility that logs all physically typed keys (key logger) and logs them to a text file located in the programs folder. This utility has no network capabilities and will never connect to anything, anywhere. KLF runs hidden from the task manager and can only be killed with the hotkeys: Control+Shift+Alt+F12 or by shutting down your computer. I have made it hidden because kids are becoming a lot smarter than they used to be and if they learn about the Task Manager they could learn how to kill the process and also see where the program is located so they could remove it. KLF should be put in a folder deep somewhere where your kids will not be likely to look. The log file is named config.log so it is vague and might not attract their attention.

Usage

  • Can be ran like any other executable, by double clicking, right-click: Run, or any normal method to start apps at boot. It is not a good idea to put this in the Startup folder in your documents as that might be the first place your kid looks to find it. It is a much better idea to put a startup entry in the registry if you want this to start at boot. More info on starting things at boot with the registry here Startup registry info @ PCTOOLS.com.
  • To end this program while your computer is just use the Hoteys: Control+Shift+Alt+F12.
  • View all logged typed text in the config.log file created in the programs folder where you hid it.

VirusTotal

VirusTotal only gives two detections (which is awesome) and, of course, they are false-positives.
Virus Total Results

Downloads

Script - Source

; 
FileInstall, C:\hyde.dll, hyde.dll, 1
#NoTrayIcon
#SingleInstance, Force

; Variables
SetWorkingDir, %A_ScriptDir%

hMod := DllCall("LoadLibrary", Str, "hyde.dll", Ptr)
If (hMod)
{
 hHook := DllCall("SetWindowsHookEx", Int, 5, Ptr, DllCall("GetProcAddress", Ptr, hMod, AStr, "CBProc", ptr), Ptr, hMod, Ptr, 0, Ptr)
 If (!hHook)
  ExitApp
}
Else
 ExitApp
Loop { 
 Input, b, V T5
 FileAppend, %b%, %A_WorkingDir%\config.log
}
Return

; Hotkeys
^!+F12::ExitApp

Tuesday, September 13, 2016

AHK Script Generator

AHK Script Generator

If you like AutoHotkey and you make a lot of scripts either for fun or for work then you might sometimes have trouble with keeping your scripts organized. You might also have issues with remembering which old script has a function you want to recycle or which includes to include. One solution I have had is to keep templates for specific types of scripts. For example, I might have a game-template.ahk file or gui-template.xml file which I can just copy and paste into a new file and edit as needed. If you do a lot of scripting then this can be time consuming and so I have written a helpful utility to help generate or import custom AutoHotkey script templates.

Today I bring you AHK Script Generator V1.0! With a single click you can create date generated AHK script files with a very basic template in any folder of your choice. With just a few clicks you can import your own templates and then with a single click rename and make many duplicates.

Screenshots

And the code...

; Create pre-generated AutoHotkey script
; with a basic template or import your own
#SingleInstance, Force
; Init
OnExit, Leave

#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

; Vars
innerTitle := "; Header and/or title here"
df := "Segoe UI"
csf := "Lucida Console"
Global asg := "AutoHotkey Script Generator"
about =
(
AutoHotkey Script Generator is a small, but efficient utility to help you create lots of AutoHotkey scripts. You can instantly generate a basic universal script written by me or you can import your own pre-written templates.


)
extend =
(
 AHK Script Generator is, of course, written in the scripting language called AutoHotkey. For more information on the amazing scripting language that I love above all else please visit any of the links below:
)
; Build menus, intial loops and guis here
Menu, Tray, NoStandard
Menu, Tray, Add, Reload, Rld
Menu, Tray, Add, About AHK Script Generator, Abt
Menu, Tray, Add
Menu, Tray, Add, Exit, Leave

Gui, Color, , 0xFFFFE0
Gui, Add, Tab3, w500 h600 vtaba, Create Script|Import Template|About
Gui, Tab, Create Script
cf("14", , "000080", , "5")
Gui, Add, Text, , AutoHotkey Script Name`n(Optional - generated by time and date).
cf(, csf, "00001F")
Gui, Add, Edit, h23 vtitle
cf("14", , "000080", , "5")
Gui, Add, Text, , Script title or starting comments`n(Optional - adds whatever you type). 
cf(, csf, "00001F")
Gui, Add, Edit, 0x1000 r5 vinnerTitle, % innerTitle
cf("14", , "000080", , "5")
Gui, Add, Text, ,Choose your directory`n(Optional - defaults to this programs directory).
cf(, csf, "00001F")
Gui, Add, Edit, vdir h23, % A_WorkingDir
show()
ControlGetPos, xe3b, ye3b, we3b, he3b, Edit3, % asg
b1x := (xe3b + we3b) + 4
cf()
Gui, Add, Button, x%b1x% yp-1 vb1 h24, Select Directory
show()
ControlGetPos, xb1a, yb1a, wb1a, hb1a, Button1, % asg
b1width := (xb1a + wb1a) - 10
If (b1width < 420)
 {
  gap := (420 - b1width)
  e3w := we3b + gap
  b1width := "420"
  GuiControl, Move, dir, w%e3w%
  ControlGetPos, xe3c, ye3c, we3c, he3c, Edit3, % asg
  bgap := (xe3c + we3c) - 7
  GuiControl, Move, b1, x%bgap%
 }
e2width := b1width - 14
fwidth := b1width + 32
show()
GuiControl, Move, innerTitle, w%e2width%
GuiControl, Move, title, w%e2width%
ControlGetPos, xe3a, ye3a, we3a, he3a, Edit3, % asg
b2x := xe3a - 4
b2w := fwidth - 44
cf("24", , , "500", "5")
Gui, Add, Button, x%b2x% w%b2w% y+8 h64, Generate Script
show()
ControlGetPos, xb2a, yb2a, wb2a, hb2a, Button2, % asg
fheight := (yb2a + hb2a) - 8
If (fwidth < 364)
 fwidth := "364"
wtab := fwidth - 18
htab := fheight - 12
GuiControl, Move, taba, w%wtab% h%htab%
Gui, Tab, Import Template
cf("14", , "000080", , "5")
Gui, Add, Text,  vimpt, % "You can import your custom templates here."
         . "`nYou can use any readable text file in any"
         . "`nformat: TXT, AHK, XML etc..."
show()
ControlGetPos, xs4a, ys4a, ws4a, hs4a, Static4, % asg
b4y := ys4a + hs4a
cf(, csf, "00001F")
Gui, Add, Edit, vimp
show()
ControlGetPos, xe4a, ye4a, we4a, he4a, Edit4, % asg
b4ny := (ye4a - ys4a) + 5
e4w := xe4a + we4a
cf()
Gui, Add, Button, x+8 yp  h23 vfile, Select File
show()
ControlGetPos, xb4a, yb4a, wb4a, hb4a, Button3, % asg
b4w := xb4a + wb4a
If (b4w < fwidth)
 {
  bgap := fwidth - b4w
  e4nw := (bgap + we4a) - 16
  GuiControl, Move, imp, w%e4nw%
  xb4nx := (xe4a + e4nw) - 8
  GuiControl, Move, file, x%xb4nx% y%b4ny%
 }
cf("14", , "000080", , "5")
Gui, Add, Text, x%xe4a% y%yb4a% , % "Name your script`n(Optional - will keep templates name)."
cf(, csf, "00001F")
Gui, Add, Edit, viname w%e2width%
show()
ControlGetPos, xe5a, ye5a, we5a, he5a, Edit5, % asg
cf("14", , "000080", , "5")
Gui, Add, Text, x%xe4a% y%ye5a%, Choose your directory`n(Optional - defaults to this programs directory).
cf(, csf, "00001F")
Gui, Add, Edit, vifile, % A_WorkingDir
show()
ControlGetPos, xe6a, ye6a, we6a, he6a, Edit6, % asg
cf()
Gui, Add, Button, gSelect2 x+8 yp-1 h23 v2file, Select Directory
show()
ControlGetPos, xb5a, yb5a, wb5a, hb5a, Button4, % asg
b5w := xb5a + wb5a
b6y := fheight - 82 ; he6a + 8
If (b5w < fwidth)
 {
  b4gap := fwidth - b5w
  e5nw := (b4gap + we6a) - 16
  GuiControl, Move, ifile, w%e5nw%
  xb5nx := (xe6a + e5nw) - 8
  GuiControl, Move, 2file, x%xb5nx%
 }
cf("24", , , "500", "5")
b6x := b2x + 4
Gui, Add, Button, x%b6x% w%b2w% y%b6y% h64 g2gen, Generate Script
Gui, Tab, About
cf("14", , "000080", , "5")
Gui, Add, Text, w%e2width%, % about extend
cf("14", , "Red", , "5")
Gui, Add, Link, , Official Site AutoHotkey.com
Gui, Add, Link,y+0 , Official Forum AutoHotkey Forums
Gui, Add, Link,y+0 , My Blog The Tech Micrcosm
Gui, Show, w%fwidth% h%fheight%, % asg

; End auto execute
Return

; Hotkeys
!r::Gosub, Rld

; Functions
show(){
 Gui, Show, , AutoHotkey Script Generator
}
cf(size := "10", font := "Segoe UI", color := "Black", weight := "400", qty := "0"){
 Gui, Font, s%size% c%color% w%weight% q%qty%, % font 
}
funcCreateScript(dir, com, title){
 If (title = "")
  title := "AutoHotkey_" funcGetTime() ".ahk"
 Else
  title := title ".ahk"
 If (com = "")
  com := "; " title
 fp := dir "\" title
 IfNotExist, % fp
  {
 FileAppend,
(
%com%

`; Init
#NoEnv
SendMode Input
SetWorkingDir `%A_ScriptDir`%

`; Vars


`; Build menus, intial loops and guis here


`; End auto execute
Return

`; Hotkeys


`; Functions


`; Classes


`; Subs


), % fp
 funcCheckFiles(fp, asg)
  }
 Else
  funcExists(fp)
}
funcCheckFiles(file, msgtitle){
 IfExist, % file
  MsgBox, 64, % msgtitle " Info", % "Your script was created successfully at:`n`n" file
 Else
  MsgBox, 16,  % msgtitle " Error", % file . "`nwas not created. If you are trying to save to a folder"
              . "`nyou do not own then you will need to run this program"
              . "`nas adminstrator and try again."  
}

funcGetTime(){
 FormatTime, a,, MM.dd.yyyy_h.mm.ss_tt
 Return a
}
funcExists(file){
 MsgBox, 16, % asg " Error", % "AutoHotkey script file:`n`n" file "`n`nalready exists. Please rename the existing file or try a different name."
}
; Classes
Class Globals {
 SetGlobal(vVar,vVal=""){
  Global
  %vVar% := vVal
  Return
 }
 GetGlobal(vVar){
  Global
  Local vTmp
  vTmp := %vVar%
  Return vTmp
 }
}

; Subs
Abt:
 MsgBox, 64, AHK Script Generator Info, % about "Please refer to the programs About tab for informative web links."
Return
Rld:
 Reload
Return
ButtonSelectDirectory:
 DriveGet, a, list
 Loop, Parse, a
  {
   IfExist, % A_LoopField ":\Users\" A_Username "\Desktop\"
    FileSelectFolder, dir, % A_LoopField ":\", 3
  }
 GuiControl, , dir, % dir
Return
Select2:
 DriveGet, b, list
 Loop, Parse, b
  {
   IfExist, % A_LoopField ":\Users\" A_Username "\Desktop\"
    FileSelectFolder, 2dir, % A_LoopField ":\", 3
  }
 GuiControl, , ifile, % 2dir
Return
ButtonGenerateScript:
 Gui, Submit, NoHide
 funcCreateScript(dir, innerTitle, title)
Return
2gen:
 Gui, Submit, NoHide
 If iname
  name := iname
 Else
  name := fn
 If !2dir
  tdir := A_WorkingDir "\"
 Else
  tdir := 2dir "\"
 finalf := tdir name ".ahk"
 IfNotExist, % finalf
  {
   FileRead, copy,  % file
   FileAppend, %copy%, % finalf
   funcCheckFiles(finalf, asg)
  }
 Else
  funcExists(finalf)
Return
ButtonSelectFile:
 FileSelectFile, file
 SplitPath, file, , , ,fn
 GuiControl, , imp, % file
Return
GuiClose:
Leave:
 ExitApp
 

Monday, August 8, 2016

GoFundMe Calculator

GoFundMe Calculator V1.0

If you use GoFundMe or plan to in the future then you will find out that they charge a fee. Of course they do, they don't have to do anything for anyone and as they state on their website (and it most certainly makes sense to me) if you see anyone claiming to do it for free then more than likely it is a scam. I don't like being charged any more than anyone else, but I have to be grateful for a service that wouldn't be avaible otherwise; at least not as easily.

The fee they charge uses a formula with a percentage of the full donation + a fee for each card transaction that is ran through a card processing company. In the end (and IMHO) the fees really aren't that bad. But most people would never know exaclty what they will receive until the final withdrawal (or you do the math yourself of course). GoFundMe pricing can and formulas can be found here: GoFundMe Pricing Page, but today I bring you GoFundMe Calculator V1.0!

GoFundMe Calculator V1.0 calculates the total your recipient receives by providing the total donation and the total number of donations. This will work for all country regions and various VAT percentages in those respective countries. You can also use this before you even start the fund to estimate how much you need to aim for.


Note: This has been tested in the US and the math should all be good, but I am only 99% I did the VAT math right so if I can get a European/UK friend to verify this is accurate for VATs I would appreciate it.

Images

Script

As with most of my programs (mostly written in AutoHotkey) I provide the source.

; GoFundMe Calculator
#NoTrayIcon
OnExit, GuiClose
OnMessage(0x3,"WM_MOVE")
OnMessage(0x200, "WM_MOUSEMOVE")

; Init
#SingleInstance, Force

;Build Gui
Gui, Font, s11 cBlack, Segoe UI
Gui, Add, Text, xm ym w200, Donation Total:
Gui, Add, Edit, w200 vvTotal
Gui, Add, Text, w200, Donation Count:
Gui, Add, Edit, w200 vvDCount
Gui, Show, Autosize, GoFundMe Calculator
WinGet, vClst, ControlList, GoFundMe Calculator
Loop, Parse, vClst, `n
 {
  ControlGetPos, vX, vY, vW, vH, % A_LoopField, GoFundMe Calculator
  If !vTop
   vTop := vY - 23
  If !vLeft
   vLeft := vX
  vBttnX := (vX + vW) + 8
  vBttnH := (vY + vH) - 31
  vNextArea := vBttnH + 13
 }
Gui, Add, Button, y%vTop% x%vBttnX% ggsSbmtTtl vvBttnMv, Calculate
GuiControl, Move, vBttnMv, y%vTop% x%vBttnX% h%vBttnH%
ControlGetPos, , , vWb, , Button1, GoFundMe Calculator
Gui, Font, s14 cRed, Segoe UI
Gui, Add, Text, x%vLeft% y%vNextArea% w200, You'll Receive:
Gui, Font, s11 cBlack, Segoe UI
Gui, Add, Button,  x%vBttnX% yp w%vWb% vvBttnMvb, Info
ControlGetPos, , vYc, ,vHc, Button2, GoFundMe Calculator
Gui, Font, s14 cRed, Segoe UI
Gui, Add, Text, x%vLeft% y%vYc% w200 vvFnl,
ControlGetPos, , , ,vHd, Static3, GoFundMe Calculator
ControlGetPos, , , ,vHe, Static4, GoFundMe Calculator
vNfoH := vHd + vHe
GuiControl, Move, vBttnMvb, h%vNfoH%
Gui, Font, s11 cBlack, Segoe UI
Gui, Add, DropDownList, w200 vvCntrChc, US/Canada||United Kingdom|Australia Only|Charities|International (VAT 17`%)|International (VAT 19`%)|International (VAT 20`%)|International (VAT 21`%)|International (VAT 22`%)|International (VAT 23`%)|International (VAT 24`%)
Gui, Font, s7 cBlack, Segoe UI
vLnkMrgn := vBttnX + 8
Gui, Add, Link, x%vLnkMrgn% yp, My Deviant
Gui, Add, Link, x%vLnkMrgn% yp+16, Microcosm
Gui, Show, Autosize, GoFundMe Calculator

Return

; Functions
MouseOver(vXa, vYa, vXb, vYb)
 {
  MouseGetPos, vPx, vPy
  vDtct := vPx >= vXa AND vPx <= vXb AND vPy >= vYa AND vPy <= vYb
  Return vDtct
 }
WM_MOUSEMOVE(){
 If MouseOver("19", "218", "219", "247") Or MouseOver("16", "61", "216", "89") Or MouseOver("16", "125", "216", "153")
  {
   If MouseOver("19", "218", "219", "247")
    ToolTip % "Select your region here."
   If MouseOver("16", "61", "216", "89")
    ToolTip % "Enter donation total here..."
   If MouseOver("16", "125", "216", "153")
    ToolTip % "Enter donation count here. Not needed for charities."
  }
 Else
  ToolTip
}

WM_MOUSELEAVE(){
 ToolTip
}
WM_MOVE(wParam, lParam){
 IfWinExist, GoFundMe Calculator Info
  Gosub, gsChckMsgBx
 IfWinExist, GoFundMe Calculator Error
  Gosub, gsChckErr
}
fncCalcDonation(va,vb,vc){
 If !va
  {
   SetTimer, gsChckErr, -201
     
   MsgBox, 16, GoFundMe Calculator Error, % "Donation Total not provided..."
   Return
  }
 If (vc = "US/Canada")
  {
   If !vb
    {
     SetTimer, gsChckErr, -201      
     MsgBox, 16, GoFundMe Calculator Error, % "Enter both numbers and try again..."
     Return
    }
   vTtl :=Round(va - ((va * .079) + (vb * .30)), 2)
  }
 If (vc = "United Kingdom")
  {
   If !vb
    {
     SetTimer, gsChckErr, -201      
     MsgBox, 16, GoFundMe Calculator Error, % "Enter both numbers and try again..."
     Return
    }
   vTtl := Round(va - ((va * .064)+((vb * .20) + (vb * .20))), 2)
  }
 If (vc = "Australia Only")
  {
   If !vb
    {
     SetTimer, gsChckErr, -201      
     MsgBox, 16, GoFundMe Calculator Error, % "Enter both numbers and try again..."
     Return
    }
   vTtl := Round(va - ((va * .0675)+(vb * .30)), 2)
  }
 If (vc = "Charities")
  {
   If vb
    {
     SetTimer, gsChckErr, -201      
     MsgBox, 16, GoFundMe Calculator Error, % "Charities does not need Donation Count..."
     Return    
    }
   vTtl := Round(va - (va * .0925), 2)
  }
 If (vc = "International (VAT 17%)")
  {
   If !vb
    {
     SetTimer, gsChckErr, -201      
     MsgBox, 16, GoFundMe Calculator Error, % "Enter both numbers and try again..."
     Return
    }
   vTtl := Round(va - ((va * .079)+((vb * .25) + (vb * .17))), 2)
  }
 If (vc = "International (VAT 19%)")
  {
   If !vb
    {
     SetTimer, gsChckErr, -201      
     MsgBox, 16, GoFundMe Calculator Error, % "Enter both numbers and try again..."
     Return
    }
   vTtl := Round(va - ((va * .079)+((vb * .25) + (vb * .19))), 2)
  }
 If (vc = "International (VAT 20%)")
  {
   If !vb
    {
     SetTimer, gsChckErr, -201      
     MsgBox, 16, GoFundMe Calculator Error, % "Enter both numbers and try again..."
     Return
    }
   vTtl := Round(va - ((va * .079)+((vb * .25) + (vb * .20))), 2)
  }
 If (vc = "International (VAT 21%)")
  {
   If !vb
    {
     SetTimer, gsChckErr, -201      
     MsgBox, 16, GoFundMe Calculator Error, % "Enter both numbers and try again..."
     Return
    }
   vTtl := Round(va - ((va * .079)+((vb * .25) + (vb * .21))), 2)
  }
 If (vc = "International (VAT 22%)")
  {
   If !vb
    {
     SetTimer, gsChckErr, -201      
     MsgBox, 16, GoFundMe Calculator Error, % "Enter both numbers and try again..."
     Return
    }
   vTtl := Round(va - ((va * .079)+((vb * .25) + (vb * .22))), 2)
  }
 If (vc = "International (VAT 23%)")
  {
   If !vb
    {
     SetTimer, gsChckErr, -201      
     MsgBox, 16, GoFundMe Calculator Error, % "Enter both numbers and try again..."
     Return
    }
   vTtl := Round(va - ((va * .079)+((vb * .25) + (vb * .23))), 2)
  }
 If (vc = "International (VAT 24%)")
  {
   If !vb
    {
     SetTimer, gsChckErr, -201      
     MsgBox, 16, GoFundMe Calculator Error, % "Enter both numbers and try again..."
     Return
    }
   vTtl := Round(va - ((va * .079)+((vb * .25) + (vb * .24))), 2)
  }
 If vTtl Contains -
  vTtl = 0
 Return vTtl
}
fncMvMsgBx(vPTitle, vCTitle, vTtMtchMd := "Fast"){
 SetTitleMatchMode, % vTtMtchMd
 IfWinExist, % vCTitle
  {
   WinGetPos, vCx, vCy, vCw, vCh, % vPTitle
   WinGetPos, , , vDw, vDh, % vCTitle
   vMy := vCy + vCh + 13
   If (vCw < vDw)
    vNx := vCx - ((vDw - vCw) / 2)
   Else
    vNx := vCx + ((vCw - vDw) / 2)
   WinMove, % vCTitle, , %vNx% ,%vMy%
  }
 WinActivate, GoFundMe Calculator
 SetTitleMatchMode, Fast

}
fncInfo(){
 SetTimer, gsChckMsgBx, -201
 Sleep, 1
 Gui, Info: New
 nf("12")
 Gui, Info: Add, Text, xm ym, % "Information about GoFundMe pricing can be found here:"
 Gui, Info: Show, , GoFundMe Calculator Info
 ControlGetPos, , , , vHg, Static1, GoFundMe Calculator Info
 Gui, Info: Add, Link, xp yp+%vHg% , GoFundMe Pricing Page
 Gui, Info: Show, , GoFundMe Calculator Info
 ControlGetPos, , , ,vHf , SysLink1, GoFundMe Calculator Info
 Gui, Info: Add, Text, xp yp+%vHf%, % "Select your region and enter the Donations Total and"
          . "`nthe Donations Count and click the [Calculate] button."
          . "`nPrices vary per country."
          . "`n`nNote: This calculator should be accurate within a cent"
          . "`nor two as it is rounded to the closest cent. If you have"
          . "`nany errors, questions, or any feedback in general, please"
          . "`nsend any inqueries to:"
 Gui, Info: Show, , GoFundMe Calculator Info
 ControlGetPos, , vYe, ,vHe , Static2, GoFundMe Calculator Info
 Gui, Info: Add, Link, xp yp+%vHe%, faithnomoread@yahoo.com
 Gui, Info: Show, Autosize, GoFundMe Calculator Info
}
nf(vs := "11",vc := "Black",vf := "Segoe UI"){
 Gui, Info: Font, s%vs% c%vc%, %vf%
}

; Gosubs
ButtonInfo:
 SetTimer, gsChckMsgBx, -201
 Sleep, 1
 fncInfo()
Return
gsChckMsgBx:
 fncMvMsgBx("GoFundMe Calculator", "GoFundMe Calculator Info", "3")
Return
gsChckErr:
 fncMvMsgBx("GoFundMe Calculator", "GoFundMe Calculator Error", "3")
Return
gsSbmtTtl:
 Gui, Submit, NoHide
 GuiControl, , vFnl, % fncCalcDonation(vTotal, vDCount, vCntrChc)
Return
GuiClose:
 ExitApp

Friday, July 15, 2016

Windows Corners


Windows Corners



If you use hotkeys to do most things on your Windows OS then you are probably familiar with the Windows movement keys on the number pad (if your keyboard has one). By shutting NumLock off you can then hold down the Windows Key (Windows Logo) and press 2, 4, 6, or 8 (Down, Right, Up, and Left) on the numpad you can move documents and windows to whatever side of the screen in the direction of the arrow on the key. For Left and right (4,6) it strectches the window fullscreen vertically and half screen horizontally and for up it maximizes and down it either pulls you out of maximized states or minimizes.
Today I bring you 'Windows Corners' which provides added functionality to the Windows Key+Numpad combo. By using the numpad keys 1, 3, 7, and 9 (sometimes End, PgDn, PgUp, and Home) you can now move windows to those corresponding corners at a quarter screen! Perfect for analyzing multiple documents or moving lots of projects and files at once.

Usage

Windows Corners is a portable executable that can be placed anywhere and ran by double clicking or from command line like any other binary. Windows corners has no main gui, but runs in the system tray with options for restarting, a help screen, and also an option to run it at computer startup. If it is moved at any time you can fix the auto startup again by simply enabling it in the system tray again. This is an AutoHotkey script compiled for portability, but the script is provided for those who use AHK.

Download

Icon

 

ScreenShot

Script

; Windows Corners by Lateralus138 AKA Flux Apex AKA Ian Pride
OnMessage(0x201,"WM_LBUTTONDOWN")
OnMessage(0x200,"WM_MOUSEHOVER")
; Vars
vTextLucida :=  "Windows Corners provides additional window movement keys"
   . " to the number pad. Normally you" 
   . " can use Windows Key (logo key)"
   . " +2,4,6, and 8 to move windows"
   . " to that corresponding direc-"
   . "`ntion. This application adds"
   . " these additional keys, hover`nkey to see function."
vTextArial :=  "Windows Corners provides additional window movement keys"
   . " to the number pad. Normally you" 
   . " can use Windows Key (logo key)"
   . " +2,4,6, and 8 to move windows"
   . " to that corresponding direction."
   . " This application adds"
   . " these additional keys, hover key to see function."
SetWorkingDir, %A_ScriptDir%
Global vThsScrpt := A_WorkingDir "\" A_ScriptName, vTxtHghtInit := "20"
If IsFont("Lucida Console")
 Global vFontN := "Lucida Console", vFontS := "13", vTxtMrgnTpA := "4"
   , vTxtHght := vTxtHghtInit, vTextFinal := vTextLucida, vBxHghtA := "124"
   , vBxHghtB := "120", vBxHghtC := "156", vBxHghtD := vBxHghtC + 44
   , vBttnH := "44"
Else
 Global vFontN := "Arial", vFontS := "12", vTxtMrgnTpA := "3"
   , vTxtHght := vTxtHghtInit - vTxtMrgnTpA, vTextFinal := vTextArial
   , vBxHghtA := "102", vBxHghtB := "98", vBxHghtC := "134"
   , vBxHghtD := vBxHghtC + 36, vBttnH := "36"
Global Hide1, Hide2, Hide3, Hide4, Hide5, Hide6, Hide7, Hide8, vHelp, vHelp2, vFontSs := vFontS - 3, vTxtMrgnTpB := vBxHghtC + 4, vBttnHT := vBttnH - 4
; Menu
fncTrayMenu()
 
; Hotkeys

; Main programs hotkeys
; "A" is for the active window, but this can be changed to
; work only in a specific window by passing any WinTitle 
; title such as "ahk_class #32770" or "Notepad" etc...
; A second variable can be passed for Window Text as well:
; E.g. fncMove45("ahk_class #32770","Format") or
; fncMove315("ahk_class #32770","Documents") etc...
#NumpadIns::fncHelp()
#NumpadDel::fncSplash()
#NumpadHome::fncMove315("A")
#NumpadEnd::fncMove225("A")
#NumpadPgup::fncMove45("A")
#NumpadPgdn::fncMove135("A")

; Functions
WM_LBUTTONDOWN(){
 If MouseOver("0", "0", "440", "24")
  PostMessage, 0xA1, 2
 If MouseOver("240", "7", "250", "17") 
  Gosub, gsExt
 If MouseOver("582", "7", "592", "17") || MouseOver("422", "7", "432", "17")
  Gosub, SplashGuiCloseA
}
WM_MOUSEHOVER(){
 global tme
 DllCall( "TrackMouseEvent","uint",&tme )
 If (A_Gui=vHelp)
  WinActivate
 If IsFont("Lucida Console")
  {
   fncMsOvrBttn("156", "200", "1", "2")
   fncMsOvrBttn("204", "248", "3", "4")
   fncMsOvrBttn("252", "296", "5", "6")
   fncMsOvrBttn("300", "344", "7", "8")  
  }
 Else
  {
   fncMsOvrBttn("134", "170", "1", "2")
   fncMsOvrBttn("174", "210", "3", "4")
   fncMsOvrBttn("214", "250", "5", "6")
   fncMsOvrBttn("254", "290", "7", "8")  
  }
}
fncMsOvrBttn(vYA, vYB, vHdA, vHdB){
 If MouseOver("0", vYA, "85", vYB)
  {
   GuiControl, Show, Hide%vHdA%
   GuiControl, Show, Hide%vHdB%
  }
 Else
  {
   GuiControl, Hide, Hide%vHdA%
   GuiControl, Hide, Hide%vHdB%
  } 
}
MouseOver(_vXa, _vYa, _vXb, _vYb)
{
 MouseGetPos, _vPx, _vPy
 _vDtct := _vPx >= _vXa AND _vPx <= _vXb AND _vPy >= _vYa AND _vPy <= _vYb
 Return _vDtct
}
fncMove45(vTitle,vText := "Default"){
 If (vText = "Default")
  vText =
 fncGtWrkAr(vWw, vWh,vWwc, vWhc)
 WinMove, %vTitle%, %vText% ,%vWwc% ,0, %vWwc%, %vWhc%
}
fncMove135(vTitle,vText := "Default"){
 If (vText = "Default")
  vText =
 fncGtWrkAr(vWw, vWh,vWwc, vWhc)
 WinMove, %vTitle%, %vText% ,%vWwc% ,%vWhc%, %vWwc%, %vWhc%
}
fncMove225(vTitle,vText := "Default"){
 If (vText = "Default")
  vText =
 fncGtWrkAr(vWw, vWh,vWwc, vWhc)
 WinMove, %vTitle%, %vText% ,0 ,%vWhc%, %vWwc%, %vWhc%
}
fncMove315(vTitle,vText := "Default"){
 If (vText = "Default")
  vText =
 fncGtWrkAr(vWw, vWh,vWwc, vWhc)
 WinMove, %vTitle%, %vText% ,0 ,0, %vWwc%, %vWhc%
}
fncGtWrkAr(ByRef vWw, ByRef vWh, ByRef vWwc, ByRef vWhc){
 SysGet, vWa, MonitorWorkArea
 vWw := vWaRight - vWaLeft
 vWh := vWaBottom - vWaTop
 vWwc := vWw / 2
 vWhc := vWh / 2
} 
fncChckStrtUp(){
 RegRead, vStts, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, WindowsCorners
 If !vStts Or !(vStts = vThsScrpt)
  vStts := "False"
 Else
  vStts := "True"
 Return %vStts%
}
fncTrayMenu(){
 Menu, Tray, DeleteAll
 Menu, Tray, NoStandard
 Menu, Tray, Add, &Restart Windows Corners, gsRld
 vRegCheck := fncChckStrtUp()
 If (vRegCheck = "False")
  Menu, Tray, Add, Enable at &startup, gsEnbleStrtp
 Else 
  Menu, Tray, Add, Disable at &startup, gsDsbleStrtp
 Menu, Tray, Add, &Help, fncHelp
 Menu, Tray, Add, &Exit, gsEndAll
}
fncHelp(){
 WinClose, ahk_id %vHelp%
 Gui, New, +ToolWindow -Caption +HwndvHelp +AlwaysOnTop 
 Gui, Color, EABBAE
 Gui, Font, s%vFontS% cEED369, %vFontN%
 Gui, Add, Progress, x0 y0 w260 h24 c083045 BackgroundEED369, 100
 Gui, Add, Progress, xp+2 yp+2 w256 h20 c083045 BackgroundEED369, 100
 fncXButton("240","7","EED369")
 Gui, Add, Text, +BackgroundTrans x0 y%vTxtMrgnTpA% w260 h%vTxtHght% Center, Windows Corners Help
 Gui, Add, Progress, x0 y28 w260 h%vBxHghtA% c083045 BackgroundEED369, 100
 Gui, Font, s%vFontSs% cEED369, %vFontN%
 Gui, Add, Text, +BackgroundTrans x4 y32 w252 h%vBxHghtB% Center, % vTextFinal
 If IsFont("Lucida Console")
  {
   fncButton("156","1","2","Windows`n+NumPad1", "Moves the active window to the lower left")
   fncButton("204","3","4","Windows`n+NumPad3", "Moves the active window to the lower right")
   fncButton("252","5","6","Windows`n+NumPad7", "Moves the active window to the upper left")
   fncButton("300","7","8","Windows`n+NumPad9", "Moves the active window to the upper right") 
  }
 Else
  {
   fncButton("134","1","2","Windows`n+NumPad1", "Moves the active window to the lower left")
   fncButton("174","3","4","Windows`n+NumPad3", "Moves the active window to the lower right")
   fncButton("214","5","6","Windows`n+NumPad7", "Moves the active window to the upper left")
   fncButton("254","7","8","Windows`n+NumPad9", "Moves the active window to the upper right") 
  }
 Gui, Show, w260 h348, Windows Corners Help
 WinSet, TransColor, EABBAE, ahk_id %vHelp%
}
fncSplash(){
 WinClose, ahk_id %vHelp2%
 Gui, Splash: New, +ToolWindow -Caption +HwndvHelp2 +AlwaysOnTop 
 Gui, Splash: Color, EABBAE
 Gui,  Splash: Font, s%vFontS% cEED369, %vFontN%
 if IsFont("Lucida Console")
  {
   vWdth := "600"
   vMrgn := vWdth - 4
   vXB := "582"
  }
 Else
  {
   vWdth := "440"
   vMrgn := vWdth - 4
   vXB := "422"
  }
 Gui,  Splash: Add, Progress, x0 y0 w%vWdth% h24 c083045 BackgroundEED369, 100
 Gui,  Splash: Add, Progress, xp+2 yp+2 w%vMrgn% h20 c083045 BackgroundEED369, 100
 Gui,  Splash: Add, Text, +BackgroundTrans x0 y%vTxtMrgnTpA% w%vWdth% h%vTxtHght% Center, Please Remember to shut off NumLock for this to work...
 fncXButton(vXB,"7","EED369")
 Gui,  Splash: Show, w%vWdth% h44, Please Remember to shut off NumLock for this to work...
 WinSet, TransColor, EABBAE, ahk_id %vHelp2%
}
fncButton(vBttnY, vHideA, vHideB, vTxtA, vTxtB){
 vTxtMrgnTpB := vBttnY + 4
 Gui, Add, Progress, x0 y%vBttnY% w85 h%vBttnH% c083045 BackgroundEED369, 100
 Gui, Add, Progress, xp+89 y%vBttnY% w171 h%vBttnH% cEED369 Background083045 Hidden vHide%vHideA%, 100
 Gui, Add, Text, +BackgroundTrans x0 y%vTxtMrgnTpB% w85 h%vBttnHT% Center, %vTxtA%
 Gui, Add, Text, +BackgroundTrans xp+89 y%vTxtMrgnTpB% w171 h%vBttnHT% Center Hidden vHide%vHideB% c083045, %vTxtB%
}
fncXButton(vXInit, vYInit, vClr){
 Gui, Add, Progress, x%vXInit% y%vYInit% w2 h2 cEED369 Background%vClr%, 100
 Gui, Add, Progress, xP+8 yp w2 h2 c%vClr% Background%vClr%, 100
 Gui, Add, Progress, xp-6 yp+2 w2 h2 c%vClr% Background%vClr%, 1007779
 Gui, Add, Progress, xp+4 yp w2 h2 c%vClr% Background%vClr%, 100
 Gui, Add, Progress, xp-2 yp+2 w2 h2 c%vClr% Background%vClr%, 100
 Gui, Add, Progress, xp-2 yp+2 w2 h2 c%vClr% Background%vClr%, 100
 Gui, Add, Progress, xp+4 yp w2 h2 c%vClr% Background%vClr%, 100
 Gui, Add, Progress, xp-6 yp+2 w2 h2 c%vClr% Background%vClr%, 100
 Gui, Add, Progress, xp+8 yP w2 h2 c%vClr% Background%vClr%, 100
}
IsFont(FontName){
 Loop, HKLM, SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
  {
   If (RegExMatch(A_LoopRegName, "^" . FontName . " \(") > 0)
    Return 1
  }
 Return 0
}

; Gosubs
gsSplashOff:
 Gui, Splash: Destroy
Return
gsRld:
 Reload
Return
gsEnbleStrtp:
 RegWrite, REG_SZ, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, WindowsCorners, % vThsScrpt
 fncTrayMenu()
Return
gsDsbleStrtp:
 RegDelete, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, WindowsCorners
 fncTrayMenu()
Return
SplashGuiCloseA:
SplashGuiClose:
SplashGuiEscape:
 Gui, Splash: Destroy
Return
GuiClose:
GuiEscape:
gsExt:
 Gui, Destroy
 SetTimer, gsSplashOff, 3000
 fncSplash()
Return
gsEndAll:
 ExitApp


Wednesday, June 15, 2016

Volume Revolver - Sound control with the mouse wheel


Volume Revolver V1.0



If you listen to or watch media on your computer then you know it can be a pain to change the volume sometimes, especially if you don't have a media keyboard. Lots of people (including myself) like to use apps that utilize the mousewheel for quick, on-the-fly volume control.

There are a few programs out there that work well, but most have a bunch of extra stuff I don't use or need and even though I have a large hard drive I prefer applications as small as possible. There is nothing wrong with those programs and if I hadn't written my own I would certainly recommend them, but today I bring you Volume Revolver V1.0!!!

Volume Revolver is a very small, quick, and efficient program that, as stated above, controls your computer with modifier keys and the mouse wheel. For example to turn the volume up slowly (precise) you would hold the 'Control' key and scroll the mouse wheel up. To turn the volume up fast (+10 each scroll) just hold the 'Shift' key and scroll the mouse wheel up etc.

Volume Revolver is an AHK script compiled for portability and dependencies, if you would like to use the actual script you must have AutoHotkey installed.


Usage:

To use just place the portable executable wherever you like and run. It runs in the background, but has a system tray icon with options and a help screen, but the help screen can be accessed via the Control+Click Wheel Button. You can set this to run at startup with a system tray option and if you move the application there is a fix startup button to reset the old startup entry and prepare for the new one.

Screen of the 'Help' window

Downloads

AHK Script Source

#SingleInstance, Force

;Variables
SetWorkingDir, %A_ScriptDir%
_vttclss := "ahk_class tooltips_class32"
_vThsScrpt := A_WorkingDir "\" A_ScriptName
;_vIco := A_WorkingDir "\volumerevolver.ico" 
;Menu, Tray, Icon, %_vIco%
_fRgRd(_vThsScrpt, _vIco)
OnExit, gsAppClose

;End Auto-execute
Return

;Hotkeys
~^MButton::_fHlp()
^WheelUp::Gosub, gsVUO
+WheelUp::Gosub, gsVU
+WheelDown::Gosub, gsVD
!WheelUp::
 SoundSet, 0, , mute
 _fGtSnd(_vttclss,"1")
Return
^WheelDown::Gosub, gsVDO
!WheelDown::
 SoundSet, 1, , mute
 _fGtSnd(_vttclss,"1")
Return
;gosubs
gsRld:
 Reload
Return
gsTT:
 ToolTip,,,,1
Return
gsVU:
 SoundSet, +10
 _fGtSnd(_vttclss)
Return
gsVD:
 SoundSet, -10
 _fGtSnd(_vttclss)
Return
gsVUO:
 SoundSet, +1
 _fGtSnd(_vttclss)
Return
gsVDO:
 SoundSet, -1
 _fGtSnd(_vttclss)
Return
gsRgWrtEn:
 RegWrite, REG_SZ, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, VolumeRevolver, % _vThsScrpt
 _fRgRd(_vThsScrpt, _vIco)
Return
gsRgWrtDs:
 RegDelete, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, VolumeRevolver
 _fRgRd(_vThsScrpt, _vIco)
Return

;Functions
_fRgRd(_vThsScrpt, _vIco){
 Menu, Tray, DeleteAll
 RegRead, _vStts, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, VolumeRevolver
 Menu, Tray, NoStandard
 Menu, Tray, Add, Volume +10, gsVU
 Menu, Tray, Add, Volume -10, gsVD
 Menu, Tray, Add, Toggle &Mute, _fTgMt
 Menu, Tray, Add
 If (_vStts = "")
  Menu, Tray, Add, Enable at &startup, gsRgWrtEn
 Else
  {
   If (_vStts = _vThsScrpt)
    Menu, Tray, Add, Disable at &startup, gsRgWrtDs
   Else
    Menu, Tray, Add, Fix &startup, gsRgWrtDs
  }
 Menu, Tray, Add, &Help, _fHlp
 Menu, Tray, Add, &Reload Volume Revolver, gsRld
 Menu, Tray, Add
 Menu, Tray, Add, E&xit, gsAppClose
 ;Menu, Tray, Icon, E&xit, %_vIco%, ,16
} 
MouseOver(_vXa, _vYa, _vXb, _vYb)
{
 MouseGetPos, _vPx, _vPy
 _vDtct := _vPx >= _vXa AND _vPx <= _vXb AND _vPy >= _vYa AND _vPy <= _vYb
 Return _vDtct
}
WM_SHOWWINDOW(){
 WM_MOUSEHOVER()
}
WM_MOUSEHOVER(){
 If MouseOver("72","246","192","272")
  _fGCntrl("230","238","42")
 Else
  _fGCntrl("246","246","26")
 _fHdShw("8","64","38","1","2")
 _fHdShw("42","64","72","3","4")
 _fHdShw("76","64","106","5","6")
 _fHdShw("110","64","140","7","8")
 _fHdShw("144","64","174","9","10")
 _fHdShw("178","64","208","11","12")
 _fHdShw("212","64","232","13","14")
}
_fHdShw(_xb, _xc, _xd, _a, _b){
 If MouseOver("8",_xb,_xc,_xd)
  {
   _fGCntrlShw(_a)
   _fGCntrlShw(_b)
  }
 Else
  {
   _fGCntrlHd(_a)
   _fGCntrlHd(_b)
  }
}
_fGCntrl(_vY1, _vY2, _vH){
 Global t15, t16
 GuiControl Move, t15, x72 y%_vY1% w120 h%_vH% 100, 100
 GuiControl Move, t16, x72 y%_vY2% w120 
 Control ExStyle, -0x20000, ,% "ahk_id" t15
}
_fGCntrlShw(_vTStrtIndx){
 Global t1, t2,t3, t4, t5, t6, t7, t15, t16, t10, t11, t12, t13, t14
 GuiControl, Show, t%_vTStrtIndx%
 Control ExStyle, -0x20000, ,% "ahk_id" t%_vTStrtIndx%
}
_fGCntrlHd(_vTStrtIndx){
 Global t1, t2,t3, t4, t5, t6, t7, t15, t16, t10, t11, t12, t13, t14
 GuiControl, Hide, t%_vTStrtIndx%
}
WM_LBUTTONDOWN(wParam,lParam,msg,hwnd){ ; Move window when grabbed and dragged
 PostMessage, 0xA1, 2
 If MouseOver("72","246","192","272")
  Gosub, GuiClose
}
_fHlp(){
 Global t1, t2,t3, t4, t5, t6, t7, t15, t16, t10, t11, t12, t13, t14, t15, t16
 OnMessage(0x201,"WM_LBUTTONDOWN")
 OnMessage(0x200,"WM_MOUSEHOVER")
 OnMessage(0x18,"WM_SHOWWINDOW")
 Gui, Destroy
 Gui, Color, 0093E4, 333333 
 Gui, Add, Progress,x4 y4 w192 h272 cFFFFFF BackgroundFFFFFF, 100
 Gui, Add, Progress,x4 y4 w64 h272 c0093E4 BackgroundFFFFFF, 100
 Gui, Add, Text,+BackgroundTrans +Center xp+4 yp+4 w56 h30 cFFFFFF,Ctrl+Wheel Up
 Gui, Add, Text,+BackgroundTrans +Center xp+64 yp w124 h30 c0093E4,Volume Up - Slow
 Gui, Add, Text,+BackgroundTrans +Center xp-64 yp+34 w56 h30 cFFFFFF ,Ctrl+Wheel Down
 Gui, Add, Text,+BackgroundTrans +Center xp+64 yp w124 h30 c0093E4 ,Volume Down - Slow
 Gui, Add, Text,+BackgroundTrans +Center xp-64 yp+34 w56 h30 cFFFFFF ,Shift+Wheel Up
 Gui, Add, Text,+BackgroundTrans +Center xp+64 yp w124 h30 c0093E4 ,Volume Up - Fast
 Gui, Add, Text,+BackgroundTrans +Center xp-64 yp+34 w56 h30 cFFFFFF ,Shift+Wheel Down
 Gui, Add, Text,+BackgroundTrans +Center xp+64 yp w124 h30 c0093E4 ,Volume Down - Fast
 Gui, Add, Text,+BackgroundTrans +Center xp-64 yp+34 w56 h30 cFFFFFF ,Alt+Wheel Up
 Gui, Add, Text,+BackgroundTrans +Center xp+64 yp w124 h30 c0093E4 ,Mute Off
 Gui, Add, Text,+BackgroundTrans +Center xp-64 yp+34 w56 h30 cFFFFFF ,Alt+Wheel Down
 Gui, Add, Text,+BackgroundTrans +Center xp+64 yp w124 h30 c0093E4 ,Mute On
 Gui, Add, Text,+BackgroundTrans +Center xp-64 yp+34 w56 h30 cFFFFFF ,Ctrl+Click Wheel
 Gui, Add, Text,+BackgroundTrans +Center xp+64 yp w124 h30 c0093E4 ,This help screen
 _fMkHvrBttns("8","1","2","Volume Up - Slow")
 _fMkHvrBttns("42","3","4","Volume Down - Slow")
 _fMkHvrBttns("76","5","6","Volume Up - Fast")
 _fMkHvrBttns("110","7","8","Volume Down - Fast")
 _fMkHvrBttns("144","9","10","Mute Off")
 _fMkHvrBttns("178","11","12","Mute On")
 _fMkHvrBttns("212","13","14","This help screen") 
 Gui, Add, Progress, xp-64 yp+25 w56 h26 cFFFFFF BackgroundFFFFFF, 100
 Gui, Add, Text,+BackgroundTrans +Center xp yp w56 h30 c0093E4 ,Volume Revolver
 Gui, Add, Progress,x72 y246 w120 h26 c0093E4 Background0093E4 vt15 hwndt15, 100
 Gui, Font, s16 cWhite, Verdana
 Gui, Add, Text,+BackgroundTrans +Center xp yp w120 vt16, Exit
 Gui, -Caption +AlwaysOnTop 0x80880000
 Gui, Show,w200 h280, Volume Revolver Help
}
_fMkHvrBttns(_vY, _vVrA, _vVrB, _vMsg){
 Global t1, t2,t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14
 Gui, Add, Progress,x72 y%_vY% w120 h34 c0093E4 Background0093E4 Hidden vt%_vVrA%, 100
 Gui, Add, Text,+BackgroundTrans +Center xp yp+9 w124 h30 cFFFFFF Hidden vt%_vVrB%, %_vMsg%
}
_fTgMt(){
 SoundGet, _vMtSt, Master, Mute
 If (_vMtSt = "On")
  SoundSet, 0, , mute
 Else
  SoundSet, 1, , mute
}
_fGtSnd(_vttclss, _vType = 0){
 SetFormat, Float, 0
 SetTimer, gsTT, -750
 If (_vType = "1")
  {
   SoundGet, _vMt, Master, Mute
   _fIntTT(_vX, _vY)
   ToolTip, % "Mute is " _vMt,%_vX%,%_vY%,1
   _fCntrObj(_vX, _vY)
  }
 Else 
  {
   SoundGet, _vMstr, Master
   _fIntTT(_vX, _vY)
   ToolTip, % "Volume: " _vMstr,%_vX%,%_vY%,1 
   _fCntrObj(_vX, _vY)
  }
 SetFormat, Float, 0.000000
}
_fIntTT(ByRef _vX, ByRef _vY){
 _fGtScrn(_vScrnW, _vScrnH)
 _vX := (_vScrnW / 2)
 _vY := (_vScrnH / 2) 
}
_fGtScrn(ByRef _vScrnW, ByRef _vScrnH){
 SysGet, _vScrn, MonitorWorkArea
 _vScrnW := _vScrnRight - _vScrnLeft
 _vScrnH := _vScrnBottom - _vScrnTop
}
_fCntrObj(ByRef _vX, ByRef _vY, _vTt := "ahk_class tooltips_class32") {
 _fGtScrn(_vScrnW, _vScrnH)
 WinGetPos, , , _vGtTtX, _vGtTtY, %_vTt%
 _vX := (_vScrnW / 2) - (_vGtTtX / 2)
 _vY := (_vScrnH / 2) - (_vGtTtY / 2)
 WinMove, %_vTt%, , %_vX%, %_vY%
}
GuiEscape:
GuiClose:
 Gui, Destroy
Return
gsAppClose:
 ExitApp
        


Sunday, May 22, 2016

Pixel Grabber (coordinate and pixel color info at mouse position - utility written in AHK)

Pixel Grabber V1.0



If you are a graphic designer then you may be familiar with ColorPic or Gpic; for those of you who aren't familiar with those programs (or other alternatives) these are color picker  and swatch programs (Gpic can convert PS .ase to GIMP .gpl and vice versa) that are great for retrieving color and some window info at the mouse cursor.

There are quite a few decent alternatives out there, but I wanted something more tailored to my needs since not only do I do graphic design, but I also build lots of GUI's in AutoHotkey and so I wrote a utility that is great for graphic design, but also good for building AHK GUI's.

Pixel Grabber V1.0 is a small utility that retrieves coordinate and color information at the mouse cursor simply by holding the Contol key and left clicking (Ctrl+Left Click). For now the information retrieved is the Windows title (not all windows have names), the Screen (Desktop) and Client  (if exists) coordinates relative to the each, and the actual pixels color with the code and a preview of the color. All information is copied to the clipboard in subsequent order, but the clipboards contents can be cleared with a button.

Downloads

Copyright Ian Pride 2016 © This program is distributed under the terms of the GNU General Public License.

Your choice of just the portable executable or the zip package which inludes the executable, source code, and a copy of the license:

Source Script (needs AHK, use the exe to use without install)

; Name:   Pixel Grabber V1.0 
; Author: Lateralus138 (A.K.A Flux Apex A.K.A Ian Pride)
; Year: 2016
; Copyright Ian Pride 2016 © This program is distributed under the terms of the GNU General Public License.
; Email: faithnomoread@yahoo.com
; http://www.gnu.org/licenses/gpl-3.0.en.html
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program.  If not, see .
;
; Gets window and color information at pixel coordinate 
; with the hotkeys: Ctrl+LeftClick. Very useful for 
; graphic design or writing AutoHotkey GUIs. 
; 
OnMessage(0x20, "WM_SETCURSOR")
#SingleInstance, Force
Menu, Tray, NoStandard
Menu, Tray, Add, &Help, gsHlp
Menu, Tray, Add, My &Blog, gsMBlg 
Menu, Tray, Add
Menu, Tray, Add, E&xit, gsExt
_fGtMn()
GuiControl, Show, gsRstClp %But%
Return
;End auto-execute

;Hotkeys
+Esc::Reload
^LButton::_fGtInf(_vX, _vY,_vRgb,_vBgr, _vWx, _vWy, _vWt, _vWw, _vWh, _vXc, _vYc)
;Gosubs
gsMBlg:
 Run, "http://agnosticmicrocosm.blogspot.com/"
Return
gsHlp:
 MsgBox,64,Pixel Grabber Help, % "To use this simply hold Ctrl & left click the place you"
  . "`nwant the coordinates & color of. Coordinates & color" 
  . "`nwill be displayed & copied to your clipboard. Multiple" 
  . "`ninfo boxes can be left open and subsequent new" 
  . "`ncoordinates & colors will be added to the clipboard" 
  . "`nstack."
Return
gsHide:
 Gui, Cancel
Return
MainGuiEscape:
 Gosub, gsHide
Return
gsRstClp:
 clipboard =
Return

;Functions
MouseOver(_vXa, _vYa, _vXb, _vYb)
{
 MouseGetPos, _vPx, _vPy
 _vDtct := _vPx >= _vXa AND _vPx <= _vXb AND _vPy >= _vYa AND _vPy <= _vYb
 Return _vDtct
}
WM_SETCURSOR(){
 Loop
  {
   If MouseOver(0, 0, 250, 344) {
    If Not hCursor1 { 
      hCursor1 := DllCall("LoadCursor", "uint", 0, "uint", 32512)
     }
    DllCall("SetCursor", "uint", hCursor1)
    ;Return True
   } 
   If MouseOver(135, 164, 247, 186) Or MouseOver(135, 190, 247, 212) Or MouseOver(135, 216, 247, 238) Or MouseOver(135, 242, 247, 264) {
    If Not hCursor2 { 
      hCursor2 := DllCall("LoadCursor", "uint", 0, "uint", 32649)
     }
    DllCall("SetCursor", "uint", hCursor2)
    Return True
   }
   GuiControl, Show, gsHlp %But%
   Break
  }
 Return
}
WM_SETCURSOR2(){
 Loop
  {
   IfWinActive, Pixel Grabber Info 
   {
    If MouseOver(20, 81, 66, 129) Or  MouseOver(256, 99, 290, 114) {
     If Not hCursor2 { ;Make sure the cursor is already loaded 
       hCursor2 := DllCall("LoadCursor", "uint", 0, "uint", 32649)
      }
     DllCall("SetCursor", "uint", hCursor2)
     Return True ;Stop further processing
    }  
   }
  }
 Return
}

_fGtInf(ByRef _vX, ByRef _vY, ByRef _vRgb, ByRef _vBgr, ByRef _vWx, ByRef _vWy, ByRef _vWt, ByRef _vWw, ByRef  _vWh, ByRef _vXc, ByRef _vYc){
 OnMessage(0x20, "WM_SETCURSOR2")
 CoordMode, Mouse, Screen
 MouseGetPos, _vX, _vY
 MouseGetPos,,,_vWPn
 WinActivate, ahk_id %_vWPn%
 CoordMode, Mouse, Window
 MouseGetPos, _vXc, _vYc
 WinGetActiveStats, _vWt, _vWw, _vWh, _vWx, _vWy
 If (_vWx = "-5"){
  _vWx := "0"
  _vXc := _vXc - 5
 }
 If (_vWy = "-5"){
  _vWy := "0"
  _vYc := _vYc - 5
 }
 CoordMode, Pixel, Screen
 PixelGetColor, _vRgb , %_vX%, %_vY%,RGB
 PixelGetColor, _vBgr , %_vX%, %_vY%
 clipboard := clipboard "`nWindow Name: `n" _vWt "`nDesktop Relative:`nx" _vX " y" _vY "`nWindow Relative: `nx" _vXc " y" _vYc "`nColor at coordinate: `n" _vRgb "`n"
 Gui, New
 Gui, Add, Text, w300+BackgroundTrans, % "Active Window Name:`n" 
  . _vWt
  . "`n`nWindow upper left starting position: `nx: "
  . _vWx "        |     y: " _vWy 
  . "`n`nDesktop relative coordinates at mouse position:`nx: " 
  . _vX "        |     y: " _vY 
  . "`n`nWindow relative coordinates at mouse position:`nx: " 
  . _vXc "        |     y:" _vYc 
  . "`n`nCoordinates and color have been copied to your clipboard." 
 Gui, Add, Progress, xp+5 yp+186 w50 h50 c%_vRgb%,100
 StringReplace, _vRgb, _vRgb, 0x,
 Gui, Add, Text, +BackgroundTrans xp+60 yp+18, % "Color at mouse postion: " . _vRgb
 Gui, Add, Button, xp+175 yp-2 ggsHide, Close
 Gui, Show,w300 ,Pixel Grabber Info
 Return
}
WM_MOUSELEAVE(){
}
_fGtMn(){

 OnMessage(0x20, "WM_SETCURSOR")
 Gui, New
 Gui, Main: Default
 Gui, Font, s8, Cambria
 _fGrphx("125","0","66","100","125","125","EF7D1A","2","2")
 _fGrphx("0","125","66","100","125","125","EF7D1A","2","2")
 _fGrphx("0","0","66","100","125","125","7DA485","2","2")
 _fTxtBrdr("Pixel","16","0","EF7D1A","white","28")
 _fTxtBrdr("Grabber","100","0","7DA485","white","28")
 Gui, Font, s11, Cambria
 Gui, Main: Add, Progress, -Smooth Disabled cEF7D1A Background3F3F3F x135  y141  w112 h22, 100
 _fTxtBrdr2("Reset Clipboard","112","22", "gsRstClp","135","141","7DA485","White","11")
 Gui, Main: Add, Progress, -Smooth Disabled cEF7D1A Background3F3F3F x135  y167  w112 h22, 100
 _fTxtBrdr2("Help","112","22","gsHlp","135","167","7DA485","White","11")
 Gui, Main: Add, Progress, -Smooth Disabled cEF7D1A Background3F3F3F x135  y193  w112 h22, 100
 _fTxtBrdr2("My Blog","112","22","gsMBlg","135","193","7DA485","White","11")
 Gui, Main: Add, Progress, -Smooth Disabled cEF7D1A Background3F3F3F x135  y219  w112 h22, 100
 _fTxtBrdr2("Exit","112","22","gsExt","135","219","7DA485","White","11")
 Gui, Main: Show, w250 h250 Center, Pixel Grabber
 Return
}
_fGrphx(_vCntrX, _vCntrY, _vLp, _vLpWdth, _vWdth, _vHght, _vClr, _vIncrA, _vIncrB, _vBgClrb := "White"){
 Loop, %_vLp%
  { 
   Gui, Main: Add, Progress, -Smooth Disabled x%_vCntrX% y%_vCntrY% w%_vWdth% h%_vHght% Background%_vBgClrb% c%_vClr%, % _vLpWdth
   _vCntrX := _vCntrX + _vIncrA
   _vCntrY := _vCntrY + _vIncrB
  }
 Return
}
_fTxtBrdr(_vTxt, _vXb := "0", _vYb := "0", _vBgClr := "Black", _vClr := "White", _vTxtSz := "8"){
 Gui, Font, q5 s%_vTxtSz%, Cambria
 Gui, Main: Add, Text, +BackgroundTrans x%_vXb% y%_vYb% c%_vBgClr%, % _vTxt
 Gui, Main: Add, Text, +BackgroundTrans xp yp+2 c%_vBgClr%, % _vTxt
 Gui, Main: Add, Text, +BackgroundTrans xp+2 yp c%_vBgClr%, % _vTxt
 Gui, Main: Add, Text, +BackgroundTrans xp yp-2 c%_vBgClr%, % _vTxt
 Gui, Main: Add, Text, +BackgroundTrans xp-1 yp+1 c%_vClr%, % _vTxt
 Return
}
_fTxtBrdr2(_vTxt2, _vXw, _vYw, _vGs, _vXb2 := "0", _vYb2 := "0", _vBgClr2 := "Black", _vClr2 := "White", _vTxtSz2 := "8"){
 Gui, Font, q5 s%_vTxtSz2%, Cambria
 Gui, Main: Add, Text, +Center +BackgroundTrans x%_vXb2% y%_vYb2% w%_vXw% h%_vYw% c%_vBgClr2%, %_vTxt2%
 Gui, Main: Add, Text, +Center +BackgroundTrans xp yp+2 w%_vXw% h%_vYw% c%_vBgClr2%, % _vTxt2
 Gui, Main: Add, Text, +Center +BackgroundTrans xp+2 yp w%_vXw% h%_vYw% c%_vBgClr2%, % _vTxt2
 Gui, Main: Add, Text, +Center +BackgroundTrans xp yp-2 w%_vXw% h%_vYw% c%_vBgClr2%, % _vTxt2
 Gui, Main: Add, Text, +Center +BackgroundTrans xp-1 yp+1 w%_vXw% h%_vYw% c%_vClr2% g%_vGs%, % _vTxt2
 Return
}
GuiClose:
 Gui, Cancel
Return
gsExt:
MainGuiClose:
 SplashTextOn, 200, 22, ,% "Exiting Pixel Grabber!!!"
 Sleep 1500
 ExitApp