Jump to content

Recommended Posts

Posted (edited)

Hello all New here :)

Can someone help me with my script. I'm trying to get it to work while the app is minimized but it stops working when i press alt+tab or move to another window.

Please don't laugh at my coding skills it took me hours and hours of reading the forums and the helpfile to write this script. I don't know where i'm going wrong.

In essence the script is meant to press the return key ever 3 seconds that's it lol.

 

Global $sTargetExe = "MSAR-Win64-Shipping.exe"
Global $bEnterPress = False ; Flag to control Enter key pressing

HotKeySet("{F1}", "ToggleEnterPress") ; Set F1 as hotkey to toggle Enter key pressing
HotKeySet("{F2}", "StopEnterPress") ; Set F2 as hotkey to stop Enter key pressing
HotKeySet("{F3}", "ToggleMinimize") ; Set F3 as hotkey to toggle minimize the script window

While 1
    Sleep(100)
WEnd

Func ToggleEnterPress()
    $bEnterPress = Not $bEnterPress ; Toggle the flag

    If $bEnterPress Then
        While $bEnterPress
            If ActivateTargetWindow() Then
                Send("{ENTER}")
                Sleep(3000) ; Wait for 3 seconds
            Else
                $bEnterPress = False ; Stop if the target window is not active
            EndIf
        WEnd
    EndIf
EndFunc

Func ActivateTargetWindow()
    Local $hWnd = WinActivate("[CLASS:UnrealWindow]")
    If $hWnd <> 0 Then
        Return True
    Else
        Return False
    EndIf
EndFunc

Func ToggleMinimize()
    Local $hWnd = WinGetHandle("[TITLE:V3 test enter]")
    If $hWnd <> 0 Then
        WinSetState($hWnd, "", @SW_MINIMIZE) ; Minimize the window if it exists
    EndIf
EndFunc

Func StopEnterPress()
    $bEnterPress = False
EndFunc

Thank you for your time and patience. Also if you know a better way to toggle the F1 key without using F2 that would be greatly appreciated. 

Edited by Jos
added codebox
  • Developers
Posted

Welcome to the AutoIt forum.

Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked.

See you soon with a legitimate question I hope.

The Moderation team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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