Show Timer, Continue After 10 seconds Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
RoseCode
Posts: 47
Joined: 24 Jan 2015, 15:34

Show Timer, Continue After 10 seconds

13 Apr 2018, 01:34

How can I pause the script while my countdown timer displays? Sounds easy. I thought so too! This Script pulls out even or odd lines from the clipboard. I want the user to know his clipboard has been restored after about 10 seconds. This gives him time to paste the odd lines, before the original clipboard is restored. I have a timer that displays a countdown, but nothing I've tried can stop the script during those 10 seconds and continue, without breaking the timer display in some way.

Ideas? Thank you!

By the way, if using SciTE hit your right alt key to save and refresh this script for quick testing!

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance, Force
#InstallKeybdHook
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2
return

F3::
; This extracts even or odd lines from clipboard
EvenOrOddLines=
ClipboardStorage := CouldBeClipboard
;myvar := Clipboard
myvar = 
(
1
2
3
4
5
6
7
)

Gui 3:default
Gui Add, Picture, x10 y20 w300 h300, %A_ScriptDir%\images\logo.jpg
Gui, Add, Text, yp+40, Extract Even and Odd LInes
Gui, Add, Edit, yp+40 vSomeVariableOne, This is an Unused Edit Box
Gui, Add, Text, yp+40, This is the Second Text Line
Gui, Add, Edit, yp+40 vSomeVariableTwo, Second Unused Edit Box
Gui, Add, Text, yp+40, Third Line of Text
Gui, Add, Edit, yp+40 vSomeVariableThree, Third Unused Edit Box
Gui, Add, Text, yp+40, Fourth Line of Text
Gui Add, Edit, yp+40  vSomeVariableFour, Another EditBox String
Gui, Add, Button, Default gOK1, Extract Odd Lines
Gui, Add, Button, Default gOK2, Extract Even Lines
Gui, Add, Button, Default gOK3, Unused Button

Gui Show, , Window

Return

OK1: ; Odd Lines
Gui, Submit
sleep 400
Loop, parse, myvar, `n
EvenOrOddLines .= Mod( A_Index,2 ) ?  A_LoopField "`n" : ""
MsgBox, You Have 7 seconds after clicking OK to paste these lines somewhere `n Before Clipboard is restored `n `n %EvenOrOddLines%
Gui, Destroy
Clipboard := EvenOrOddLines
;sleep 8000
SetTimer, Timed, 10
Clipboard := ClipboardStorage
MsgBox Your Clipboard has been restored to this: `n %ClipboardStorage%

return

Timed:
++curTime
timed := round(CurTime/3, 1)

if timed < 10 
{
	ToolTip, %timed%
sleep 300
	tooltip
}


;sleep 7000  breaks everything
return

OK2: ; Even Lines
Gui, Submit
sleep 400
Loop, parse, myvar, `n
EvenOrOddLines .= Mod( A_Index,2 ) ? "" : A_LoopField "`n"
MsgBox, You Have 7 seconds after clicking OK to paste these lines somewhere `n Before Clipboard is restored `n `n %EvenOrOddLines%
Gui, Destroy
Clipboard := EvenOrOddLines
sleep 7000
Clipboard := ClipboardStorage
return

OK3: ; Unused
Gui, Submit
sleep 400
MsgBox something
Gui, Destroy
return

3GuiEscape:
3GuiClose:
;MsgBox % vText1 "'n" vText2 vText3 vRadioState
MsgBox Okay - Doing Nothing
Gui, Destroy
return



;======================= STANDARD AUTOHOTKEY FOOTER
RAlt::
IfWinActive, SciTE
{
sendinput ^s
sleep 300
}
IfWinExist, DebugView
{
	;MsgBox hello

ControlSend, , ^x, DebugView
sleep 300
}

Reload
return


^Esc::
exitapp
return


BIGEXIT:
	exit
Why Vegan? Because...because..I mean, have you ever seen a Lamb play? http://VeganGod.org :-)
User avatar
noname
Posts: 509
Joined: 19 Nov 2013, 09:15

Re: Show Timer, Continue After 10 seconds  Topic is solved

13 Apr 2018, 05:50

Try a "settimer" and move the restore clipboard to the timer label ?

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance, Force
#InstallKeybdHook
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2
return

F3::
timed:=0
; This extracts even or odd lines from clipboard
EvenOrOddLines=
ClipboardStorage := "old clipboard"
;myvar := Clipboard
myvar = 
(
1
2
3
4
5
6
7
)

Gui 3:default
Gui Add, Picture, x10 y20 w300 h300, %A_ScriptDir%\images\logo.jpg
Gui, Add, Text, yp+40, Extract Even and Odd LInes
Gui, Add, Edit, yp+40 vSomeVariableOne, This is an Unused Edit Box
Gui, Add, Text, yp+40, This is the Second Text Line
Gui, Add, Edit, yp+40 vSomeVariableTwo, Second Unused Edit Box
Gui, Add, Text, yp+40, Third Line of Text
Gui, Add, Edit, yp+40 vSomeVariableThree, Third Unused Edit Box
Gui, Add, Text, yp+40, Fourth Line of Text
Gui Add, Edit, yp+40  vSomeVariableFour, Another EditBox String
Gui, Add, Button, Default gOK1, Extract Odd Lines
Gui, Add, Button, Default gOK2, Extract Even Lines
Gui, Add, Button, Default gOK3, Unused Button

Gui Show, , Window

Return



OK1: ; Odd Lines
Gui, Submit
sleep 400
Loop, parse, myvar, `n
EvenOrOddLines .= Mod( A_Index,2 ) ?  A_LoopField "`n" : ""
MsgBox, You Have 7 seconds after clicking OK to paste these lines somewhere `n Before Clipboard is restored `n `n%EvenOrOddLines%
Gui, Destroy
Clipboard := EvenOrOddLines
SetTimer, Timed, -10  ; to update immediately 
SetTimer, Timed, 1000
return

Timed:
timed ++
if (timed <= 10 )
  ToolTip, % 10 - timed
else
  {
  tooltip 
  Clipboard := ClipboardStorage
  MsgBox Your Clipboard has been restored to this: `n%ClipboardStorage%
  timed:=0
  SetTimer, timed,off
  exit
  }
return

OK2: ; Even Lines
Gui, Submit
sleep 400
Loop, parse, myvar, `n
EvenOrOddLines .= Mod( A_Index,2 ) ? "" : A_LoopField "`n"
MsgBox, You Have 7 seconds after clicking OK to paste these lines somewhere `n Before Clipboard is restored `n `n %EvenOrOddLines%
Gui, Destroy
Clipboard := EvenOrOddLines
SetTimer, Timed, -10
SetTimer, Timed, 1000
return

OK3: ; Unused
Gui, Submit
sleep 400
MsgBox something
Gui, Destroy
return

3GuiEscape:
3GuiClose:
;MsgBox % vText1 "'n" vText2 vText3 vRadioState
MsgBox Okay - Doing Nothing
Gui, Destroy
return



;======================= STANDARD AUTOHOTKEY FOOTER
RAlt::
IfWinActive, SciTE
{
sendinput ^s
sleep 300
}
IfWinExist, DebugView
{
	;MsgBox hello

ControlSend, , ^x, DebugView
sleep 300
}

Reload
return


^Esc::
exitapp
return


BIGEXIT:
	exit
soundcloud.com/user-32706894
User avatar
RoseCode
Posts: 47
Joined: 24 Jan 2015, 15:34

Re: Show Timer, Continue After 10 seconds

13 Apr 2018, 13:47

The day pure gold ceases to flow from your code NoName, will be the end of the world, which should be ruled by the spirits captured in your new avatar in whose eyes is tolerance and later, VICTORY over every shadow!

Your code solution is artful and unexpected: I would never have worked that out like that, especially the Timed, -10 immediately preceding the Timed, 1000. There's more than meets the eye here :-)

It's BEAUTIFUL! Thank you, again, NoName.
Why Vegan? Because...because..I mean, have you ever seen a Lamb play? http://VeganGod.org :-)
User avatar
RoseCode
Posts: 47
Joined: 24 Jan 2015, 15:34

Re: Show Timer, Continue After 10 seconds

14 Apr 2018, 01:00

I can't get past the power of your avatar! I tried TinEye to look it up but no luck. Did you paint this? I would love to see the full print Noname.
Why Vegan? Because...because..I mean, have you ever seen a Lamb play? http://VeganGod.org :-)
User avatar
noname
Posts: 509
Joined: 19 Nov 2013, 09:15

Re: Show Timer, Continue After 10 seconds

14 Apr 2018, 06:52

ひみつ !! I send the link to your inbox .

If you want to create a circular avatar you can use this:
https://autohotkey.com/boards/viewtopic.php?t=29825

I had the image ( grayscaled ) as wallpaper when i wrote the code so it was my first test ( with a mesmerizing result.....) .

Thanks for another example of your colourfull unique writing style !
soundcloud.com/user-32706894
User avatar
RoseCode
Posts: 47
Joined: 24 Jan 2015, 15:34

Re: Show Timer, Continue After 10 seconds

19 Apr 2018, 01:55

Noname is, of course, my favorite persona on the internet and many are saying, the world's best coder. Thank you Noname.
Why Vegan? Because...because..I mean, have you ever seen a Lamb play? http://VeganGod.org :-)

Return to “Ask For Help”

Who is online

Users browsing this forum: MrGrayline, pythonker, QuestVBA, ulraf and 195 guests