Jump to content

Toggle Key Help!


Recommended Posts

Is there a way to make a toggle key to pause your script? I have a script that has "HotKeySet" keys that when I type in B1 (on the keyboard) it will preform a function. I want to have the ability of hitting a key (ex. TAB) and have it pause the script. This way I can type B1 which out it preforming that function. Then I can hit TAB again and it will resume the script. 

I have tried a few Toggle scripts and they have not worked. I looked in the Help file and saw one for PAUSE but my laptop does not have the PAUSE key. Please help!

Thanks

Link to comment
Share on other sites

What have you tried so far, so we're not rehashing things that won't work for you?

On the other hand, there's probably 100 different examples of ways to pause a script on here if you do a search for it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Here is my code that I have put together:

#include <HotString.au3>
#include <Misc.au3>
Global $Paused = False ;set var top of script
HotKeySet("{ESC}", "TogglePause") ;top of script
;HotKeySet("{ESC}", "Terminate")


;############################################################################################
                        
;############################################################################################
HotStringSet("{Ctrl}lod1{Left}", "LOD01")
    HotStringSet ("{Ctrl}l1{Left}", "LOD01")

HotStringSet("{Ctrl}lod2{Left}", "LOD02")
    HotStringSet ("{Ctrl}l2{Left}", "LOD02")

HotStringSet("{Ctrl}vn1{Left}", "VN01")
    HotStringSet ("{Ctrl}v1{Left}", "VN01")

HotStringSet("{Ctrl}vn2{Left}", "VN02")
    HotStringSet ("{Ctrl}v2{Left}", "VN02")


Func TogglePause() ; anywhere in script
$Paused = Not $Paused ; change the state of the var
While $Paused
  Sleep(100)
WEnd
EndFunc

While 1
    Sleep(100)
WEnd

Func LOD01()
Run ("C:\Program Files (x86)\Radmin Viewer 3\Radmin.exe /connect:hostname:4899")
EndFunc

Func LOD02()
Run ("C:\Program Files (x86)\Radmin Viewer 3\Radmin.exe /connect:hostname:4899")
Run ("C:\Program Files (x86)\Radmin Viewer 3\Radmin.exe /connect:hostname:4899")
EndFunc

Func VN01()
Run ("C:\Program Files (x86)\Radmin Viewer 3\Radmin.exe /connect:hostname:4899")
EndFunc

Func VN02()
Run ("C:\Program Files (x86)\Radmin Viewer 3\Radmin.exe /connect:hostname:4899")

EndFunc

Here is the code I am using to try and pause the script: 

Global $Paused = False ;set var top of script
HotKeySet("{PAUSE}", "TogglePause") ;top of script
Func TogglePause() ; anywhere in script
$Paused = Not $Paused ; change the state of the var
While $Paused
  Sleep(100)
WEnd
EndFunc
Edited by swstrau118
Link to comment
Share on other sites

The problem is that HotString isn't going to get paused from looking at the code for it, it's working just like a HotKey will, just with more options. You'd need to deregister the hotstrings as you pause the script, and then reregister them as you unpause it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

The problem is that HotString isn't going to get paused from looking at the code for it, it's working just like a HotKey will, just with more options. You'd need to deregister the hotstrings as you pause the script, and then reregister them as you unpause it.

How can you deregister then re-register? 

Link to comment
Share on other sites

I would guess you'd do it the same way you would do it with a HotKey, set the HotString to a blank function. But you'd have to try it to see if it works as I've never used the functions before.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

 

I understand what the problem at the moment you are facing with _IsPressed (there is a solution though)
but...

I still suspect you are breaking the Forum Rules (Game Automation). Can you now please tell which application are you automating. Without a specific application automation is useless.

Regards  :)

I'm a little late in this topic however, I am running into the same issue when trying to pause my script. I am only using one script and this script is using HotKeys that I can type that will remote into a computer. However, I can't get my script to pause and unpause. That way I can hit B1 on my computer and it will not do anything, if paused. If not paused it will open up a remote desktop station.

Please help!

Here's my code:

Here is my code that I have put together:
#include <HotString.au3>
#include <Misc.au3>
Global $Paused = False ;set var top of script
HotKeySet("{ESC}", "TogglePause") ;top of script
;HotKeySet("{ESC}", "Terminate")


;############################################################################################
                        
;############################################################################################
HotStringSet("{Ctrl}lod1{Left}", "LOD01")
    HotStringSet ("{Ctrl}l1{Left}", "LOD01")

HotStringSet("{Ctrl}lod2{Left}", "LOD02")
    HotStringSet ("{Ctrl}l2{Left}", "LOD02")

HotStringSet("{Ctrl}vn1{Left}", "VN01")
    HotStringSet ("{Ctrl}v1{Left}", "VN01")

HotStringSet("{Ctrl}vn2{Left}", "VN02")
    HotStringSet ("{Ctrl}v2{Left}", "VN02")


Func TogglePause() ; anywhere in script
$Paused = Not $Paused ; change the state of the var
While $Paused
  Sleep(100)
WEnd
EndFunc

While 1
    Sleep(100)
WEnd

Func LOD01()
Run ("C:\Program Files (x86)\Radmin Viewer 3\Radmin.exe /connect:hostname:4899")
EndFunc

Func LOD02()
Run ("C:\Program Files (x86)\Radmin Viewer 3\Radmin.exe /connect:hostname:4899")
Run ("C:\Program Files (x86)\Radmin Viewer 3\Radmin.exe /connect:hostname:4899")
EndFunc

Func VN01()
Run ("C:\Program Files (x86)\Radmin Viewer 3\Radmin.exe /connect:hostname:4899")
EndFunc

Func VN02()
Run ("C:\Program Files (x86)\Radmin Viewer 3\Radmin.exe /connect:hostname:4899")

EndFunc

Here is the pause function I am trying to use:

Global $Paused = False ;set var top of script
HotKeySet("{PAUSE}", "TogglePause") ;top of script
Func TogglePause() ; anywhere in script
$Paused = Not $Paused ; change the state of the var
While $Paused
  Sleep(100)
WEnd
EndFunc
Edited by swstrau118
Link to comment
Share on other sites

swstrau118

You're not even going to try what I suggested in your other thread? Make a little effort rather than resurrecting posts that have nothing to do with your problem.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

^

|_______Help File

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

swstrau118,

One thread at a time please. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...