DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: IDEA : Start-Quit Program w/Single Key?  (Read 7,913 times)

MourningStar

  • Participant
  • Joined in 2013
  • *
  • Posts: 11
IDEA : Start-Quit Program w/Single Key?
« on: August 16, 2013, 07:40 PM »
I request help to configure a keyboard key to run and quit a task. For example a desktop clock, calendar, cpu meter, etc (app, gadget, pgm etc,). It should function as follows :



key press-hold = app (e.g. clock) appears (executes a run command?)

key release = app (e.g. clock) disappears (executes a exit/quit command?)



In the clock example, I would like to simply press-hold a key and a custom desktop clock appears (program start) and then disappears (program quit) when I release the key. Defining many tasks in this manner would prevent the need for having multiple tasks running and eating cpu/ram when occasionally 'checking in' super-quickly on something is all that's required.



-thnx

TaoPhoenix

  • 0 - 60 ... then back to 0 again!
  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 4,642
    • Participated in NANY Challenge Three Times
Re: IDEA : Start-Quit Program w/Single Key?
« Reply #1 on: August 16, 2013, 10:02 PM »

With a slight modification, something like this can kill an existing service.

AppleMobileDeviceSupport service prevents my comp from rebooting!

So rather than fish for it in Task Manager, some random defined key could kill it.
Use attachthumb=# to show an attached image as an expandable thumbnail, or attach=# to show full size. (With Brackets)

BigVent

  • Member
  • Joined in 2013
  • **
  • Posts: 36
    • Participated in NANY Challenge Once
Re: IDEA : Start-Quit Program w/Single Key?
« Reply #2 on: August 19, 2013, 05:53 PM »


Code: (autohotkey)
#SingleInstance, force

;//change hotkey to your desired key
Numpad5::	;//Number Pad 5 hotkey
{
		
	while GetKeyState("Numpad5")	;//while Number Pad 5 key is held
	{
		Traytip, Key Is Held, Your hotkey is being held., ,1
		
		IfWinExist, Date and Time Properties	;//Windows clock & date
			Continue
		IfWinNotExist, Date and Time Properties
			run, Timedate.cpl
	}
	Traytip

		WinClose, Date and Time Properties	;//upon release close the window
}
Return

ESC & Numpad5::	;//esc & Number Pad 5 will exit the script
	Critical
	ExitApp
Return
~BigVent

MourningStar

  • Participant
  • Joined in 2013
  • *
  • Posts: 11
Re: IDEA : Start-Quit Program w/Single Key?
« Reply #3 on: August 21, 2013, 12:02 AM »
^
thank you BigVent - I tied your script, unfortunately the date-time window does not close upon key release.

BigVent

  • Member
  • Joined in 2013
  • **
  • Posts: 36
    • Participated in NANY Challenge Once
Re: IDEA : Start-Quit Program w/Single Key?
« Reply #4 on: August 21, 2013, 02:49 PM »
Perhaps I should've clarified that this was an example that can be modified to suit your needs & I only tested it on my XP box, sorry about that.
Anyway, I've made an adjustment to the window & it should work as desired.  (e.g. "Date and Time Properties" on XP & "Date and Time" on > Vista)

Tested on Win XP, Vista, & 7


Enjoy!

Code: (autohotkey)
    #SingleInstance, force
    SetTitleMatchMode, 2
	
    ;//change hotkey to your desired key
    Numpad5:: ;//Number Pad 5 hotkey
    {
     
		while GetKeyState("Numpad5")	;//while Number Pad 5 key is held
		{
			Traytip, Key Is Held, Your hotkey is being held., ,1
     
			IfWinExist, Date and Time ;//Windows clock & date
				Continue
			IfWinNotExist, Date and Time
				run, Timedate.cpl
		}

		sleep, 3000    ;//small delay
		Traytip
     
		WinClose, Date and Time ;//upon release close the window
    }
    Return
     
    ESC & Numpad5:: ;//esc & Number Pad 5 will exit the script
		Critical
		ExitApp
    Return
~BigVent
« Last Edit: August 21, 2013, 02:55 PM by BigVent »

MourningStar

  • Participant
  • Joined in 2013
  • *
  • Posts: 11
Re: IDEA : Start-Quit Program w/Single Key?
« Reply #5 on: August 22, 2013, 03:50 AM »
^
:up:
thnx!

Original address: https://www.donationcoder.com/forum/index.php?topic=35808.0