Sign in to follow this  
Followers 0
KentNguyen

Need help with TimmerDiff and TimerInit ^ ^

6 posts in this topic

first, i'm sr about my bad english, i got stuck in this script, if i write by anotherway then its ok ,but when i tried to use TimerDiff and TimerInit i got a problem that i cant even know what it is, i did the same as i saw in the forum... pls, help me out pls :D here is my script

#include-once

#include <GUIListView.au3>

#include <GUIConstants.au3>

#include <GuiListView.au3>

#Include <GuiConstants.au3>

TraySetIcon ("icon.ico")

Opt("TrayAutoPause",0)

Opt("WinTitleMatchMode", 2)

Opt("TrayMenuMode",0)

Opt("SendKeyDownDelay", 50)

Opt("MouseClickDownDelay",50)

Opt("PixelCoordMode", 0)

Global $Paused

Global $time

GUICreate("Auto Game",240,170,-1,-1)

GUICtrlCreateTab(10,10,220,150)

GUICtrlCreateTabItem("Char#1")

GUICtrlCreateLabel("UID",20,45,30,20)

$uid=GUICtrlCreateInput("",60,40,100,20)

$att=GUICtrlCreateCheckbox("Tự động đánh",20,80,100,20)

GUICtrlSetState(-1,$GUI_CHECKED)

$move=GUICtrlCreateCheckbox("Tự động chạy",120,80,100,20)

GUICtrlSetState(-1,$GUI_CHECKED)

$run=GUICtrlCreateButton("Run",20,120,60,20)

$hide=GUICtrlCreateButton("Hide",100,120,60,20)

$show=TrayCreateItem("Show")

$trayexit=TrayCreateItem("Exit")

$m=0

$a=0

$time=0

GUISetState()

While 1

$msg=GUIGetMsg()

$msg2=TrayGetMsg()

If $msg=$GUI_EVENT_CLOSE Then

Exit

EndIf

If $msg=$hide Then

GUISetState(@SW_HIDE)

EndIf

If $msg2=$show Then

GUISetState(@SW_SHOW)

EndIf

If $msg2=$trayexit Then

Exit

EndIf

If $msg=$run Then

TraySetToolTip ( "Char : "& GUICtrlRead($uid))

$sub= GUICtrlRead($uid)

$tit= WinGetTitle($sub, "")

$m=GUICtrlRead($move)

$a=GUICtrlRead($att)

EndIf

RUNX()

WEnd

Func RUNX()

While 1

If $msg=$GUI_EVENT_CLOSE Then Exit

If TimerDiff($time)>=5000 Then

A()

$time=TimerInit()

EndIf

If TimerDiff($time)>=3600000 Then

B()

$time=TimerInit()

EndIf

Wend

EndFunc

Func A()

If $a=1 Then

controlsend($tit,"","","!z")

Sleep(1000)

EndIf

EndFunc

Func B()

If $m=1 Then

_MOUSECLICKPLUS($tit, "left", 780, 520, 1)

Sleep(700)

_MOUSECLICKPLUS($tit, "left", 620, 480, 1)

Sleep(700)

_MOUSECLICKPLUS($tit, "left", 780, 520, 1)

Sleep(700)

EndIf

EndFunc

Func _MOUSECLICKPLUS($WINDOW, $BUTTON = "left", $X = "", $Y = "", $CLICKS = 1)

Local $MK_LBUTTON = 1

Local $WM_LBUTTONDOWN = 513

Local $WM_LBUTTONUP = 514

Local $MK_RBUTTON = 2

Local $WM_RBUTTONDOWN = 516

Local $WM_RBUTTONUP = 517

Local $WM_MOUSEMOVE = 512

Local $I = 0

Select

Case $BUTTON = "left"

$BUTTON = $MK_LBUTTON

$BUTTONDOWN = $WM_LBUTTONDOWN

$BUTTONUP = $WM_LBUTTONUP

Case $BUTTON = "right"

$BUTTON = $MK_RBUTTON

$BUTTONDOWN = $WM_RBUTTONDOWN

$BUTTONUP = $WM_RBUTTONUP

EndSelect

If $X = "" Or $Y = "" Then

$MOUSECOORD = MouseGetPos()

$X = $MOUSECOORD[0]

$Y = $MOUSECOORD[1]

EndIf

For $I = 1 To $CLICKS

DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($WINDOW), "int", $WM_MOUSEMOVE, "int", 0, "long", _MAKELONG($X, $Y))

DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($WINDOW), "int", $BUTTONDOWN, "int", $BUTTON, "long", _MAKELONG($X, $Y))

DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($WINDOW), "int", $BUTTONUP, "int", $BUTTON, "long", _MAKELONG($X, $Y))

Next

EndFunc

Func _MAKELONG($LOWORD, $HIWORD)

Return BitOR($HIWORD * 65536, BitAND($LOWORD, 65535))

EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

first, i'm sr about my bad english, i got stuck in this script, if i write by anotherway then its ok ,but when i tried to use TimerDiff and TimerInit i got a problem that i cant even know what it is, i did the same as i saw in the forum... pls, help me out pls :D here is my script

Func RUNX()
While 1
$msg=GUIGetMsg()
$show=TrayCreateItem("Show")
If $msg=$hide Then
GUISetState(@SW_HIDE)
EndIf
If $msg2=$show Then
GUISetState(@SW_SHOW)
EndIf

#include-once
#include <GUIListView.au3>
#include <GUIConstants.au3>
#include <GuiListView.au3>
#Include <GuiConstants.au3>


TraySetIcon ("icon.ico")
Opt("TrayAutoPause",0)
Opt("WinTitleMatchMode", 2)
Opt("TrayMenuMode",0)
Opt("SendKeyDownDelay", 50)
Opt("MouseClickDownDelay",50)
Opt("PixelCoordMode", 0)


Global $Paused
Global $time

GUICreate("Auto Game",240,170,-1,-1)
GUICtrlCreateTab(10,10,220,150)
GUICtrlCreateTabItem("Char#1")
GUICtrlCreateLabel("UID",20,45,30,20)
$uid=GUICtrlCreateInput("",60,40,100,20)
$att=GUICtrlCreateCheckbox("T? ??ng ??nh",20,80,100,20)
GUICtrlSetState(-1,$GUI_CHECKED)
$move=GUICtrlCreateCheckbox("T? ??ng ch?y",120,80,100,20)
GUICtrlSetState(-1,$GUI_CHECKED)
$run=GUICtrlCreateButton("Run",20,120,60,20)
$hide=GUICtrlCreateButton("Hide",100,120,60,20)
$show=TrayCreateItem("Show")
$trayexit=TrayCreateItem("Exit")
$m=0
$a=0
$time=0
GUISetState()

While 1
$msg=GUIGetMsg()
$msg2=TrayGetMsg()
If $msg=$GUI_EVENT_CLOSE Then
Exit
EndIf
If $msg=$hide Then
GUISetState(@SW_HIDE)
EndIf
If $msg2=$show Then
GUISetState(@SW_SHOW)
EndIf
If $msg2=$trayexit Then
Exit
EndIf
If $msg=$run Then
TraySetToolTip ( "Char : "& GUICtrlRead($uid))
$sub= GUICtrlRead($uid)
$tit= WinGetTitle($sub, "")
$m=GUICtrlRead($move)
$a=GUICtrlRead($att)
EndIf

WEnd

Func RUNX()
While 1
$msg=GUIGetMsg()
$show=TrayCreateItem("Show")
If $msg=$hide Then
GUISetState(@SW_HIDE)
EndIf
If $msg2=$show Then
GUISetState(@SW_SHOW)
EndIf
If $msg=$GUI_EVENT_CLOSE Then Exit
If TimerDiff($time)>=5000 Then
A()
$time=TimerInit()
EndIf
If TimerDiff($time)>=3600000 Then
B()
$time=TimerInit()
EndIf
Wend
EndFunc

Func A()
If $a=1 Then
controlsend($tit,"","","!z")
Sleep(1000)
EndIf
EndFunc

Func B()
If $m=1 Then
_MOUSECLICKPLUS($tit, "left", 780, 520, 1)
Sleep(700)
_MOUSECLICKPLUS($tit, "left", 620, 480, 1)
Sleep(700)
_MOUSECLICKPLUS($tit, "left", 780, 520, 1)
Sleep(700)
EndIf
EndFunc


Func _MOUSECLICKPLUS($WINDOW, $BUTTON = "left", $X = "", $Y = "", $CLICKS = 1)
Local $MK_LBUTTON = 1
Local $WM_LBUTTONDOWN = 513
Local $WM_LBUTTONUP = 514
Local $MK_RBUTTON = 2
Local $WM_RBUTTONDOWN = 516
Local $WM_RBUTTONUP = 517
Local $WM_MOUSEMOVE = 512
Local $I = 0
Select
Case $BUTTON = "left"
$BUTTON = $MK_LBUTTON
$BUTTONDOWN = $WM_LBUTTONDOWN
$BUTTONUP = $WM_LBUTTONUP
Case $BUTTON = "right"
$BUTTON = $MK_RBUTTON
$BUTTONDOWN = $WM_RBUTTONDOWN
$BUTTONUP = $WM_RBUTTONUP
EndSelect
If $X = "" Or $Y = "" Then
$MOUSECOORD = MouseGetPos()
$X = $MOUSECOORD[0]
$Y = $MOUSECOORD[1]
EndIf
For $I = 1 To $CLICKS
DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($WINDOW), "int", $WM_MOUSEMOVE, "int", 0, "long", _MAKELONG($X, $Y))
DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($WINDOW), "int", $BUTTONDOWN, "int", $BUTTON, "long", _MAKELONG($X, $Y))
DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($WINDOW), "int", $BUTTONUP, "int", $BUTTON, "long", _MAKELONG($X, $Y))
Next
EndFunc

Func _MAKELONG($LOWORD, $HIWORD)
Return BitOR($HIWORD * 65536, BitAND($LOWORD, 65535))
EndFunc
Edited by wolf9228

صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

thank for reply but it doesnt work, what i want to do is make 2 separate time counting and do 2 separate things in different times so i make my $time into $timeatt and $timemove, it doesnt work either, the problem is when i take out TimerDiff and TimerInit, do another way and it's all good, when i use TimerDiff and TimerInit, there is no error but nothing happen, can some1 help me pls?

#include-once
#include <GUIListView.au3>
#include <GUIConstants.au3>
#include <GuiListView.au3>
#Include <GuiConstants.au3>


TraySetIcon ("icon.ico")
Opt("TrayAutoPause",0)
Opt("WinTitleMatchMode", 2)
Opt("TrayMenuMode",0)
Opt("SendKeyDownDelay", 50)
Opt("MouseClickDownDelay",50)
Opt("PixelCoordMode", 0)


Global $Paused
Global $timea
Global $timem

GUICreate("Auto Game",240,170,-1,-1)
GUICtrlCreateTab(10,10,220,150)
GUICtrlCreateTabItem("Char#1")
GUICtrlCreateLabel("UID",20,45,30,20)
$uid=GUICtrlCreateInput("",60,40,100,20)
$att=GUICtrlCreateCheckbox("T? ??ng ??nh",20,80,100,20)
GUICtrlSetState(-1,$GUI_CHECKED)
$move=GUICtrlCreateCheckbox("T? ??ng ch?y",120,80,100,20)
GUICtrlSetState(-1,$GUI_CHECKED)
$run=GUICtrlCreateButton("Run",20,120,60,20)
$hide=GUICtrlCreateButton("Hide",100,120,60,20)
$show=TrayCreateItem("Show")
$trayexit=TrayCreateItem("Exit")
$m=0
$a=0
$timea=0
$timem=0
GUISetState()

While 1
  $msg=GUIGetMsg()
  $msg2=TrayGetMsg()
  If $msg=$GUI_EVENT_CLOSE Then
    Exit
  EndIf
  If $msg=$hide Then
    GUISetState(@SW_HIDE)
  EndIf
  If $msg2=$show Then
    GUISetState(@SW_SHOW)
  EndIf
  If $msg2=$trayexit Then
    Exit
  EndIf
  If $msg=$run Then
    TraySetToolTip ( "Char : "& GUICtrlRead($uid))
    $sub= GUICtrlRead($uid)
    $tit= WinGetTitle($sub, "")
    $m=GUICtrlRead($move)
    $a=GUICtrlRead($att)
  EndIf
  RUNX()
WEnd

Func RUNX()
  While 1
    $msg=GUIGetMsg()
    $show=TrayCreateItem("Show")
    If $msg=$hide Then
      GUISetState(@SW_HIDE)
    EndIf
    If $msg2=$show Then
      GUISetState(@SW_SHOW)
    EndIf
    If $msg=$GUI_EVENT_CLOSE Then Exit
    If TimerDiff($timea)>=5000 Then
      A()
      $timea=TimerInit()
    EndIf
    If TimerDiff($timem)>=3600000 Then
      B()
      $timem=TimerInit()
    EndIf
  Wend
EndFunc

Func A()
  If $a=1 Then
    controlsend($tit,"","","!z")
    Sleep(1000)
  EndIf
EndFunc

Func B()
  If $m=1 Then
    _MOUSECLICKPLUS($tit, "left", 780, 520, 1)
    Sleep(700)
    _MOUSECLICKPLUS($tit, "left", 620, 480, 1)
    Sleep(700)
    _MOUSECLICKPLUS($tit, "left", 780, 520, 1)
    Sleep(700)
  EndIf
EndFunc


Func _MOUSECLICKPLUS($WINDOW, $BUTTON = "left", $X = "", $Y = "", $CLICKS = 1)
Local $MK_LBUTTON = 1
Local $WM_LBUTTONDOWN = 513
Local $WM_LBUTTONUP = 514
Local $MK_RBUTTON = 2
Local $WM_RBUTTONDOWN = 516
Local $WM_RBUTTONUP = 517
Local $WM_MOUSEMOVE = 512
Local $I = 0
Select
Case $BUTTON = "left"
  $BUTTON = $MK_LBUTTON
  $BUTTONDOWN = $WM_LBUTTONDOWN
  $BUTTONUP = $WM_LBUTTONUP
Case $BUTTON = "right"
  $BUTTON = $MK_RBUTTON
  $BUTTONDOWN = $WM_RBUTTONDOWN
  $BUTTONUP = $WM_RBUTTONUP
EndSelect
If $X = "" Or $Y = "" Then
  $MOUSECOORD = MouseGetPos()
  $X = $MOUSECOORD[0]
  $Y = $MOUSECOORD[1]
EndIf
For $I = 1 To $CLICKS
  DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($WINDOW), "int", $WM_MOUSEMOVE, "int", 0, "long", _MAKELONG($X, $Y))
  DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($WINDOW), "int", $BUTTONDOWN, "int", $BUTTON, "long", _MAKELONG($X, $Y))
  DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($WINDOW), "int", $BUTTONUP, "int", $BUTTON, "long", _MAKELONG($X, $Y))
Next
EndFunc

Func _MAKELONG($LOWORD, $HIWORD)
Return BitOR($HIWORD * 65536, BitAND($LOWORD, 65535))
EndFunc
Edited by KentNguyen

Share this post


Link to post
Share on other sites

thank for reply but it doesnt work, what i want to do is make 2 separate time counting and do 2 separate things in different times so i make my $time into $timeatt and $timemove, it doesnt work either, the problem is when i take out TimerDiff and TimerInit, do another way and it's all good, when i use TimerDiff and TimerInit, there is no error but nothing happen, can some1 help me pls?

Try this code

#include-once
#include <GUIListView.au3>
#include <GUIConstants.au3>
#include <GuiListView.au3>
#Include <GuiConstants.au3>


TraySetIcon ("icon.ico")
Opt("TrayAutoPause",0)
Opt("WinTitleMatchMode", 2)
Opt("TrayMenuMode",0)
Opt("SendKeyDownDelay", 50)
Opt("MouseClickDownDelay",50)
Opt("PixelCoordMode", 0)


Global $Paused
Global $time

GUICreate("Auto Game",240,170,-1,-1)
GUICtrlCreateTab(10,10,220,150)
GUICtrlCreateTabItem("Char#1")
GUICtrlCreateLabel("UID",20,45,30,20)
$uid=GUICtrlCreateInput("",60,40,100,20)
$att=GUICtrlCreateCheckbox("T? ??ng ??nh",20,80,100,20)
GUICtrlSetState(-1,$GUI_CHECKED)
$move=GUICtrlCreateCheckbox("T? ??ng ch?y",120,80,100,20)
GUICtrlSetState(-1,$GUI_CHECKED)
$run=GUICtrlCreateButton("Run",20,120,60,20)
$hide=GUICtrlCreateButton("Hide",100,120,60,20)
$show=TrayCreateItem("Show")
$trayexit=TrayCreateItem("Exit")
Global $m=0 , $a=0 , $time1=0 , $time2=0
GUISetState()
if ControlClick("Auto Game", "", $run) Then _ ; Click Run Button
TrayTip("ControlClick", "Run Button / Wait 5 seconds", 5, 1)
While 1
$msg=GUIGetMsg()
$msg2=TrayGetMsg()
If $msg=$GUI_EVENT_CLOSE Then Exit
If $msg=$hide Then
GUISetState(@SW_HIDE)
EndIf
If $msg2=$show Then
GUISetState(@SW_SHOW)
EndIf
If $msg2=$trayexit Then
Exit
EndIf
If $msg=$run Then
TraySetToolTip ( "Char : "& GUICtrlRead($uid))
$sub= GUICtrlRead($uid)
$tit= WinGetTitle($sub, "")
$m=GUICtrlRead($move)
$a=GUICtrlRead($att)
RUNX()
EndIf

WEnd

Func RUNX()
$time1=TimerInit()
$time2=TimerInit()

While 1

If TimerDiff($time1)>=5000 Then
A()
$time1=TimerInit()
EndIf
If TimerDiff($time2)>=3600000 Then
B()
$time2=TimerInit()
EndIf

$msg=GUIGetMsg()
$msg2=TrayGetMsg()
If $msg=$GUI_EVENT_CLOSE Then Exit
If $msg=$hide Then
GUISetState(@SW_HIDE)
EndIf
If $msg2=$show Then
GUISetState(@SW_SHOW)
EndIf
If $msg2=$trayexit Then Exit

Wend
EndFunc

Func A()
If $a=1 Then
TrayTip("Func A()", "$time1", 5, 1)
controlsend($tit,"","","!z")
Sleep(1000)
EndIf
EndFunc

Func B()
If $m=1 Then
TrayTip("Func B()", "$time2", 5, 1)
_MOUSECLICKPLUS($tit, "left", 780, 520, 1)
Sleep(700)
_MOUSECLICKPLUS($tit, "left", 620, 480, 1)
Sleep(700)
_MOUSECLICKPLUS($tit, "left", 780, 520, 1)
Sleep(700)
EndIf
EndFunc


Func _MOUSECLICKPLUS($WINDOW, $BUTTON = "left", $X = "", $Y = "", $CLICKS = 1)
Local $MK_LBUTTON = 1
Local $WM_LBUTTONDOWN = 513
Local $WM_LBUTTONUP = 514
Local $MK_RBUTTON = 2
Local $WM_RBUTTONDOWN = 516
Local $WM_RBUTTONUP = 517
Local $WM_MOUSEMOVE = 512
Local $I = 0
Select
Case $BUTTON = "left"
$BUTTON = $MK_LBUTTON
$BUTTONDOWN = $WM_LBUTTONDOWN
$BUTTONUP = $WM_LBUTTONUP
Case $BUTTON = "right"
$BUTTON = $MK_RBUTTON
$BUTTONDOWN = $WM_RBUTTONDOWN
$BUTTONUP = $WM_RBUTTONUP
EndSelect
If $X = "" Or $Y = "" Then
$MOUSECOORD = MouseGetPos()
$X = $MOUSECOORD[0]
$Y = $MOUSECOORD[1]
EndIf
For $I = 1 To $CLICKS
DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($WINDOW), "int", $WM_MOUSEMOVE, "int", 0, "long", _MAKELONG($X, $Y))
DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($WINDOW), "int", $BUTTONDOWN, "int", $BUTTON, "long", _MAKELONG($X, $Y))
DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($WINDOW), "int", $BUTTONUP, "int", $BUTTON, "long", _MAKELONG($X, $Y))
Next
EndFunc

Func _MAKELONG($LOWORD, $HIWORD)
Return BitOR($HIWORD * 65536, BitAND($LOWORD, 65535))
EndFunc

صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites

it doesnt work either, it does show that the script is running on tray tip but nothing happen in the window which i want to send keys to, i thought it could be problem about getting wintitle but its strange, because it's ok if i use counting and set sleep time between counts, but that way is not so good, so i wanna do with TimerDiff/Init ... anyway, thank for ur help wolf, got any other idea, oh this is bad, i'm really confusing :D

Share this post


Link to post
Share on other sites

thank you wolf, finally i got it... it works, thanks a lot :D

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0