Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Turning Off and On Switch...


  • Please log in to reply
16 replies to this topic
smyzzyx
  • Members
  • 6 posts
  • Last active: Apr 05 2013 12:05 PM
  • Joined: 29 Mar 2013

Hi to all,

 

       Sorry about this, its my first post XD. I was searching for an on and off switch for a ahk and i cant find anything. Also to add, ON and OFF is the same with suspend? XD just asking. 

 

       Btw about the on and off switch, for example i have an ahk and i want to add some on and off switch to turn it on and off, THANKS



JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013

On and off can mean any number of different things to different people.
To turn a script "off" the simplest thing you can do is add this line to your script

Esc::ExitApp

This will stop your script in its tracks simply by pressing the esc key. Turning it back on will require you to run the script again
To start and stop your script but not unload it you could add a key like this...

!Esc::Pause, Toggle

This will pause your script and restart it from where it left off. So as you can see, On and off can mean different things depending on what you want to turn off and on...


Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.


smyzzyx
  • Members
  • 6 posts
  • Last active: Apr 05 2013 12:05 PM
  • Joined: 29 Mar 2013

i mean,,, suspend and unsuspend the hot key xD



JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013

In that case put Suspend On right after the hotkey Identifier and Suspend Off just before the Return from the hotkey subroutine -- like so

!k:: ;<-- alt k sample hotkey
Suspend On
Msgbox, You pressed the Alt-k hotkey
Suspend Off
Return

Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.


smyzzyx
  • Members
  • 6 posts
  • Last active: Apr 05 2013 12:05 PM
  • Joined: 29 Mar 2013

hmm... im a little bit confused on how to use it... sorry about this, but a button that when i press it suspends the codes then when i press it back turns off suspend xD

 

but let me give you a sample of my code that i need to put a suspend on and off button...

 

 

btw thanks for the infos...

 

 
$A::
loop, 5
{
send, {A}
sleep, .30 
MouseClick, Left
}
return


JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013
Something like this perhaps?
$A::
loop, 5
{
send, {A}
sleep, .30 
MouseClick, Left
}
return

^!s::
   Suspend, Permit
   SusToggle := !SusToggle
   If (SusToggle)
   {   Suspend, On
   }
   Else
   {   Suspend Off
   }
   Return

Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.


JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013

or... even shorter

^!s::
Suspend, Permit
Suspend, Toggle
Return

Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.


smyzzyx
  • Members
  • 6 posts
  • Last active: Apr 05 2013 12:05 PM
  • Joined: 29 Mar 2013

Something like this perhaps?

$A::
loop, 5
{
send, {A}
sleep, .30 
MouseClick, Left
}
return

^!s::
   Suspend, Permit
   SusToggle := !SusToggle
   If (SusToggle)
   {   Suspend, On
   }
   Else
   {   Suspend Off
   }
   Return

can you please tell me what does " ^!s:: " stands for? ^_^ im new with this AHK prog. Please specify and Thanks ^_^



smyzzyx
  • Members
  • 6 posts
  • Last active: Apr 05 2013 12:05 PM
  • Joined: 29 Mar 2013

i got it now thanks ^_^



shaneags
  • Members
  • 16 posts
  • Last active: Aug 11 2015 10:00 AM
  • Joined: 04 Mar 2015

hi All

 

can I add

 

Suspend On
Tab
Suspend Off
Return

 

to my script to turn it on and off easy?

 

thx

Shane

 

i'm very  new to coding so plz be gentle lol



Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013

hi All

 

can I add

 

Suspend On
Tab
Suspend Off
Return

 

to my script to turn it on and off easy?

 

thx

Shane

 

i'm very  new to coding so plz be gentle lol

 

If you want to use Tab as a hotkey to suspend/unsuspend your script you could use this:

Tab::Suspend, Toggle

This will toggle suspend on / off.

Since its one line there is no need to put a return for the hotkey.



shaneags
  • Members
  • 16 posts
  • Last active: Aug 11 2015 10:00 AM
  • Joined: 04 Mar 2015

i found a problem with my code as it's

 

Rbutton::space
Lbutton::up

Suspend On
Tab::Suspend, Toggle
Suspend Off

Esc::ExitApp

 

i use a on screen keyboard because i am a quadriplegic can't move any limbs

once I turn my script on i can't click any thing is there another way I can suspend it ? maybe move cursor to top left corner of screen?



Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013
Rbutton::space

~Lbutton::up

Tab::Suspend, Toggle

Esc::ExitApp

Try it like this.(basicly you have 4 hotkeys)

 

Added ~ prefix to the LButton hotkey to allow normal usage so you can still click with it.

 

Tab will toggle the suspending.



shaneags
  • Members
  • 16 posts
  • Last active: Aug 11 2015 10:00 AM
  • Joined: 04 Mar 2015

thx so much works a treat :)



onra
  • New members
  • 2 posts
  • Last active: Jul 17 2015 03:49 PM
  • Joined: 15 Jul 2015

can anyone help me with thisone?

 

#InstallKeybdHook
#Persistent
#HotkeyInterval,100
#NoEnv
SetKeyDelay, –1
SetTitleMatchMode, 2 ; Makes matching the titles easier
SendMode Input
SetWorkingDir %A_ScriptDir%
MButton::
{
WinHide, Opera
Return
}
F7::
{
DetectHiddenWindows, On
WinShow, Opera
Return
}
 
 
but i want to click the mbutton once to hide and then again to show up. how can i do this?