Jump to content

Looking for a few examples


Recommended Posts

I'm writing a small script to do some basic button mashing for a game I play, I've gotten that whole part figured out and it runs fairly well. What I'm trying to do now is get it to save the settings to a file. Nothing big or fancy I just am not sure which functions I should be using to do that. Do I need to make it open up notepad and write them in there then save it through notepad? Or is there a simpler way? :)

Link to comment
Share on other sites

Thanks Zedna those work much better. Another question I have now while looking through the help file at a few other things, I found the SendKeyDelay option, I think this would work out much better than a standard sleep as I would imagine it wouldn't hold up the rest of the script (pushing pause button etc.) Any clue where I could find a little more info about this option? And does said option delay before the key is pressed or after?

Link to comment
Share on other sites

Thanks Zedna those work much better. Another question I have now while looking through the help file at a few other things, I found the SendKeyDelay option, I think this would work out much better than a standard sleep as I would imagine it wouldn't hold up the rest of the script (pushing pause button etc.) Any clue where I could find a little more info about this option? And does said option delay before the key is pressed or after?

Look into HelpFile at Opt()

Link to comment
Share on other sites

Thank you once again Zenda, seems that won't help me since they need to be varying delays. Last question I promise, I'm trying to do a controlsend however it doesn't seem to send it to the specified window, I looked at a few other's code and stole a few pieces (namely WoW anti-afk scripts). At first I figured it was a problem with the game but I cant even get it to send they key to notepad here's a snippet from what I'm working on as I don't want you to see how horrid the whole thing looks. :)

#include <GUIConstants.au3>
AutoItSetOption("WinTitleMatchMode", 4) 
Global $Delay
Global $Button
Global $BRun
Global $BPause
Global $handle = WinGetHandle("classname=Notepad")
#region GUI stuff
$Form1 = GUICreate("AForm1", 386, 170, 193, 115)
$Label1 = GUICtrlCreateLabel("Select Button to Mash and Delay", 96, 16, 160, 17)
$DKey = GUICtrlCreateCombo("Select Key", 48, 64, 105, 25)
GUICtrlSetData(-1, "A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|1|2|3|4|5|6|7|8|9|0|{F1}|{F2}|{F3}|{F4}|{F5}|{F6}|{F7}|{F8}|{F9}|{F10}|{F11}|{F12}")
$TDelay = GUICtrlCreateInput("Enter Delay", 224, 64, 65, 21)
$BRun = GUICtrlCreateButton("Run Script", 144, 104, 81, 41, 0)
GUISetState(@SW_SHOW)
#endregion
MsgBox(0,"Test",$handle) ;Debug MsgBox FTW! making sure something was returned by WinGetHandle
MainLoop()
Func MainLoop()
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $BRun
                GUICtrlDelete($BRun)
                $BPause = GUICtrlCreateButton("Stop Script", 144, 104, 81, 41, 0)
                $Delay = GUICtrlRead($TDelay) * 1000
                $Button = GUICtrlRead($DKey)
                MashLoop()
        EndSwitch
    WEnd
EndFunc

Func MashLoop()

    Sleep(1000)
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $BPause
                GUICtrlDelete($BPause)
                $BRun = GUICtrlCreateButton("Run Script", 144, 104, 81, 41, 0)
                MainLoop()
            EndSwitch
        ControlSend($handle,"","",$Button)

        Sleep($Delay)
    WEnd
EndFunc
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...