Jump to content

Recommended Posts

Posted

Example:

#include <date.au3>
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")

#include <GUIConstants.au3>

$Form1 = GUICreate("Form1", 294, 85, 193, 125)
$Label1 = GUICtrlCreateLabel("Label1", 24, 24, 236, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    $time = _NowCalc()
    GUICtrlSetData($Label1, $time)
    Sleep(50)
WEnd


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

#include <ByteMe.au3>

Posted (edited)

HotKeySet("{f5}", "_process")
Global $giStep = 0
main()
Func main()
While 1
  Sleep(10)
WEnd
EndFunc   ;==>main
Func _process()
Switch $giStep
  Case 0
   $giStep += _step($giStep)
   Return (1)
  Case 1
   $giStep += _step($giStep)
   Return (1)
  Case 2
   $giStep += _step($giStep)
   Return (1)
  Case 3
   Exit
EndSwitch
EndFunc   ;==>_process
Func _Step($giStep)
ConsoleWrite(@LF & "This should do stuff! " & $giStep & @LF)
Return (1)
EndFunc   ;==>_Step

Edited by DicatoroftheUSA
Posted (edited)

Hello,

thanks for your proposals.

This is nearly what I mean:

Run("notepad.exe")
WinWaitActive("[CLASS:Notepad]")
Send("This is a testline before the enter key was pressed." & @LF)
Send("This is a testline before the enter key was pressed." & @LF)
; --------------------------------------------------------------------
#include<Misc.au3>
$dll = DllOpen("user32.dll")
While 1
Sleep(250)
If _IsPressed("0D", $dll) Then ; enter
  ExitLoop
Else
  MsgBox(0, "confirmation", "Press <ENTER> to confirm")
EndIf
WEnd
DllClose($dll)
; --------------------------------------------------------------------
Sleep(500)
Send(@LF)
Send(@LF)
Send("This is a testline after the enter key was pressed." & @LF)
Send("This is a testline after the enter key was pressed." & @LF)
Exit

The problem is, that I have to press the enter key too long, in order to continue the script flawlessly.

Edited by newcomer44
Posted

But you coded it to take a long time. Imagine that Enter is pressed straight after the _IsPressed(), you have a 250 ms Sleep() so it would have to be pressed for 250 ms!

Unless you need the Enter for something else, use HotKeySet() instead of _IsPressed(). Or since it's just notepad you're automating, one of the Control*() functions, or write directly to the file with something like FileWrite().

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