Sign in to follow this  
Followers 0
dufran3

Ctrl+Shift+Click on an icon

5 posts in this topic

I want to create an icon on a GUI...

$iKey = GUICtrlCreateIcon($LocalIconPath & 'key.ico','',390,473,16,16)
oÝ÷ ØÚ0¶­¶¢râ²Ø^­æ§v©§"$"|vØb±·¥£­Â)e®éíꮢÔÞ²Ú®¢×îËb¢|!z{az'(+'$yÚ'"Ëaz·Á¬­¢f¤z+l¢ØZ¶+pYg¢×hj|­)àºy^²À­®_'íùÉbrJ'Ó«ë-J·à¥É(+ZºÚ"µÍÕRPÝÙ]Û][
    ÌÍÚRÙ^K ÌÎN×ÕÝ ÌÎNÊH

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

There's probly a better way to do it...

#include <GUIConstants.au3>
#include <Misc.au3>
Opt("GUIOnEventMode", 1)

GUICreate('Test', 130,100)
$iKey = GUICtrlCreateIcon('Shell32.dll',45,20,20,16,16)
GUICtrlSetOnEvent($iKey, '_Test')
GUISetOnEvent($GUI_EVENT_CLOSE, 'Close')
GUISetState()

While 1
    Sleep (10)
WEnd

Func _Test()
    $dll = DllOpen("user32.dll")
    If _IsPressed('11', $dll )  And _IsPressed('10', $dll) Then ;Press Ctrl + Shift (11 = Ctrl  , 10 = Shift)
        ;;;; Your code here
        MsgBox(0,'', 'Yep')
    EndIf
    $dll = DllClose($dll)
EndFunc

Func Close()
    Exit
EndFunc

As you can see the _Test function is still called , but if the keys aren't pressed then it shouldn't launch the "Your code here".

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites

That's not bad smashly, although putting the DllOpen/Close inside the function is kind of redundant to the point of using DllOpen/Close. The reason you use these functions is so that during the entirety of your script you only load the dll file once, and unload it once you're completely done with it.

I would suggest the following modification:

#include <GUIConstants.au3>
#include <Misc.au3>
Opt("GUIOnEventMode", 1)

Global $user32dll = DllOpen("user32.dll")

GUICreate('Test', 130,100)
$iKey = GUICtrlCreateIcon('Shell32.dll',45,20,20,16,16)
GUICtrlSetOnEvent($iKey, '_Test')
GUISetOnEvent($GUI_EVENT_CLOSE, 'Close')
GUISetState()

While 1
    Sleep (10)
WEnd

Func _Test()
    If _IsPressed('11', $user32dll )  And _IsPressed('10', $user32dll) Then ;Press Ctrl + Shift (11 = Ctrl  , 10 = Shift)
        ;;;; Your code here
        MsgBox(0,'', 'Yep')
    EndIf
EndFunc

Func Close()
    DllClose($user32dll)
    Exit
EndFuncoÝ÷ Ø mz¹Ú¶+Þ(Ê·ö·®²)ඦzËéh¢¨u觲×vÞ½éí^#]v(ëax%G­+ºÚ"µÍÚ[ÛYH   ÑÕRPÛÛÝ[Ë]LÉÝÂÚ[ÛYH  ÓZØË]LÉÝÂÛØ[    ÌÍÝÙÌHÜ[  ][ÝÝÙÌ  ][ÝÊBÕRPÜX]J    ÌÎNÕÝ   ÌÎNËLÌL
BÌÍÚRÙ^HHÕRPÝÜX]RXÛÛ   ÌÎNÔÚ[Ì    ÌÎNË

KMMBÕRTÙ]Ý]J
BÚ[HB  ÌÍÙÛHHÕRQÙ]ÙÊ
BÝÚ]Ú    ÌÍÙÛBØÙH  ÌÍÚRÙ^BYÒÔÜÙY
    ÌÎNÌLIÌÎNË    ÌÍÝÙÌ
H[ÒÔÜÙY
    ÌÎNÌL    ÌÎNË ÌÍÝÙÌ
H[ÔÜÈÝ
ÈÚY
LHHÝLHÚY
BÎÎÎÈ[ÝÛÙHBÙÐÞ
    ÌÎNÉÌÎNË  ÌÎNÖY    ÌÎNÊB[YØÙH ÌÍÑÕRWÑUSÐÓÔÑB^]ÛÜ[ÝÚ]ÚÑ[ÛÜÙJ ÌÍÝÙÌ

Either of those should work.

Share this post


Link to post
Share on other sites

Nice catch saunders :shocked:

Yep as you can tell I'm still very newb to autoit scripting and I have no gerat talent for it ...yet :(

Most the time straight out logic fails me..lol

Cheers

Share this post


Link to post
Share on other sites

Sweet, that is exactly what I needed, thanks both of you!

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