InjuredDeer Posted October 11, 2017 Share Posted October 11, 2017 im making a Gui that when presssing on the button will activate a function. i stopped coding about 10 years ago with au3 and decided to start back up because it is so damn fun. so when i push down on $bottomright1 i want it to run func mousepos() $Form1_1 = GUICreate("Form1", 442, 241, 186, 145) $TopLeft = GUICtrlCreateButton("TopLeft", 72, 16, 75, 25) $TopLeft2 = GUICtrlCreateButton("TopLeft2", 72, 56, 75, 25) $TopLeft3 = GUICtrlCreateButton("TopLeft3", 72, 96, 75, 25) GUICtrlCreateLabel("", 312, 16, 4, 4) $BottomRight2 = GUICtrlCreateButton("BottomRight2", 152, 56, 73, 25) $BottomRight1 = GUICtrlCreateButton("BottomRight1", 152, 16, 73, 25) $BottomRight3 = GUICtrlCreateButton("BottomRight3", 152, 96, 73, 25) GUISetState(@SW_SHOW) Func MousePos() Local $aMgp = 0 While 1 $aMgp = MouseGetPos() ToolTip("x: " & $aMgp[0] & ", y: " & $aMgp[1], $aMgp[0] + 10, $aMgp[1] + 10) Sleep(50) WEnd EndFunc Func _Terminate() Exit EndFunc Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 11, 2017 Moderators Share Posted October 11, 2017 @InjuredDeer welcome to the forum. You need a while loop to look for activity on your GUI, like so: #include <GUIConstantsEx.au3> $Form1_1 = GUICreate("Form1", 442, 241, 186, 145) $TopLeft = GUICtrlCreateButton("TopLeft", 72, 16, 75, 25) $TopLeft2 = GUICtrlCreateButton("TopLeft2", 72, 56, 75, 25) $TopLeft3 = GUICtrlCreateButton("TopLeft3", 72, 96, 75, 25) GUICtrlCreateLabel("", 312, 16, 4, 4) $BottomRight2 = GUICtrlCreateButton("BottomRight2", 152, 56, 73, 25) $BottomRight1 = GUICtrlCreateButton("BottomRight1", 152, 16, 73, 25) $BottomRight3 = GUICtrlCreateButton("BottomRight3", 152, 96, 73, 25) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $BottomRight1 MousePos() EndSwitch WEnd Func MousePos() Local $aMgp = 0 While 1 $aMgp = MouseGetPos() ToolTip("x: " & $aMgp[0] & ", y: " & $aMgp[1], $aMgp[0] + 10, $aMgp[1] + 10) Sleep(50) WEnd EndFunc Func _Terminate() Exit EndFunc Be aware that once you enter your MousePos function you have created an endless While Loop, so it will never leave that function. Earthshine 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
InjuredDeer Posted October 11, 2017 Author Share Posted October 11, 2017 thankyou so much! and yes thankyou for looking at the mousepos() i knew it was endless but thankyou for commenting that also. 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