Sign in to follow this  
Followers 0
oneLess

press key including hotkey

6 posts in this topic

i made a custom window [message window]

inside a GUI

this custom window is closed by moving a mouse at least 18 pixels on x or y , or by pressing {ESC}

Func _MsgBox_move_mouse ( $_string_1_mm , $_string_2_mm , $_sound_mode_mm , $_fontbold_mm , $_fer_mm );
... 
drawing the custom message GUI and other stuff
... 
$_pos_1_mm = MouseGetPos ( )
Sleep (100)
While 1
    Sleep ( 300 )
    $_msg_mm   = GUIGetMsg ( )
    $_pos_2_mm = MouseGetPos ( )
    $modulo_X  = $_pos_2_mm[0] - $_pos_1_mm[0]
    $modulo_Y  = $_pos_2_mm[1] - $_pos_1_mm[1]
    If $modulo_X < 0 Then $modulo_X = - $modulo_X
    If $modulo_Y < 0 Then $modulo_Y = - $modulo_Y
    If $modulo_X > $modulo_Y Then 
        $modulo =  $modulo_X
    Else
        $modulo =  $modulo_Y
    EndIf
    If $modulo > 18 Then ExitLoop
    If $_msg_mm = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
....
delete the custom message GUI and other stuff
....
EndFunc

i want to leave the while loop , also , when ANY key is pressed , including here hotkeys

search button dont give me any clue ...

with _ispressed ($key) must check all keys in another loop

AU3RECORD i understand is an external .exe

i want to modify the exit conditions something like :

If $modulo > 18 Then ExitLoop

If _any_key_is_pressed_including_hotkeys () Then ExitLoop

If $_msg_mm = $GUI_EVENT_CLOSE Then ExitLoop

can help me something else what i missed ... ?

Share this post


Link to post
Share on other sites



Hi as you've already said to use _IsPressed() to find if a key is pressed you'd need to loop through all the keys.

I now it's a rough around the edges approach, but heregoes ..

#include <Misc.au3>

Opt("MouseCoordMode", 2)

$Gui = GUICreate("Test", 200, 100)
GUISetState()

While 1
    Sleep(10)
    If GUIGetMsg() = -3 Then Exit
    For $i = 8 To 255
        $MGP = MouseGetPos()
        If $MGP[0] >= 18 And $MGP[0] <= 182 And $MGP[1] >= 18 And $MGP[1] <= 82 And _IsPressed(StringFormat("%02x", $i)) Then Exit  
    Next    
WEnd

Cheers

Share this post


Link to post
Share on other sites

thank you very much smashly !

my little problem is solved .

i have only one question .

like you can see in the attached script [a small sample]

if you press the button , after that press F5 and after that press F6

i will have 3 message windows on screen .

so , this look like _IsPressed DO NOT catch the hotkeys

[the other hotkeys , because the active hotkey is disabled temporary in its own function]

is another thing i can do for cathing with _IsPressed the other hotkeys ?

or only something like

;----------------------------------------------------------------------------
    HotKeySet("{F5}", "_my_function")
;----------------------------------------------------------------------------
    Func _my_function ( )
    ;HotKeySet("{F5}")
        _disable_all_hotkeys ( )
    ; stuff here
        _MsgBox_move_mouse ( "another message for you" , "" , 1 , "Arial Bold" , WinGetHandle ("") )
        _enable_all_hotkeys ( )
    ;HotKeySet("{F5}", "_my_function")
    EndFunc
;----------------------------------------------------------------------------

_test_IsPressed.au3

Share this post


Link to post
Share on other sites

#include <Misc.au3>
    ;----------------------------------------------------------------------------
    Func _any_key_is_pressed ( )
        Local $_key_pressed = False
        For $i = 1 To 255
            If _IsPressed(StringFormat("%02x", $i)) Then 
                $_key_pressed = True 
                ExitLoop
            EndIf
        Next    
        Return $_key_pressed
    EndFunc
    ;----------------------------------------------------------------------------

DO NOT catch hotkeys ![?]

any other idea than mine above ?

Share this post


Link to post
Share on other sites

SOLVED , like i wanted .

you can see the difference betwen {F5} and {F6} hotkeys .

thank you for tip smashly .

_test_IsPressed.au3

Share this post


Link to post
Share on other sites

Do an exit check in your hotkey function..

#include <Misc.au3>

Opt("MouseCoordMode", 2)

HotKeySet("{F5}", "F5HotKeyFunc")
HotKeySet("{F6}", "F6HotKeyFunc")

$Gui = GUICreate("Test", 200, 100)
GUISetState()

While 1
    Sleep(10)
    If GUIGetMsg() = -3 Then Exit
    ExitCheck()
WEnd

Func F5HotKeyFunc()
    If ExitCheck() = 0 Then MsgBox(0,'', "Well F5 was pressed and the exit check returned so I won't exit")
EndFunc

Func F6HotKeyFunc()
    If ExitCheck() = 0 Then MsgBox(0,'', "Well F6 was pressed and the exit check returned so I won't exit")
EndFunc

Func ExitCheck()
    For $i = 8 To 255
        $MGP = MouseGetPos()
        If $MGP[0] >= 18 And $MGP[0] <= 182 And $MGP[1] >= 18 And $MGP[1] <= 82 And _IsPressed(StringFormat("%02x", $i)) Then Exit 
    Next
    Return 0    
EndFunc

Cheers

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