Jump to content

Advice for a script I made


Recommended Posts

After reading and exploring around I decided to attempt to make my first script. Based on other scripts I have come across, I wrote a basic HotKetSet Script that would assign a hotkey to send key strokes. The initial problem I had was the repetitive keystrokes. After I use the hotkey it would repeatedly send the keystorkes until I terminate the script. So I figure I add a line where it would send the TogglePause right after the keystroke so it would send it once then stop. I'm just wondering if this is the proper way to do this.

Global $Paused
HotKeySet("{F9}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!1", "TogglePause1");Shift-Atl-1
HotKeySet("+!d", "ShowMessage");Shift-Alt-d


;;;; Body of program would go here;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        Send("Test")
        Send("{F9}")
        
        ToolTip('Script is "Paused"',0,0)
    WEnd
EndFunc
;;;;;;;;;
Func Terminate()
    Exit 0
EndFunc

;;;;;;;;;

Func TogglePause1()
    $Paused = NOT $Paused
    While $Paused
        Send("hello")
        Send("{F9}")
        
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc
;;;;;;;;;
Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

This is my first attempt to write something :">

I appreciate all the input :)

Edited by Jason
Link to comment
Share on other sites

...I'm just wondering if this is the proper way to do this...

Before I could comment on that, I would need to know what "this" is. :-)

What are you wanting to do with your script? Do you want your script to run/idle all of the time - waiting for you to press a key before the script does something beside idle? Or do you want it to do a series of things and then exit?

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Global $Paused
HotKeySet("{F9}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!1", "TogglePause1");Shift-Atl-1
HotKeySet("+!d", "ShowMessage");Shift-Alt-d
;;;; Body of program would go here;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    Send("Test")
    Send("{F9}")
    While $Paused   
         ToolTip('Script is "Paused"',0,0)
         Sleep(15);<----you might want this to slow the script down, adjust as needed
    WEnd
EndFunc
;;;;;;;;;
Func Terminate()
    Exit 0
EndFunc

;;;;;;;;;

Func TogglePause1()
    $Paused = NOT $Paused
    Send("hello")
    Send("{F9}")
    While $Paused   
         ToolTip('Script is "Paused"',0,0)
         Sleep(15);<----you might want this to slow the script down, adjust as needed
    WEnd
    ToolTip("")
EndFunc
;;;;;;;;;
Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc
Try this, the other way you had your keystrokes within the While loop and so it kept sending them over and over, this way it will only send them 1 time for each time you enter the function.

Nomad

Edited by Nomad
Link to comment
Share on other sites

Before I could comment on that, I would need to know what "this" is. :-)

What are you wanting to do with your script? Do you want your script to run/idle all of the time - waiting for you to press a key before the script does something beside idle? Or do you want it to do a series of things and then exit?

Yes it is idle untill I use an actual hotkey, but I will terminate it myself.

Thanks for the input guys I knew that ToolTip line had a purpose. Much appreciated :D

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...