Jump to content

Do something and again do it after 2 min


mrtgtr
 Share

Recommended Posts

$handle = a window you own, could be your autoit script

"DoitBabe" is a func you will create that do what you want after 2 min.

Search for that UDF it is on autoit help file

Make a script of your own, if it is not working post it and ill help

 

Link to comment
Share on other sites

Func Wm()
$ctl=_Timer_SetTimer($hGUI,2*2500,'Wm")

error: syntax error (illegal character)

error: _Timer_SetTimer() : undefined function.


PixelSearch(590 , 742 , 1020 , 742, 0xAA3322)
If @error Then
Send("{9 down}")
Sleep(1700)
Send("{9 up}")
EndIf
EndFunc

Link to comment
Share on other sites

1 hour ago, Nine said:

$handle = a window you own, could be your autoit script

"DoitBabe" is a func you will create that do what you want after 2 min.

Search for that UDF it is on autoit help file

Make a script of your own, if it is not working post it and ill help

Func Wm()
$ctl=_Timer_SetTimer($hGUI,2*2500,'Wm")

error: syntax error (illegal character)

error: _Timer_SetTimer() : undefined function.


PixelSearch(590 , 742 , 1020 , 742, 0xAA3322)
If @error Then
Send("{9 down}")
Sleep(1700)
Send("{9 up}")
EndIf
EndFunc

Link to comment
Share on other sites

where is $hgui and you cannot call wm within wm. it must be outside wm

and always have opt ("MustDeclareVars",1) at the beginning of your script, it will greatly help you debug

 

Edited by Nine
Link to comment
Share on other sites

Can you please give us some more detailed information about the program you try to automate?
PixelSearch and Send depend on screen size and resolution, window position and might interfere with user actions.
Most of the time there are more reliable ways to do what you want to do.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

1 hour ago, water said:

Can you please give us some more detailed information about the program you try to automate?
PixelSearch and Send depend on screen size and resolution, window position and might interfere with user actions.
Most of the time there are more reliable ways to do what you want to do.

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=firefox.ico
#AutoIt3Wrapper_Outfile=firefox.Exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <Misc.au3>

Opt("TrayIconHide", 1)

    ; Create a GUI with various controls.
$hGUI = GUICreate("Google - Mozilla Firefox", 500, 500)
$Start = GUICtrlCreateButton("BAŞLA", 215, 420, 75, 50)
GUICtrlCreateLabel("Durdurmak için + ya bas", 165, 30)
$WMBOX = GUICtrlCreateCheckbox("WM", 75, 50, 100, 60)
GUICtrlSetFont(-1, 16, 800, 0, "Comic Sans MS")
$ZBOX = GUICtrlCreateCheckbox("Z", 75, 100, 100, 60)
GUICtrlSetFont(-1, 16, 800, 0, "Comic Sans MS")
GUICtrlSetTip(-1, "50")
GUISetState(@SW_SHOW)
Local $hDLL = DllOpen("user32.dll")

Global $Timer1 = TimerInit()



While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Start
            runner()
        Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
WEnd




Func Runner()
    While 1

    If _IsPressed("6B", $hDLL) Then
        Exit
    EndIf


    If GUICtrlRead($wmbox) = 1 Then
    WM()
    EndIf

    If GUICtrlRead($ZBOX) = 1 Then
    Z()
    EndIf
    WEnd


    EndFunc


Func kapat()
    Exit
EndFunc



Func WM();when start, this is do it and do every 2 min (loop)
PixelSearch(590 , 742 , 1020 , 742, 0xAA3322)
If @error Then
Send("{9 down}")
Sleep(1700)
Send("{9 up}")
EndIf
EndFunc

Func Z() ;when start, this is do it and do every 1 min (loop)
    Send("{z down}")
    Sleep(100)
    Send("{z up}")
EndFunc

 

Link to comment
Share on other sites

Thanks for the code. But it doesn't explain what you want to achieve with function WM.
Example: You want to wait until a button gets active and then click on this button.
Can you please elaborate?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

First insert at the begining of your script :  Opt ("MustDeclareVars",1)Btw, 2* 2500 is not 2 minutes....

And Wm must have the following arguments :

Func Wm ($hWnd, $iMsg, $iIDTimer, $iTime)

Instead of Global $Timer1 = TimerInit () replace by :

Local $ctl=_Timer_SetTimer($hGUI,2*2500,'Wm")
  if not $ctl then
    MsgBox (0,"test","timer error")
    Exit
  endif 
Edited by Nine
Link to comment
Share on other sites

Link to comment
Share on other sites

40 minutes ago, mrtgtr said:

error: syntax error (illegal character)

error: _Timer_SetTimer(): undefined function.

you must have at the beginning of the script :

#include <Timers.au3>

Please look in index of autoit help for _Timer_SetTimer, all the information is in there

Link to comment
Share on other sites

1 hour ago, Nine said:

you must have at the beginning of the script :

#include <Timers.au3>

Please look in index of autoit help for _Timer_SetTimer, all the information is in there

 

I did #include <Timers.au3>

now

Local $ctl=_Timer_SetTimer($hGUI,2*2500,'Wm")

error: syntax error (illegal character)

Link to comment
Share on other sites

2 minutes ago, mrtgtr said:

Local $ctl=_Timer_SetTimer($hGUI,2*2500,'Wm")

You have a double quote at one end of the Wm, and a single at the other.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Link to comment
Share on other sites

2 hours ago, Nine said:

Have you put the parameters to  Func Wm ($hWnd, $iMsg, $iIDTimer, $iTime

If so, bring all your code in so we can see what's going on

While I am searching timers I found this

$Timer = TimerInit()
Func SomeFunction
    $Delay = TimerDiff($Timer)
    $DelayTime = (120000)
    If $Delay > $DelayTime Then
        <your code goes here>
        $Timer = TimerInit()
    EndIf
EndFunc

 

this is good but

it is waiting 2 min and doing it 

I want to do it and wait 2 min and again do it,( again, again, again, loop)

but it is not be sleep it must be timer

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...