Jump to content

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

Toggle script on/off -can't get it to work.


  • Please log in to reply
3 replies to this topic
Vashbul
  • Members
  • 3 posts
  • Last active: Oct 24 2015 11:11 PM
  • Joined: 23 Oct 2015

Just installed Autohotkey and wrote a simple script:

 

Z::
Send, gdcvnc{ENTER}
Return
 
so when I press "Z" it will type the string "gdcvnc" (a password for an application that shouldn't need one - I couldn't figure out how to disable it so this was the next best solution).
 
It works, but I can't get it to quit when I don't need it.
 
I searched this forum, and lots of people want the same thing, a way to pause/unpause a script. One solution suggested was this:
 
f12::
Pause
Suspend
return
 
But it doesn't work for me. 
This is what I did: right click the AHK icon on my desktop, choose "Edit script", a Notepad window pops up with this in it:
 
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
Z::
Send, gdcvnc{ENTER}
Return 
 
I add the suggested addition to it so it looks like this:
 
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
Z::
Send, gdcvnc{ENTER}
Return
 
f12::
Pause
Suspend
return
 
I hit "save". Should work, but when I test it I still get "gdcvnc".
 
The AHK tutorial is too confusing and I don't know what else to do. Where am I going wrong here?

 



Masonjar13
  • Members
  • 1517 posts
  • Last active:
  • Joined: 16 Sep 2012

The Pause is where you're going wrong. It's pausing the current thread, which then never reaches Suspend. Hotkeys create new threads, therefore the pause does nothing. Suspend disallows hotkeys from running, with several exceptions (see documentation). Simply remove the pause.


OS: Windows 7 Ultimate / Windows 8.1 Pro | Editor: Notepad++


Vashbul
  • Members
  • 3 posts
  • Last active: Oct 24 2015 11:11 PM
  • Joined: 23 Oct 2015

Didn't work.

 

Is there something I need to do besides save the edited script?

 

I tried this, as a test: went to "Edit" and changed my original script

 
Z::
Send, gdcvnc{ENTER}
Return
 
to this:
 
Z::
Send, Z{ENTER}
Return
 
then saved. But pressing the hotkey (Z) still prints the string (gdcvnc).


Vashbul
  • Members
  • 3 posts
  • Last active: Oct 24 2015 11:11 PM
  • Joined: 23 Oct 2015

Um, okay - I figured it out, you have to right click on the script icon, select "Run script". It works now.