Jango Posted September 29, 2008 Share Posted September 29, 2008 Hello, I use the following script to send user and password to an application and it works. The shortcut is in the quick launch bar (one click). But, some users do a double click in the quick launch bar and then my script fail because the window looses focus even if i put a WinActivate just before sending user/pwd. Any help is welcome. $Start = TimerInit() While 1 If TimerDiff($Start) > $TimeOut Then ExitLoop If WinExists($Title) Then WinActivate($Title) Send($User) Send("{TAB}") Send($Pwd) Send("{ENTER}") ExitLoop EndIf Sleep(100) WEnd Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 29, 2008 Share Posted September 29, 2008 $Start = TimerInit() While 1 If TimerDiff($Start) >= $TimeOut Then ExitLoop If WinExists($Title) Then WinActivate($Title) Sleep(500);allow the program focus to take effect Send($User) Send("{TAB}") Sleep(500);wait to make sure the control has registered Send($Pwd) Send("{ENTER}") ExitLoop EndIf Sleep(100) WEnd I'd also recommend you use ControlSend() and not just Send/tab/etc. That way the controls will get the data even if the window doesn't have the focus, you don't need to tab, and you can ControlClick() the send/enter/next button. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
rasim Posted September 29, 2008 Share Posted September 29, 2008 Use a ControlSend() function. Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 29, 2008 Share Posted September 29, 2008 I believe I already mentioned that . Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
November Posted September 29, 2008 Share Posted September 29, 2008 Use a ControlSend() function.Hi there,Or you can add _Singleton to your script and keep it smooth to run only one instance of your script.Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 29, 2008 Share Posted September 29, 2008 From what I read the problem is the event is triggered by a single click but when a person double clicks it takes focus away from the control/program being manipulated and sets focus to the tray icon so I don't see how _Singleton would help. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Zedna Posted September 29, 2008 Share Posted September 29, 2008 Also look at SendKeepActive() - Attempts to keep a specified window active during Send().It's relatively new AutoIt's native function introduced in version 3.2.10.0 (25th November, 2007) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Jango Posted September 29, 2008 Author Share Posted September 29, 2008 From what I read the problem is the event is triggered by a single click but when a person double clicks it takes focus away from the control/program being manipulated and sets focus to the tray icon so I don't see how _Singleton would help.Correct. thank you for your help. Link to comment Share on other sites More sharing options...
Jango Posted September 29, 2008 Author Share Posted September 29, 2008 Also look at SendKeepActive() - Attempts to keep a specified window active during Send(). It's relatively new AutoIt's native function introduced in version 3.2.10.0 (25th November, 2007) Here is my code corrected : $Start = TimerInit() While 1 If TimerDiff($Start) > $TimeOut Then ExitLoop If WinExists($Title) Then $Handle = WinGetHandle($Title) ControlSend($Handle, "", "Edit2", $User) ControlSend($Handle, "", "Edit3", $Pwd) ControlClick($Handle, "OK", "Button1") ExitLoop EndIf Sleep(100) WEnd 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