3dude Posted December 29, 2007 Share Posted December 29, 2007 (edited) Could someone please tell me how can I detect a key being pressed! Example You click "calendar" button => Clendar Opens and old gui hides => Then(here is the problem) if the user presses F9 the Calendar hides and the main gui show again(like a back button) ------- Searched in help file for: "key" "if key pressed" Keystroke" ........ Thanks --- tried with If $msg = Send("F9") Then GUISetState (@SW_HIDE, note1()) GUISetState (@SW_SHOW, $the_GUI) EndIf Please don't laugh Edited December 29, 2007 by 3dude View my blog :) 3dude's blog <= help with project :S Link to comment Share on other sites More sharing options...
searchresult Posted December 29, 2007 Share Posted December 29, 2007 Could someone please tell me how can I detect a key being pressed! Example You click "calendar" button => Clendar Opens and old gui hides => Then(here is the problem) if the user presses F9 the Calendar hides and the main gui show again(like a back button) ------- Searched in help file for: "key" "if key pressed" Keystroke" ........ Thanks --- tried with If $msg = Send("F9") Then GUISetState (@SW_HIDE, note1()) GUISetState (@SW_SHOW, $the_GUI) EndIf Please don't laugh try with _IsPressed function look in help for this function Link to comment Share on other sites More sharing options...
BigDod Posted December 29, 2007 Share Posted December 29, 2007 You could also look for HotKeySet Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
star2 Posted December 29, 2007 Share Posted December 29, 2007 your HotKey is F9 #include <guiconstants.au3> HotKeySet ("{F9}" , "_back") $the_GUI = GUICreate ("Test" , 200 , 80,-1,-1,$WS_CAPTION) $button = GUICtrlCreateButton ("Show Calander" , 20 , 10 , 100, 25) $exit = GUICtrlCreateButton ("Exit" , 20 , 45 , 100, 25) GUISetState (@SW_SHOW, $the_GUI) $date = GUICreate ( "My GUI get date", 200,80,-1,-1,$WS_CAPTION) GUICtrlCreateDate ("1953/04/25", 10,10,185,20,-1) GUISetState (@SW_HIDE, $date) While 1 $msg = GUIGetMsg () Select ; ==== buttons events ====== Case $msg = $exit Exit Case $msg = $button GUISetState (@SW_HIDE, $the_GUI) GUISetState (@SW_SHOW, $date) EndSelect WEnd Func _back () GUISetState (@SW_SHOW, $the_GUI) GUISetState (@SW_HIDE, $date) EndFunc [quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u] Link to comment Share on other sites More sharing options...
3dude Posted December 29, 2007 Author Share Posted December 29, 2007 THANKS!I didn't know that I should use "HotKey"!Thanks a lot! You help me a lot star2 View my blog :) 3dude's blog <= help with project :S Link to comment Share on other sites More sharing options...
star2 Posted December 29, 2007 Share Posted December 29, 2007 you're welcome but BigDod already mentioned that I just gave the example [quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u] Link to comment Share on other sites More sharing options...
3dude Posted December 29, 2007 Author Share Posted December 29, 2007 Yes Thanks to all who help! --- I have a little problem I have two buttons Calendar Note It works with the calendar BUT.... My note is in a Function Func note1() -------------- EndFunc When I click Note it appears but when I press F9 i creates another note See for yourself Func _back () GUISetState (@SW_HIDE, note1()) GUISetState (@SW_SHOW, $the_GUI) EndFunc View my blog :) 3dude's blog <= help with project :S Link to comment Share on other sites More sharing options...
star2 Posted December 29, 2007 Share Posted December 29, 2007 Func _back () GUISetState (@SW_HIDE, note1()) GUISetState (@SW_SHOW, $the_GUI) EndFunc the statement : GUISetState (@SW_HIDE, note1()) is not correct instead of putting the [ note1() ] you should put the GUI that u wish to hide I don't know if this helps but if u want u can post your script and we can help [quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u] Link to comment Share on other sites More sharing options...
Swift Posted December 29, 2007 Share Posted December 29, 2007 he would probably rather PM It too you...its a big program for him Link to comment Share on other sites More sharing options...
3dude Posted December 29, 2007 Author Share Posted December 29, 2007 expandcollapse popup#include <guiconstants.au3> #include <Misc.au3> HotKeySet ("{F9}" , "_back") $the_GUI = GUICreate ("Test" , 150 , 120,-1,-1,$WS_CAPTION) $button = GUICtrlCreateButton ("Show Calander" , 20 , 10 , 100, 25) $button2 = GUICtrlCreateButton ("Make Note" , 20 , 80 , 100, 25) $exit = GUICtrlCreateButton ("Exit" , 20 , 45 , 100, 25) GUISetState (@SW_SHOW, $the_GUI) $date = GUICreate ( "My GUI get date", 200,80,-1,-1,$WS_CAPTION) WinSetTrans("My GUI get date", "", 95) ;_________________ Func date() $date = GUICreate ( "My GUI get date", 200,220,-1,-1, $WS_CAPTION);$WS_POPUP WinSetTrans("My GUI get date", "", 95) $back = GUICtrlCreateButton ("Back" , 50 , 200 , 85, 20) GUICtrlCreateMonthCal('', 0, 0, 200, 200) EndFunc Func note1() Opt("GUIResizeMode",102); $GUI_DOCKBORDERS 102 2+4+32+64 so the control will grow as the window Dim $InitText = "Click here to edit."&@CRLF&"Click on the edges to drag the memo." Dim $Width = 240 Dim $Height = 200 $dll = DllOpen("user32.dll");for use with _IsPressed $nMemo = GUICreate("MemoBlock Memo", 240,200,-1,-1,$WS_POPUP,$WS_EX_TOOLWINDOW) GUISetFont(8,400,0,"Verdana") GUISetBkColor(0xFFF177) $nMemoText = GUICtrlCreateEdit($InitText,10,10,220,170,$ES_WANTRETURN,0) GUICtrlSetBkColor(-1,0xFFF177) $nResize = GUICtrlCreateLabel("",240-15,200-15,15,15);resize label GUICtrlSetCursor ( -1, 12 ) GUICtrlSetResizing(-1,$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT+$GUI_DOCKRIGHT+$GUI_DOCKBOTTOM) WinSetTrans($nMemo,"",200) GUISetState(@SW_SHOWNOACTIVATE ) WinSetOnTop($nMemo,"",1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $nResize If GUICtrlRead($nMemoText) = $InitText Then; erase the default text GUICtrlSetData($nMemoText,"") EndIf $wPos = WinGetPos($nMemo); element 2 x 3 is width x height $iPos = MouseGetPos(); initial mouse position While _IsPressed(01,$dll) $mPos = MouseGetPos() WinMove($nMemo,"",$wPos[0],$wPos[1],$wPos[2]+$mPos[0]-$iPos[0],$wPos[3]+$mPos[1]-$iPos[1]) WEnd $wPos = WinGetPos($nMemo) $Width = $wPos[2] $Height = $wPos[3] Case -7; case mouse down on GUI If GUICtrlRead($nMemoText) = $InitText Then; erase the default text GUICtrlSetData($nMemoText,"") EndIf $wPos = WinGetPos($nMemo);get the initial window position and mouse position and use it to calculate the movement $mPos = MouseGetPos() $x = $mPos[0]-$wPos[0] $y = $mPos[1]-$wPos[1] $Mouse = GUIGetCursorInfo($nMemo) If Not $Mouse[4] Then While _IsPressed(01,$dll) $nPos = MouseGetPos() $NewPosX = $nPos[0]-$x $NewPosY = $nPos[1]-$y If $NewPosX < 0 Then $NewPosX = 0 ElseIf $NewPosX > @DesktopWidth - $Width Then $NewPosX = @DesktopWidth - $Width EndIf If $NewPosY < 0 Then $NewPosY = 0 ElseIf $NewPosY > @DesktopHeight - $Height Then $NewPosY = @DesktopHeight - $Height EndIf WinMove($nMemo,"",$NewPosX,$NewPosY) WEnd EndIf EndSwitch WEnd DllClose($dll) EndFunc $back = GUICtrlCreateButton ("Back" , 20 , 45 , 100, 300) GUICtrlCreateDate ("1953/04/25", 10,10,185,20 ) GUISetState (@SW_HIDE, $date) While 1 $msg = GUIGetMsg () Select ; ==== buttons events ====== Case $msg = $exit Exit Case $msg = $button GUISetState (@SW_HIDE, $the_GUI) GUISetState (@SW_SHOW, date()) Case $msg = $back GUISetState (@SW_SHOW, $the_GUI) GUISetState (@SW_HIDE, $date) Case $msg = $button2 GUISetState (@SW_HIDE, $the_GUI) GUISetState (@SW_SHOW, note1()) EndSelect WEnd Func _back () GUISetState (@SW_HIDE, note1()) GUISetState (@SW_SHOW, $the_GUI) EndFunc I got the note1 function from Manadar because it's is great and i don't know how to make it View my blog :) 3dude's blog <= help with project :S Link to comment Share on other sites More sharing options...
3dude Posted December 29, 2007 Author Share Posted December 29, 2007 Help? View my blog :) 3dude's blog <= help with project :S Link to comment Share on other sites More sharing options...
star2 Posted December 29, 2007 Share Posted December 29, 2007 (edited) hope this can help expandcollapse popup#include <guiconstants.au3> #include <Misc.au3> HotKeySet ("{F9}" , "_back") ; =============== the Main GUI ============ $main_GUI = GUICreate ("The Main GUI" , 150 , 120,-1,-1,$WS_CAPTION) $show_caland = GUICtrlCreateButton ("Show Calander" , 20 , 10 , 100, 25) $show_memo = GUICtrlCreateButton ("Make Note" , 20 , 80 , 100, 25) $exit = GUICtrlCreateButton ("Exit" , 20 , 45 , 100, 25) GUISetState (@SW_SHOW,$main_GUI) ; ========== the DATE GUI ================ $date_GUI = GUICreate ( "My GUI get date", 200,220,-1,-1, $WS_CAPTION);$WS_POPUP WinSetTrans("My GUI get date", "", 95) $back = GUICtrlCreateButton ("Back" , 50 , 200 , 85, 20) GUICtrlCreateMonthCal('', 0, 0, 200, 200) GUISetState (@SW_HIDE , $date_GUI) ; ========== the Memo GUI ================ Opt("GUIResizeMode",102); $GUI_DOCKBORDERS 102 2+4+32+64 so the control will grow as the window Dim $InitText = "Click here to edit."&@CRLF&"Click on the edges to drag the memo." Dim $Width = 240 Dim $Height = 200 $dll = DllOpen("user32.dll");for use with _IsPressed $nMemo = GUICreate("MemoBlock Memo", 240,200,-1,-1,$WS_POPUP,$WS_EX_TOOLWINDOW) GUISetFont(8,400,0,"Verdana") GUISetBkColor(0xFFF177) $nMemoText = GUICtrlCreateEdit($InitText,10,10,220,170,$ES_WANTRETURN,0) GUICtrlSetBkColor(-1,0xFFF177) GUICtrlSetCursor ( -1, 5 ) WinSetTrans($nMemo,"",200) GUISetState(@SW_HIDE,$nMemo) WinSetOnTop($nMemo,"",1) While 1 $nMsg = GUIGetMsg () $t = GUIGetCursorInfo ($nMemo) Select Case $nMsg = $exit Exit Case $nMsg = $back GUISetState (@SW_HIDE,$date_GUI) GUISetState (@SW_HIDE,$nMemo) GUISetState (@SW_SHOW,$main_GUI) Case $nMsg = $show_caland _date() Case $nMsg = $show_memo _Memo() Case $t[4] = 8201 And $t[2] =1 If GUICtrlRead ($nMemoText) = $InitText Then GUICtrlSetData($nMemoText,"") EndIf EndSelect WEnd DllClose($dll) Func _back () GUISetState (@SW_HIDE,$date_GUI) GUISetState (@SW_HIDE,$nMemo) GUISetState (@SW_SHOW,$main_GUI) EndFunc Func _date() GUISetState (@SW_SHOW,$date_GUI) GUISetState (@SW_HIDE,$main_GUI) EndFunc Func _Memo() GUISetState (@SW_HIDE,$date_GUI) ;GUISetState (@SW_HIDE,$main_GUI) GUISetState (@SW_SHOW,$nMemo) EndFunc ####### Star2 ####### Edited December 29, 2007 by star2 [quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u] Link to comment Share on other sites More sharing options...
ashley Posted December 29, 2007 Share Posted December 29, 2007 ...Please don't laughlol your quite new to the fourms... now if it was some1 like Jos who asked that question then we would laugh. but your new and you need to get used to all the functions first...Welcome to the fourms Free icons for your programs Link to comment Share on other sites More sharing options...
3dude Posted December 30, 2007 Author Share Posted December 30, 2007 Joined: 11-September 07 Not quite new but I am new to AutoIt so View my blog :) 3dude's blog <= help with project :S Link to comment Share on other sites More sharing options...
3dude Posted December 30, 2007 Author Share Posted December 30, 2007 :mad: Now the dam note can't move....... View my blog :) 3dude's blog <= help with project :S Link to comment Share on other sites More sharing options...
star2 Posted December 30, 2007 Share Posted December 30, 2007 :mad: Now the dam note can't move.......when I posted my reply I was sleeping !! really but don't know exactly what did I postnow tell me what about your note? [quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u] Link to comment Share on other sites More sharing options...
3dude Posted December 30, 2007 Author Share Posted December 30, 2007 when you click Note it appear and when you press F9 it goes back BUT I cant move the note! it stays centered! I my previous code it moved when you grab it on the edge View my blog :) 3dude's blog <= help with project :S Link to comment Share on other sites More sharing options...
star2 Posted December 30, 2007 Share Posted December 30, 2007 (edited) expandcollapse popup#include <guiconstants.au3> #include <Misc.au3> HotKeySet ("{F9}" , "_back") ; =============== the Main GUI ============ $main_GUI = GUICreate ("The Main GUI" , 150 , 120,-1,-1,$WS_CAPTION) $show_caland = GUICtrlCreateButton ("Show Calander" , 20 , 10 , 100, 25) $show_memo = GUICtrlCreateButton ("Make Note" , 20 , 80 , 100, 25) $exit = GUICtrlCreateButton ("Exit" , 20 , 45 , 100, 25) GUISetState (@SW_SHOW,$main_GUI) ; ========== the DATE GUI ================ $date_GUI = GUICreate ( "My GUI get date", 200,220,-1,-1, $WS_CAPTION);$WS_POPUP WinSetTrans("My GUI get date", "", 95) $back = GUICtrlCreateButton ("Back" , 50 , 200 , 85, 20) GUICtrlCreateMonthCal('', 0, 0, 200, 200) GUISetState (@SW_HIDE , $date_GUI) ; ========== the Memo GUI ================ Opt("GUIResizeMode",102); $GUI_DOCKBORDERS 102 2+4+32+64 so the control will grow as the window Dim $InitText = "Click here to edit."&@CRLF&"Click on the edges to drag the memo." Dim $Width = 240 Dim $Height = 200 $dll = DllOpen("user32.dll");for use with _IsPressed $nMemo = GUICreate("MemoBlock Memo", 240,200,-1,-1,$WS_POPUP,$WS_EX_TOOLWINDOW) GUISetFont(8,400,0,"Verdana") GUISetBkColor(0xFFF177) $nMemoText = GUICtrlCreateEdit($InitText,10,10,220,170,$ES_WANTRETURN,0) GUICtrlSetBkColor(-1,0xFFF177) GUICtrlSetCursor ( -1, 5 ) WinSetTrans($nMemo,"",200) GUISetState(@SW_HIDE,$nMemo) WinSetOnTop($nMemo,"",1) While 1 $nMsg = GUIGetMsg () $t = GUIGetCursorInfo ($nMemo) Select Case $nMsg = $exit Exit Case $nMsg = $back GUISetState (@SW_HIDE,$date_GUI) GUISetState (@SW_HIDE,$nMemo) GUISetState (@SW_SHOW,$main_GUI) Case $nMsg = $show_caland _date() Case $nMsg = $show_memo _Memo() Case $t[4] = 8201 And $t[2] =1 If GUICtrlRead ($nMemoText) = $InitText Then GUICtrlSetData($nMemoText,"") EndIf EndSelect $wPos = WinGetPos($nMemo);get the initial window position and mouse position and use it to calculate the movement $mPos = MouseGetPos() $x = $mPos[0]-$wPos[0] $y = $mPos[1]-$wPos[1] $Mouse = GUIGetCursorInfo($nMemo) If Not $Mouse[4] Then While _IsPressed(01,$dll) $nPos = MouseGetPos() $NewPosX = $nPos[0]-$x $NewPosY = $nPos[1]-$y If $NewPosX < 0 Then $NewPosX = 0 ElseIf $NewPosX > @DesktopWidth - $Width Then $NewPosX = @DesktopWidth - $Width EndIf If $NewPosY < 0 Then $NewPosY = 0 ElseIf $NewPosY > @DesktopHeight - $Height Then $NewPosY = @DesktopHeight - $Height EndIf WinMove($nMemo,"",$NewPosX,$NewPosY) WEnd EndIf WEnd DllClose($dll) Func _back () GUISetState (@SW_HIDE,$date_GUI) GUISetState (@SW_HIDE,$nMemo) GUISetState (@SW_SHOW,$main_GUI) EndFunc Func _date() GUISetState (@SW_SHOW,$date_GUI) GUISetState (@SW_HIDE,$main_GUI) EndFunc Func _Memo() GUISetState (@SW_HIDE,$date_GUI) ;GUISetState (@SW_HIDE,$main_GUI) GUISetState (@SW_SHOW,$nMemo) EndFunc Don't lazy make some test and search around. Edited December 30, 2007 by star2 [quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u] Link to comment Share on other sites More sharing options...
3dude Posted December 30, 2007 Author Share Posted December 30, 2007 Thanks a lot but how did you do it? View my blog :) 3dude's blog <= help with project :S Link to comment Share on other sites More sharing options...
star2 Posted December 30, 2007 Share Posted December 30, 2007 Thanks a lot but how did you do it?OMG !!you didn't read the script? it was already provided by you !!######### Star2 ########### [quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now