XTensionX Posted August 31, 2010 Posted August 31, 2010 (edited) hi, im trying to make the cursor trapped inside my input box, but i dont know why it doesn't work here is my code #include <Misc.au3> $input = InputBox ("Example", "please type your text here","","",150,80) $Pos = WinGetPos($input) _MouseTrap($Pos[0], $Pos[1], $Pos[0] + $Pos[2], $Pos[1] + $Pos[3]) can anyone tell me what i did wrong? thanks Edit: Damn wrong section sry :S Edited August 31, 2010 by XTensionX
kaotkbliss Posted August 31, 2010 Posted August 31, 2010 I've seen on the forums similar situations and the explination given was something along the lines of: When the code hits the input box line, it pauses until the input box is complete, then moves on. I can't remember the solution, but some searching should help you out. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
XTensionX Posted August 31, 2010 Author Posted August 31, 2010 On 8/31/2010 at 2:16 AM, 'kaotkbliss said: I've seen on the forums similar situations and the explination given was something along the lines of:When the code hits the input box line, it pauses until the input box is complete, then moves on.I can't remember the solution, but some searching should help you out.i've been looking around for a while myself aswell.. but i cant seem to find a working answer to this problem
UEZ Posted August 31, 2010 Posted August 31, 2010 (edited) The problem is that InputBox stops the script and is waiting for an input - no other functions e.g. AdlibRegister() will not be performed!There is an example in the help file:#include <GuiConstantsEx.au3> #include <Misc.au3> Opt("MustDeclareVars", 1) _Main() Func _Main() Local $GUI, $coords[4] $GUI = GUICreate("Mouse Trap Example", 392, 323) GUISetState() While 1 $coords = WinGetPos($GUI) _MouseTrap($coords[0], $coords[1], $coords[0] + $coords[2], $coords[1] + $coords[3]) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSwitch WEnd _MouseTrap() Exit EndFunc ;==>_MainYou have to create a GUI!Br,UEZ Edited August 31, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
XTensionX Posted August 31, 2010 Author Posted August 31, 2010 On 8/31/2010 at 5:57 PM, 'UEZ said: The problem is that InputBox stops the script and is waiting for an input - no other functions e.g. AdlibRegister() will not be performed! There is an example in the help file: #include <GuiConstantsEx.au3> #include <Misc.au3> Opt("MustDeclareVars", 1) _Main() Func _Main() Local $GUI, $coords[4] $GUI = GUICreate("Mouse Trap Example", 392, 323) GUISetState() While 1 $coords = WinGetPos($GUI) _MouseTrap($coords[0], $coords[1], $coords[0] + $coords[2], $coords[1] + $coords[3]) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSwitch WEnd _MouseTrap() Exit EndFunc ;==>_Main You have to create a GUI! Br, UEZ i looked into this example aswell.. and i can get the mousetrap working on GUI, but i need it to work on a input box, so theres no way the _mousetrap would work on a input box? :/
kaotkbliss Posted August 31, 2010 Posted August 31, 2010 In otherwords, you have to create a gui that looks and acts just like an inputbox. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
XTensionX Posted August 31, 2010 Author Posted August 31, 2010 On 8/31/2010 at 7:19 PM, 'kaotkbliss said: In otherwords, you have to create a gui that looks and acts just like an inputbox.oh i see gna have to remake my script a little then
martin Posted August 31, 2010 Posted August 31, 2010 (edited) No need to do much at all, certainly no need to make your own gui. I think the code below does what you want . #include <Misc.au3> #include <timers.au3> $t1 = _Timer_SetTimer(0,50,"Trap") $input = InputBox ("Example 001", "please type your text here","","",150,80) func Trap($a,$b,$c,$d) Local $margin = 6;might be better to keep cursor within client area $pos=wingetpos("Example 001") _MouseTrap($Pos[0]+$margin, $Pos[1]+$margin, $Pos[0] + $Pos[2]-$margin, $Pos[1] + $Pos[3]-$margin) _Timer_KillAllTimers(0) EndFunc The margin is needed to prevent sizing arrows appearing. Edited August 31, 2010 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
UEZ Posted August 31, 2010 Posted August 31, 2010 Nice to know that _Timer_SetTimer() is skipping this limit! But after resizing the window "trapping" is not working anymore Br,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
XTensionX Posted September 3, 2010 Author Posted September 3, 2010 On 8/31/2010 at 9:43 PM, 'martin said: No need to do much at all, certainly no need to make your own gui. I think the code below does what you want . #include <Misc.au3> #include <timers.au3> $t1 = _Timer_SetTimer(0,50,"Trap") $input = InputBox ("Example 001", "please type your text here","","",150,80) func Trap($a,$b,$c,$d) Local $margin = 6;might be better to keep cursor within client area $pos=wingetpos("Example 001") _MouseTrap($Pos[0]+$margin, $Pos[1]+$margin, $Pos[0] + $Pos[2]-$margin, $Pos[1] + $Pos[3]-$margin) _Timer_KillAllTimers(0) EndFunc The margin is needed to prevent sizing arrows appearing. thanks it works but sizing arrow still apears, and after after i resize it/move the input box, the mousetrap doesnt work no more :/
martin Posted September 6, 2010 Posted September 6, 2010 On 9/3/2010 at 9:24 PM, 'XTensionX said: thanks it works but sizing arrow still apears, and after after i resize it/move the input box, the mousetrap doesnt work no more :/ I tried this on XP and the margin of 6 keeps the cursor away from the edges so I cannot resize. Maybe you and Uez are using W7. In that case maybe in W7 you need to increase the margin, and maybe have a different margin at the top as my comment in the function. Or if you are resizing using Alt SPACE then choosing sizing, move the killAlltimers line like this #include <Misc.au3> #include <timers.au3> $t1 = _Timer_SetTimer(0,50,"Trap") $input = InputBox ("Example 001", "please type your text here","","",150,80) _Timer_KillAllTimers(0) func Trap($a,$b,$c,$d) Local $margin = 6;might be better to keep cursor within client area $pos=wingetpos("Example 001") _MouseTrap($Pos[0]+$margin, $Pos[1]+$margin, $Pos[0] + $Pos[2]-$margin, $Pos[1] + $Pos[3]-$margin) ;_Timer_KillAllTimers(0) EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
XTensionX Posted September 7, 2010 Author Posted September 7, 2010 On 9/6/2010 at 5:45 AM, 'martin said: I tried this on XP and the margin of 6 keeps the cursor away from the edges so I cannot resize. Maybe you and Uez are using W7. In that case maybe in W7 you need to increase the margin, and maybe have a different margin at the top as my comment in the function. Or if you are resizing using Alt SPACE then choosing sizing, move the killAlltimers line like this #include <Misc.au3> #include <timers.au3> $t1 = _Timer_SetTimer(0,50,"Trap") $input = InputBox ("Example 001", "please type your text here","","",150,80) _Timer_KillAllTimers(0) func Trap($a,$b,$c,$d) Local $margin = 6;might be better to keep cursor within client area $pos=wingetpos("Example 001") _MouseTrap($Pos[0]+$margin, $Pos[1]+$margin, $Pos[0] + $Pos[2]-$margin, $Pos[1] + $Pos[3]-$margin) ;_Timer_KillAllTimers(0) EndFunc it works ^^ thanks, and yes im using W7 =]
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