Jump to content

IsPressed issue


Recommended Posts

I set up an IsPressed function but I'm having an issue with it. It initially works fine, however, the way I have it set up is when you press enter, the function will start. With this particular function, if nothing is in an input box, a message box pops up indicating that they need to put something in.

So here is the problem:

When that message box pops up and I press enter to get rid of the message box, for some reason it registers on the GUI and submits again....this now starts a kind of loop. When I press enter to get rid of the message, the GUI thinks I'm trying to submit again without entering anything and the message box pops right back up again. This doesn't make sense to me because the message box is the top window. I tried some if statements like "winactive" and a few others to solve this, but that's not working. The same thing happens if I use hotkey.

This is basically what I have:

while 1
 If _IsPressed("0d") Then go()
wend

func go()

blah blah blah

endfunc

I don't think the full script is needed for this, but if so let me know.

Edited by Champak
Link to comment
Share on other sites

You first need to test that a particular window is active. If not, you pass the command on. This example (a simple Ctrl-A, for SelectAll in a text input) based on the example in the manual, demonstrates the concept...

func DoSelectAll()
    if WinActive($my_window) then
        GUICtrlSetState($input, $GUI_FOCUS) 
    else
        HotKeySet("^a")
        Send("^a")
        HotKeySet( "^a" , "DoSelectAll")
    endif
endfunc

The other window's hotkey function would have a similar code block. Winactive() uses the window handle, so there should be no ambiguity. If that's not working, then yes, we'll probably need to see your code, because something in it must be interfering.

-mu

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