Sign in to follow this  
Followers 0
Milordzie

Problem with Pause script on start

10 posts in this topic

Hi i writed simple script and i can't find how to start script stoped :(

MsgBox ( 4096, "xxx" )
SoundPlay(@WindowsDir & "\media\Windows Ding.wav", 0)
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
While 1=1
ControlSend("xxx", "", "", "{1 DOWN}")
Sleep(3000)
WEnd
Func TogglePause()
SoundPlay(@WindowsDir & "\media\Heritage\Windows Error.wav", 0)
$Paused = Not $Paused
While $Paused
Sleep(0)
ToolTip('Script is "Paused"', 0, 0)
WEnd
ToolTip("")
EndFunc ;==>TogglePause

Share this post


Link to post
Share on other sites



Milordzie,

Welcome to the AutoIt forum. :)

Just call the TogglePause function as the script starts: ;)

Global $Paused = False ; Set the flag to False so it becomes True as you enter the function for the first time
HotKeySet("{PAUSE}", "TogglePause")

MsgBox(4096, "xxx", "xxx")
SoundPlay(@WindowsDir & "\media\Windows Ding.wav", 0)

; Call the function to pause the script initially
TogglePause()

While 1
    ;ControlSend("xxx", "", "", "{1 DOWN}")
    MsgBox(0, "hi", "Sending")
    Sleep(3000)
WEnd

Func TogglePause()
    SoundPlay(@WindowsDir & "\media\Windows Error.wav", 0)
    $Paused = Not $Paused
    While $Paused
        Sleep(10) ; 10 is the minimum sleep value
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

And please forgive me for being suspicious, but whenever I see "xxx" titles I always suggest the the OP reads the Forum rules (there is also a link at bottom right of each page) before they post again. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

thx but when i try to run your code i got errors

$Paused = Not $Paused

$Paused = Not ^ ERROR

and i use sleep 0 for pause script to next click of pause on keyboard.

Share this post


Link to post
Share on other sites

Milordzie,

Are you sure you have the Global $Paused = False at the top of the script? :huh:

And as I said in the script, do not use Sleep(0). The minimum Sleep possible is around about 10ms - this is a system limitation, not an AutoIt one - and Sleep(0) is a special case which just gives up the next possible timeslice. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hmm i feel like in "back to the future" ;) scrpit is starting without errors but not paused - just start spam key "1" when i click pause on keyboard i can turn on/off it.

But how i can start script stoped :(

SoundPlay(@WindowsDir & "\media\Windows Ding.wav", 0)
Global $Paused = False
HotKeySet("{PAUSE}", "TogglePause")
While 1=1
ControlSend("clientI", "", "", "{1 DOWN}")
Sleep(3000)
WEnd
Func TogglePause()
SoundPlay(@WindowsDir & "\media\Heritage\Windows Error.wav", 0)
$Paused = Not $Paused
While $Paused
Sleep(100000000)
ToolTip('Script is "Paused"', 0, 0)
WEnd
ToolTip("")
EndFunc ;==>TogglePause
Edited by Milordzie

Share this post


Link to post
Share on other sites

Milordzie,

Did you actually look at the script I posted above - it shows you exactiy how to do it. You are missing a vital line in the script you have just posted. ;)

; Call the function to pause the script initially
TogglePause()

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Thx man a lot. its work. Sorry for my stiupid questions ;)

but i have few more about Koda FormDesinger.

I maked simple window to:

chose key for:

controlsend

ControlSend("clientI", "", "", "{1 DOWN}")

i want put here something like $label2

and for set time of sleep in while

Sleep(3000)

and i hope last question when i run GUI my inputs are hidden i must move muse on window to see them

#include 
#include 
#include 
#include 
#include 
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Form1", 637, 334, 192, 124)
$Czas = GUICtrlCreateInput("Czas", 464, 104, 121, 21)
$Combo1 = GUICtrlCreateCombo("Klawisz", 464, 48, 169, 25)
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|F1|F2|F3|F4|F5|F6|F7|F8|F9")
$Label1 = GUICtrlCreateLabel("Klawisz", 464, 24, 39, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label2 = GUICtrlCreateLabel("Czas w mili sekundach", 464, 80, 111, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetState(-1, $GUI_DISABLE)
$Pic1 = GUICtrlCreatePic("C:\Users\Exmple\Downloads\08a.jpg", -8, -8, 644, 340)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Milordzie,

I know nothing about Koda as I do not use it, sorry.

As to the "hiding" inputs - you need to disable the pic control (GUICtrlSetState($Pic1, $GUI_DISABLE)) when you use it as a background. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Something like this? I don't really understand your english

$label2 = "{1 DOWN}"
ControlSend("clientI","","",$label2)
;Sleep
$label3 = 3000
Sleep($label3)
Edited by ileandros

I feel nothing.It feels great.

Share this post


Link to post
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
Sign in to follow this  
Followers 0