New topic: Autosend strings to another APP
<http://forums.realsoftware.com/viewtopic.php?t=45805> Page 1 of 1 [ 13 posts ] Previous topic | Next topic Author Message DaveS Post subject: Autosend strings to another APPPosted: Sun Nov 04, 2012 6:05 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4232 Location: San Diego, CA Lets say I have an app with two textfields..... both populated with values. What I want to be able to do.. it click a button.... and have my app.. find the window for an open browser..... insert the value of my first text box.... send a CR/LF.... then insert the 2nd value. Assumptions.... 1) there would only be ONE browser (Safari, IE, Opera etc) 2) there would be two input fields to accept the data. Basically... I am looking to keep username/password info in my app... and have it send the login information to a websites login page. Both for OSX and WIN so... a) can it be done b) can it be done without violating Apple Store rules (I'll take "a" if I can get it. "B" would be nice but not required) _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top ktekinay Post subject: Re: Autosend strings to another APPPosted: Sun Nov 04, 2012 6:23 pm Joined: Mon Feb 05, 2007 5:21 pm Posts: 224 Location: New York, NY I have no idea how you'd do this in Windows. On the Mac, PasswordWallet has a feature that does just what you describe. You press a button in the PW window and floating window opens. You switch to your browser (or whatever), click a button in the floating window or press the option key, and it types the username + tab + password. I can think of two ways to do this: AppleScript, the System Events app, and the Universal Access features, or post the key press events directly to the system queue using system calls I don't know. To do the former: tell application "System Events" keystroke "username" & tab & "password" end tell As for the latter, I wouldn't be surprised if MBS has a plugin for that. _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top DaveS Post subject: Re: Autosend strings to another APPPosted: Sun Nov 04, 2012 6:31 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4232 Location: San Diego, CA Thanks ... I will try that..... Need a Windows solution as well... but I have a few months for that _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top ktekinay Post subject: Re: Autosend strings to another APPPosted: Sun Nov 04, 2012 6:35 pm Joined: Mon Feb 05, 2007 5:21 pm Posts: 224 Location: New York, NY Check the MBS plugins. If Christian has a plugin for this, it probably works across platforms. _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top DaveS Post subject: Re: Autosend strings to another APPPosted: Sun Nov 04, 2012 6:40 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4232 Location: San Diego, CA Well System Events works.. but not correctly.... I tried it from within an RS app and nothing happened ... or nothing I "noticed" >From the AppleScript editor app.... it just pasted the arguments from >"keystroke" command right back into the Applescript editor window.... I don't do "plug-ins"..... long story... _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top timhare Post subject: Re: Autosend strings to another APPPosted: Sun Nov 04, 2012 6:43 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 11773 Location: Portland, OR USA You need to set focus on the other app first. And make sure that the correct field has focus, too. Top timhare Post subject: Re: Autosend strings to another APPPosted: Sun Nov 04, 2012 6:44 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 11773 Location: Portland, OR USA And before you ask, I don't know how. I don't do Mac. Short story. Top charonn0 Post subject: Re: Autosend strings to another APPPosted: Sun Nov 04, 2012 6:51 pm Joined: Mon Apr 02, 2007 2:08 am Posts: 957 Location: San Francisco, CA, USA This sort of automation under Windows tends to be done by sending window messages to the text control in the other app (e.g. WM_SETTEXT). There's also the Windows Automation API. _________________ Boredom Software Top DaveS Post subject: Re: Autosend strings to another APPPosted: Sun Nov 04, 2012 7:01 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4232 Location: San Diego, CA For OSX it works like this tell application "Safari" to activate tell application "System Events" keystroke "username" keystroke (ASCII character 9) keystroke "password" keystroke (ASCII character 13) end tell only problem right now is it ASSUMES Safari is the browser of choice.... Next to find Applescript or some other way to identifiy that a Browser is open.... and WHAT browser it is. _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top DaveS Post subject: Re: Autosend strings to another APPPosted: Sun Nov 04, 2012 7:03 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4232 Location: San Diego, CA charonn0 wrote:This sort of automation under Windows tends to be done by sending window messages to the text control in the other app (e.g. WM_SETTEXT). There's also the Windows Automation API. got an example that doesn't require plugins??? _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top ktekinay Post subject: Re: Autosend strings to another APPPosted: Sun Nov 04, 2012 7:13 pm Joined: Mon Feb 05, 2007 5:21 pm Posts: 224 Location: New York, NY Right, that script requires that the username field already has focus. That's why PW requires the user to set that focus first. _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top charonn0 Post subject: Re: Autosend strings to another APPPosted: Sun Nov 04, 2012 10:16 pm Joined: Mon Apr 02, 2007 2:08 am Posts: 957 Location: San Francisco, CA, USA DaveS wrote:got an example that doesn't require plugins??? Sub SetWindowText(WindowTitle As String, TextToSet As String) Declare Sub SendMessageW Lib "User32" (hwnd As Integer, msg As Integer, wParam As Ptr, lParam As WString) Declare Function FindWindowW Lib "User32" (ClassName As Integer, WindowName As Integer) As Integer Declare Function GetWindow Lib "User32" (hwnd As Integer, Command As Integer) As Integer Declare Function GetWindowTextW Lib "User32" (hwnd As Integer, lpString As ptr, cch As Integer) As Integer Const GW_HWNDNEXT = 2 Const WM_SETTEXT = &h000C Dim hwnd As Integer Dim mb As New MemoryBlock(255) hwnd = FindWindowW(0, 0) Do If GetWindowTextW(hwnd, mb, mb.size) > 0 Then If InStr(mb.WString(0), WindowTitle) > 0 Then SendMessageW(hwnd, WM_SETTEXT, Nil, TextToSet) End If End If hwnd = GetWindow(hwnd, GW_HWNDNEXT) Loop Until hwnd <= 0 End Sub This function sends WM_SETTEXT messages to all top-level windows whose caption (AKA Title) matches. Sending a message to a child window/control will be more work but this should give you some ideas where to get started. Also note that grepping through all top-level windows (as is done here) is expensive, so don't do it in a tight loop. This is all assuming, of course, that all the browsers you want to target implement password boxes as standard text controls instead of some homebrew shenanigans. _________________ Boredom Software Top DaveS Post subject: Re: Autosend strings to another APPPosted: Mon Nov 05, 2012 1:33 am Joined: Sun Aug 05, 2007 10:46 am Posts: 4232 Location: San Diego, CA Thanks... I have a "semi-working" prototype for OSX, the seems to target the default browser and issue the username/password properly.... It needs some more work... and I will post the code when I get it all polished up.... _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 13 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
