#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
Global $_title_1 = "mousemove3"
;[CLASS:Windows.UI.Core.CoreWindow; INSTANCE:0]
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
$mainwindow = GUICreate($_title_1, 70, 70)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$msg1="stopping"
$label1=GUICtrlCreateLabel($msg1, 10, 10)
$button1 = GUICtrlCreateButton("push", 10, 20,50, 50)
GUICtrlSetOnEvent($button1, "OKButton")
GUISetState(@SW_SHOW)
Global $Paused
Global Const $iSleep_Time=500
Global Const $cdxy=50
Const $fn = 'C:\app\autoit3\Examples\a_mousemove.txt'
Global $xx1 = 0
Global $yy1 = 0
$mm=0
Dim $Ax[1]
Dim $Ay[1]
$Ax[0]= 0
$Ay[0]= 0
HotKeySet("{Esc}", "_Exit") ; Press ESC for exit
Func _Exit()
Exit 0
EndFunc ;==>_Exit
HotKeySet("{F9}", "_F9")
Func _F9()
Beep(500, 100)
$pos = MouseGetPos()
$Ax[0]= $pos[0]
$Ay[0]= $pos[1]
$Paused = NOT $Paused
if $Paused Then
sleep(100)
ToolTip('cursol is "moving"',0,0)
Else
ToolTip("")
EndIf
EndFunc ;==>_Exit
$file = FileOpen($fn, 0)
;ファイルが読み込みモードで開かれたかどうかチェック
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
;EOFに達するまで1文字づつ読み込む。
While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
$mm=$mm+1
$array2 = StringSplit($line, ",")
_ArrayAdd($Ax, $array2[1])
_ArrayAdd($Ay, $array2[2])
Wend
FileClose($file)
;_ArrayDelete($Ax, 0)
;_ArrayDelete($Ay, 0)
;_ArrayDisplay($Ax, "$avArray set manually 1D")
if WinWait($_title_1, "",3) Then
sleep(50)
ControlClick ($_title_1,"","Button1")
sleep(50)
GUISetState(@SW_MINIMIZE)
EndIf
While 1
Sleep(1000) ; Idle around
if $msg1="stopping" Then
Else
_chk()
_osu()
EndIf
WEnd
Func OKButton()
; MsgBox(0, "GUI Event", "You pressed OK!")
if $msg1="stopping" Then
$msg1="executing"
Else
$msg1="stopping"
EndIf
GUICtrlSetData ($label1, $msg1)
EndFunc
Func CLOSEClicked()
; MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")
Exit
EndFunc
;===========================
Func _chk()
$pos1 = MouseGetPos()
if $pos1[0]=$xx1 AND $pos1[1]=$yy1 Then
$cx = @DesktopWidth/2
$cy = @DesktopHeight/2
if $pos1[0]=0 Or $pos1[1]=0 Or $pos1[0]=@DesktopWidth -1 Or $pos1[1]=@DesktopHeight-1 Then
Beep(1500, 100)
$Paused = NOT $Paused
Select
Case $pos1[0]=0
$Ax[0]= @DesktopWidth-10
$Ay[0]= @DesktopHeight/2
Case $pos1[0]=@DesktopWidth -1
$Ax[0]= 0+10
$Ay[0]= @DesktopHeight/2
Case $pos1[1]=0
$Ax[0]= @DesktopWidth/2
$Ay[0]= @DesktopHeight-10
Case $pos1[1]=@DesktopHeight-1
$Ax[0]= @DesktopWidth/2
$Ay[0]= 0+10
Case Else
$Ax[0]= $pos1[0]
$Ay[0]= $pos1[1]
EndSelect
Else
; MsgBox(4096, $cx-$cdxy , $cdxy, 10)
Select
Case $pos1[0]>$cx-$cdxy AND $pos1[0]<$cx+$cdxy AND $pos1[1]>$cy-$cdxy AND $pos1[1]<$cy+$cdxy
Beep(1500, 100)
$Paused = NOT $Paused
$Ax[0]= @DesktopWidth-10
$Ay[0]= @DesktopHeight/2
Case Else
$Ax[0]= $pos1[0]
$Ay[0]= $pos1[1]
EndSelect
EndIf
EndIf
$xx1 = $pos1[0]
$yy1 = $pos1[1]
EndFunc
Func _osu()
if $Paused Then
For $iy=0 To $mm Step 1
$xx2=$Ax[$iy]
$yy2=$Ay[$iy]
MouseMove($xx2, $yy2)
Sleep($iSleep_Time)
$pos = MouseGetPos()
; ToolTip('Script is "Paused"'&$iy&" "&$xx2&" "&$yy2,0,0)
if not $Paused Then
ExitLoop
EndIf
if $pos[0]=$xx2 AND $pos[1]=$yy2 Then
Else
Beep(900, 100)
$Paused = NOT $Paused
; ToolTip('Script is "Paused"'&$xx2&" "&$yy2,0,0)
ToolTip("")
ExitLoop
EndIf
Next
EndIf
EndFunc
ディスカッション
コメント一覧
まだ、コメントがありません