Sign in to follow this  
Followers 0
Flok3r

Lose focus with _IsPressed

3 posts in this topic

Hi you kind supporters,

My tool has a structure like that (in script steps):

-GUI is built

-Window is hidden with GUISetState(@SW_HIDE)

-typicall while 1 loop checking for GUIGetMsg() AND checking:

If _IsPressed("01",$dll) And _IsPressed("02",$dll) Then "make GUI visible"

My actual problem refers to ispressed (which has to be used in order to manage simultanious keystrokes, i assume?!): If i enter keys like TAB or arrow keys (which are not triggered in my script) while the tool is hidden, the current window, e.g. FireFox, loses its focus. How can i avoid that but still trigger an action by simultanious key-/mousestrokes?

Since im a newbe, there are perhaps better solutions than _IsPressed and perhaps there is a better way than including this check as If block in a while loop??!

Thanks for any advice / suggestion / help,

Flok3r

Share this post


Link to post
Share on other sites



Flok3r,

This works fine for me: :>

#include <GUIConstantsEx.au3>
#include <Misc.au3>

$dll = DllOpen("user32.dll")

$hGUI = GUICreate("Test", 500, 500)

GUISetState(@SW_HIDE)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            DllClose($dll)
            Exit
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE)
    EndSwitch

    If _IsPressed("01", $dll) And _IsPressed("09", $dll) Then ; Left mouse and TAB
        GUISetState(@SW_SHOW)
        GUISetState(@SW_RESTORE)
    EndIf

WEnd

I do not really understand:

If i enter keys like TAB or arrow keys (which are not triggered in my script) while the tool is hidden, the current window, e.g. FireFox, loses its focus

For me the keys act in the active GUI which remains active. :unsure:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks for your fast help, im sorry that my question wasnt clear, but now (i just modified my script, but cant point out the respecting part) i cant even reproduce that "behaviour", i.d. all windows with editable controls remain active/focused while pressing tab or "right" for example.

If someone troubles like i did, here 2 reasons, which could have been my problem:

-The while loop contains too many of those checks, wich look for keys pressed simultaniously (slow PC)

-A antivirus software might check the script or a part of it (as avira did with mine) and suspend it while examining it or so, which leads to the focus loss

I am sure, that behaviour will reappear after further modifications, because i troubled the past weeks with it (must have been this function), but considered it as a bug (perhaps it is one).

I will post a new question if i manage to figure out, what triggers that focus loss.

Share this post


Link to post
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
Sign in to follow this  
Followers 0