eightban's memo

残しておきたい記事をまとめてみました。このブログに書いてあるドキュメントやブログで配布しているファイルの使用によって発生するいかなる損害に対してもこのブログの管理者は責任を負いません。使用する場合は自己責任のもとに使用してください。

AutoIt アクセシビリティ

autoit でボタンを押すと指定した場所にマウスカーソルを移動する -- CSV ファイルを読み込み,複数箇所対応,ビープ音を鳴らす

更新日:

スクリプト

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>

Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
$mainwindow = GUICreate("auto close", 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=1000
Const $fn = 'C:\autoit3\Examples\a_mousemove.txt'

$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("auto close", "",3) Then
		sleep(50)
    ControlClick ("auto close","","Button1")
;GUISetState(@SW_MINIMIZE)

EndIf


While 1
  Sleep(1000)  ; Idle around
  if $msg1="stopping"  Then
  Else
    _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 _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()
			if not $Paused Then
				ExitLoop
			EndIf

			if $pos[0]=$xx2 AND $pos[1]=$yy2 Then
			Else
				Beep(900, 100)

				$Paused = NOT $Paused
				ToolTip("")

				ExitLoop
			EndIf
		Next
	EndIf

EndFunc

"{F9}"キーを押すと移動します。もう一度同じキーを押すかマウスカーソルが指定した場所からずれていると止まります
起動時に最小化するには

GUISetState(@SW_MINIMIZE)

CSV ファイルのサンプル

1200,10
1200,360
1200,700
640,700
10,10

その他

コピペした後は下にある文字は次のように変更してください
&#91; [
&amp; &
&lt; <
&gt; >

改良版

http://memo.eightban.com/autoit/autoit-mousemove2

-AutoIt, アクセシビリティ

Copyright© eightban's memo , 2024 All Rights Reserved Powered by STINGER.