Jump to content

Recommended Posts

Posted

; Press Esc to terminate script, Pause/Break to "Copy/Paste"

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

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

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    Send ("^c")
    WEnd
    ToolTip("")
    Send (ClipGet())
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

You highlight text and press "Pause" to copy it to clipboard. Pressing "Pause" again should toggle function and pastes the text.

Works fine except that the text gets pasted twice. Why?

PS: eventually I would like to use the middle button click instead of the "Pause" key to copy/paste.

Can anyone help? Thanks.

  • Moderators
Posted
; Press Esc to terminate script, Pause/Break to "Copy/Paste"

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

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

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    Send ("^c")
    WEnd
    ToolTip("")
    Send (ClipGet())
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc
oÝ÷ Ù.(!(!¶×±µ©Ý¦·¬²«¨´ö®±ê®¢ÛhrrÛhrX©n«tú޲ȧ«¨´ö®±ê®¢Ö j)ì¥vÚ Wºw-ÚÚZ²×¬¶­{V¢¹,~)Þ{¦ÛajÛaz×±¶­²¬µçmÂ'ZIëÞÛÂ¥vX¤zÚ.±ëazhvWºÛhÉbrH§²×víꮢÓںǪºd{+hrrþ¬µà©ò¢w¡zZS©ä³ú®¢×¢çhm±ëZrÝØ¨ú+¶zwr¢ç%Éjë¶§Ø(zËh¶ºw-Ü©àzËazËZµê=«¬y©Ý¶§¬¶ayhbâè¢az|¨ºÞ²ÊZºÇ¨§Ø(zÆÚrKh¶ºw-ò¢æ«zz0{aÇîËb¢{pÇØZ½é÷öÚÞ¶êçyܵ'ûaÉ"Ú²ÚîrÛ«{
+Çè¯*.jëh×6Global $Paused, $nPauseCount
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d

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

Func TogglePause()
    $Paused = NOT $Paused
    $nPauseCount += 1
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"' & @CR & $nPauseCount,0,0)
    Send ("^c")
    WEnd
    ToolTip("")
    If $nPauseCount = 2 Then
        Send (ClipGet())
        $nPauseCount = 0
    EndIf
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

Went about it a little different, tried to keep it to one loop

; Press Esc to terminate script, Pause/Break to "Copy/Paste"

Global $Paused = 0
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d

;;;; Body of program would go here ;;;;
While 1
    Sleep(100)
 Switch $Paused
  Case 1
   Send ("^c")
   $Paused = 3
  Case 2
   ToolTip("")
   Send (ClipGet())
   $Paused = 0
  Case 3
   ToolTip('Script is "Paused"',0,0)
 EndSwitch
WEnd
;;;;;;;;

Func TogglePause()
 Switch $Paused
  Case 0
   $Paused = 1
  Case 1
   $Paused = 3
  Case 3
   $Paused = 2
 EndSwitch
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Posted

Thank you both for the solutions.

I'm going to get busy and work on the Middle Button Click function. Should be a nice timesaver.

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
  • Recently Browsing   0 members

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