Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Global $x = 0, $y = 98; Vị trí xuất phát của cái nút
- Global $w = 100, $n = 49;$w là tốc độ giữa hai lần nhấn (mili giây) cũng có thể nói là tốc độ di chuyển, $n là khoảng di chuyển
- Global $t, $d = "user32.dll" ;Cái vụ này thì soi cái hàm _IsPressed sẽ rõ
- Local $key, $dk
- $F = GUICreate("", 245, 245, 192, 124)
- $B = GUICtrlCreateButton("Cái Nút", $x, $y, 49, 49)
- $Cnv = GUICtrlCreateButton("CN.Vật", 49, 49, 49, 49)
- GUISetState(@SW_SHOW)
- Func _IsPressed($sHexKey, $vDLL = 'user32.dll') ;Cái này copy trong thư viện Misc.au3 cho nó nhẹ
- Local $a_R = DllCall($vDLL, "short", "GetAsyncKeyState", "int", '0x' & $sHexKey)
- If @error Then Return SetError(@error, @extended, False)
- Return BitAND($a_R[0], 0x8000) <> 0
- EndFunc ;==>_IsPressed
- Func Gon($key, $dk) ;Cái này tao rút gọn thôi
- $time = @HOUR & ":" & @MIN & ":" & @SEC
- If _IsPressed($key, $d) Then
- GUICtrlDelete($B)
- Switch $dk
- Case 1
- If ($x = 98 And $y = 49) Then
- ConsoleWrite("Can't Left " & $time & @CR)
- Else
- If $x - $n >= 0 Then $x = $x - $n
- EndIf
- Case 2
- If ($x = 49 And $y = 98) Then
- ConsoleWrite("Can't Up " & $time & @CR)
- Else
- If $y - $n >= 0 Then $y = $y - $n
- EndIf
- Case 3
- If ($x = 0 And $y = 49) Then
- ConsoleWrite("Can't Right " & $time & @CR)
- Else
- If $x + $n <= 196 Then $x = $x + $n
- EndIf
- Case 4
- If ($x = 49 And $y = 0) Then
- ConsoleWrite("Can't Down " & $time & @CR)
- Else
- If $y + $n <= 196 Then $y = $y + $n
- EndIf
- EndSwitch
- $B = GUICtrlCreateButton("Cái Nút ", $x, $y, 49, 49)
- Sleep($w)
- DllClose($d)
- EndIf
- EndFunc ;==>Gon
- Func DonBaiChienTruong()
- DllClose($d) ;------------------------------------------------;
- GUIDelete($F) ;4 dòng này để dọn bãi chiến trường rồi quảng cáo;
- ToolTip("", 0, 0);-----------------------------------------------------------------------------------------------------;
- MsgBox(0, "", "Code bởi Ngọc Thụ Lâm Phong" & @CR & @CR & "Http://facebook.com/AnhVuongCoDon" & @CR & @CR & "Cảm ơn đã sử dụng ^^");
- Exit
- EndFunc ;==>DonBaiChienTruong
- Func Move() ;Cho chạy hết 4 nút mũi tên, nếu nhấn nút nào thì chạy hướng nào
- Gon(25, 1)
- Gon(26, 2)
- Gon(27, 3)
- Gon(28, 4)
- EndFunc ;==>Move
- While 1
- $GUI = GUIGetMsg()
- Move()
- If "Tọa cmn độ" & @CR & "x = " & $x & @CR & "y = " & $y <> $t Then ToolTip("Tọa cmn độ" & @CR & "x = " & $x & @CR & "y = " & $y, 0, 0)
- $t = "Tọa cmn độ" & @CR & "x = " & $x & @CR & "y = " & $y
- If $GUI = -3 Then DonBaiChienTruong() ; nếu nhấn x thì dọn bãi ct rồi thoát
- If $GUI = $B Then MsgBox(0, "", "Vê lờ, cái nút thôi chớ có gì mà bấm")
- If _IsPressed("1B", $d) Then DonBaiChienTruong(); Nếu nhấn Esc thì cũng dọn bãi chiến trường và thoát
- WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement