Jump to content

How to set autoit for 1 application?


Orcc
 Share

Recommended Posts

hey i have a script for a game. and i want it to run only for that game anyone have a clue what to look for under help?

Also a pause key? Plus can a you explain what steps and what each code is for (pause) key?

(ie; Send("{F1}") ;simluate f1 keypress)

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.10.0

Author: Booleen

Script Function:

Template AutoIt script.

#ce ----------------------------------------------------------------------------

HotKeySet("-", "Stop") ;script can be stopped by pressing -

Sleep(4000) ;wait 4sec's before starting the cycle, to allow the user to navigate to the correct window

While 1 ;repeat endlessly

Send("{F1}") ;simluate f1 keypress

Sleep(800) ;wait 1 seconds

WEnd ;repeat

Func Stop() ;to allow the script to stop

Exit ;same

EndFunc ;same

Edited by Orcc
Link to comment
Share on other sites

maybe something like this? press F1 to pause script, press F1 again to continue. You'll need to edit the WinActive() to the window title of your game.

HotKeySet("{F1}","Pause")
$PauseFlag = False

HotKeySet("-", "Stop") ;script can be stopped by pressing -
Sleep(4000) ;wait 4sec's before starting the cycle, to allow the user to navigate to the correct window

While 1 ;repeat endlessly
    
    If WinActive("Game window title goes here") Then
        Send("{F1}") ;simluate f1 keypress
        Sleep(800) ;wait 1 seconds
    EndIf

WEnd ;repeat

Func Stop() ;to allow the script to stop
    Exit ;same
EndFunc ;same 

Func Pause()
    
    If $PauseFlag = False Then
        $PauseFlag = True
    Else 
        $PauseFlag = False
    EndIf

    While $PauseFlag
        Sleep(100)
    WEnd
    
EndFunc
Edited by covaks
Link to comment
Share on other sites

maybe something like this? press F1 to pause script, press F1 again to continue. You'll need to edit the WinActive() to the window title of your game.

HotKeySet("{F1}","Pause")
$PauseFlag = False

HotKeySet("-", "Stop") ;script can be stopped by pressing -
Sleep(4000) ;wait 4sec's before starting the cycle, to allow the user to navigate to the correct window

While 1 ;repeat endlessly
    
    If WinActive("Game window title goes here") Then
        Send("{F1}") ;simluate f1 keypress
        Sleep(800) ;wait 1 seconds
    EndIf

WEnd ;repeat

Func Stop() ;to allow the script to stop
    Exit ;same
EndFunc ;same 

Func Pause()
    
    If $PauseFlag = False Then
        $PauseFlag = True
    Else 
        $PauseFlag = False
    EndIf

    While $PauseFlag
        Sleep(100)
    WEnd
    
EndFunc

How do I find the game title. Ty for help btw.

Link to comment
Share on other sites

It's the title in the window. Eg: when you open notepad it says "Untitled - Notepad", that would be the title. Or Calc.exe is "Calculator".

You can use the AutoIT Window Info Tool to get the window title if you aren't sure.

or if you can't find a title, get the PID from ProcessExists() function, and get the handle using This

or any of countless other ways to go about this.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...