Jump to content

How The Hell Do I Make It Exit.


Misha
 Share

Recommended Posts

#include <GUIConstants.au3>

GUICreate("Space Presser" ,120 ,50)

$n2=GUICtrlCreateButton ("Space it",10 ,20)

GUICtrlSetState(-1,$GUI_FOCUS)

$n3=GuiCtrlCreateButton ("Exit it",70 ,20)

GUISetState ()

Do

$msg = GUIGetMsg()

if $msg = $n2 then

while $msg <> $n3

GuiGetMsg()

send ( " " , 1)

WEnd

endif

Until $msg = $n3

I press exit it wont exit please assist

Link to comment
Share on other sites

#include <GUIConstants.au3>

GUICreate("Space Presser", 120, 50)

$n2 = GUICtrlCreateButton("Space it", 10, 20)
GUICtrlSetState(-1, $GUI_FOCUS)
$n3 = GUICtrlCreateButton("Exit it", 70, 20)
GUISetState()

While 1

    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Or $msg = $n3 Then Exit

    If $msg = $n2 Then Send(" ", 1)


WEnd

8)

BTW

Welcome to the forums

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Problem: your GUI has focus, and so recieves the space intead of the target program

Solution: make your GUI lose focus by minimising it, then restoring it after space is sent

#include <GUIConstants.au3>

$GUI = GUICreate("Space Presser", 120, 50)

$n2 = GUICtrlCreateButton("Space it", 10, 20)
GUICtrlSetState(-1, $GUI_FOCUS)
$n3 = GUICtrlCreateButton("Exit it", 70, 20)
GUISetState()

While 1

    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Or $msg = $n3 Then 
        Exit
    EndIf

    If $msg = $n2 Then 
        WinSetState($GUI, "", @SW_MINIMIZE)
        Send(" ", 1)
        WinSetState($GUI, "", @SW_RESTORE)
    EndIf


WEnd

Not Tested.

#)

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...