hjf

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