Kr4mer Posted July 22, 2020 Posted July 22, 2020 Hi everyone, I am able to open rdp session using some script example I found out in forum . After first login I have to enter the credentials again Is there any way to set this textbox with the user and password and finally interact with the remote desktop icons? I appreciate examples related many thanks
argumentum Posted July 22, 2020 Posted July 22, 2020 ..go search in YouTube. It will be the best way for you to understand how it works.This is not an AutoIt issue. Is an user issue. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Kr4mer Posted July 23, 2020 Author Posted July 23, 2020 Hi there, Im trying to reach out some rdp control by using autoIT but I dont see anything related in youtube .My question is there any way to interact with the remote desktop shortcuts and so on? Is there any example that you could share with me? Thanks
argumentum Posted July 23, 2020 Posted July 23, 2020 2 hours ago, Kr4mer said: is there any way to interact with the remote desktop shortcuts In your PC or the remote PC ? I don't really understand the question. If you were to pour your heart out and explain your circumstance and your need.. . Also, how long have you coded for ( just to have an idea of where to start from ). Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Kr4mer Posted July 24, 2020 Author Posted July 24, 2020 Actually, I'm starting off using this tool and learning the code following the help guide, I'm able to make the RDP connection (I have used the example code And now I'm here in this view I would like to click enter (or moving the cursor to OK button) And Finally enter the user/pass again in order to access remote desktop and click there some icons I'm trying to reach out this window using this code: Local $hWnd = WinWait("[CLASS:TscShellContainerClass]", "XXX.XX.XX.XXX - Remote Desktop Connection", 10) ControlClick($hWnd, "", "OPContainerClass") And I'm using the AutoIT window info to get controls info: I'm not really sure if is possible to do something like that with this tool.Any idea suggested? Thanks
Developers Jos Posted July 24, 2020 Developers Posted July 24, 2020 Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
robertocm Posted July 24, 2020 Posted July 24, 2020 On 7/22/2020 at 6:51 PM, Kr4mer said: I appreciate examples related expandcollapse popup#include <Timers.au3> Opt('WinWaitDelay', 250) Opt('WinDetectHiddenText', 1) Opt('MouseCoordMode', 0) Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Opt("MustDeclareVars", 1) ;Check innactive user ;https://stackoverflow.com/questions/3867584/autoit-how-to-get-system-idle-time-or-if-screensaver-is-active ;How to get system idle time, or if screensaver is active? ;The _Timer_GetIdleTime() function uses GetLastInputInfo from user32.dll. Global $Sair, $iLimit = 120 ; idle limit in seconds (5 segundos) If _Timer_GetIdleTime() > $iLimit * 1000 Then ;MsgBox(0, "", "Continue >>") Else ;HotKeySet("ç", "_Quit") AdlibRegister("_CheckIdleTime", 1000) While 1 ;use infinite loop since ExitLoop will get called If $Sair = True Then ;ConsoleWrite("Fin") ExitLoop EndIf Sleep(1000) WEnd ;Outra forma ;Do ;Sleep(1000) ;Until $Sair = True EndIf ;it could help Send("{DOWN}") Sleep(20000) MouseMove(10, 100) If Not WinExists("XX.X.X.XX - Conexión a Escritorio remoto") Then ;https://www.autoitscript.com/forum/topic/97501-auto-mstsc/ ;RunWait('"' & @ComSpec & '" /c MSTSC.EXE C:/yourfile.rdp', '', @SW_HIDE) ;http://support.microsoft.com/kb/941641 Run("C:\windows\system32\mstsc.exe /v:" & "XX.X.X.XX") ;~ ;Wait 90 seconds for the window to appear. Local $hWnd = WinWait("XX.X.X.X - Conexión a Escritorio remoto", "", 90) ;WinActivate($hWnd) ;WinWaitActive($hWnd, "", 60) Else Local $hWnd = WinActivate("XX.X.X.XX - Conexión a Escritorio remoto") WinWaitActive($hWnd, "", 90) WinSetState($hWnd, "", @SW_MAXIMIZE) EndIf Sleep(5000) ;Test if the window is now activated ;You can use the WinActive() function to check if WinActivate() succeeded. If WinActive($hWnd, "") Then ;WinSetState($hWnd, "", @SW_MAXIMIZE) ;MsgBox(0, "", "Window NOW active") Sleep(25000) ;Command line Send ("#r") Sleep(1000) Send("_some_command_") Else ;MsgBox(0, "Error", "Window not active") ;Local $hActive = WinGetHandle("[active]") ;Local $sTitle = WinGetTitle("[active]") ;MsgBox(0, "Error", $sTitle) EndIf Func _CheckIdleTime() If _Timer_GetIdleTime() > $iLimit * 1000 Then ;AdLib functions don't run while a blocking function is shown e.g. MsgBox, InputBox, WinWait, WinWaitClose etc. ;MsgBox(16, "Timeout", "You haven't done anything in " & $iLimit & " seconds... Get busy!") $Sair = True AdlibUnRegister("_CheckIdleTime") EndIf EndFunc
argumentum Posted July 24, 2020 Posted July 24, 2020 10 hours ago, Kr4mer said: here in this view I would like to click enter As a full screen you may not but as a window ( by moving the window ), maybe you can then click at x,y . As far as code, I did some RDP code here in the forum. Look at my signature. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Kr4mer Posted July 26, 2020 Author Posted July 26, 2020 I am able set the text using Send function but I have some problems seems with keyboard layout when I try send a password like this Tfr*~afr using Send but the input sent is all chars in lowcase and special chars wrong.I have tried to set different keyboard layout and set Raw option=1 with same result.This issue happens in RDP textbox windows not in my local apps (In Notepad works ok). Even I can´t access to RDP textbox using the details from AutoIt Windows Info: I also tried what I found out in other related post, but doesn´t work. Is there any way to send exactly text to RDP inputs? thanks for your help
argumentum Posted July 26, 2020 Posted July 26, 2020 (edited) 7 hours ago, Kr4mer said: I can´t access to RDP textbox using the details from AutoIt Windows Info Well, what you have as info is true. You are working with an image of sorts. The CLASS:TscShellContainerClass has the image. ( for all intent and purpose ) 7 hours ago, Kr4mer said: special chars wrong Use Chr() to send the data. Try this out: WinActivate("[CLASS:TscShellContainerClass]") ASCII_TEST() Func ASCII_TEST() For $n = 128 To 254 Send( $n & @TAB & Chr($n) & @CRLF , 1) Sleep(1) Next EndFunc With notepad as the active window, you'll see what character you need. Use those as a translator. Edit: Using _WinAPI_OemToChar() may solve the problem Edited July 26, 2020 by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Kr4mer Posted July 27, 2020 Author Posted July 27, 2020 Hi there, I'm still stuck with this.I'm able to send the text exactly to Notepad (using Chr) but trying to replicated into RDP inputs unsuccessfully. What is the correct way to manage TscShellContainerClass? I'm trying to send the text using ControlSend but I don't have any ControlID to do that. Or is there any other alternative to interact with RDP input windows? Thanks
argumentum Posted July 27, 2020 Posted July 27, 2020 This worked from WinXP to Win10: #include <WinAPIConv.au3> If Not WinWait("[CLASS:TscShellContainerClass]", "", 60) Then Exit 3 Sleep(5000) ; ..give it time to draw the remote WinActivate("[CLASS:TscShellContainerClass]") Send("user" , 1) Send(@TAB , 1) Send("pass" , 1) Send("{ENTER}") Since you can not send to a control, you'll have to do it all via keyboard. It worked for me. Let me know if this solved it. There no other way that I can think of, if mstsc.exe file.rdp don't work due to the "corporate announcement". Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Kr4mer Posted July 27, 2020 Author Posted July 27, 2020 Actually that works properly even only using Send() function even thought the real problem is regarding password. Password changes every 24hrs and uses special chars, I'm able to write the password in Notepad but i can't put the password exactly on RDP password input, the script puts other characters.For instance: notepad:Tfr*~afrMDA-FIQDstDTPDCXMQQv3Z RDP password input:tfrmda;-FIQDstDTPDCXMQQv3Z It has not sense, even I have tried to change other keyboard language and also your other suggestion
mLipok Posted July 27, 2020 Posted July 27, 2020 You should login to this system by hand. Change security setting to not using password and then your problem will gone. Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
argumentum Posted July 27, 2020 Posted July 27, 2020 So there are 2 issues: 1) aim to the proper control by using the keyboard ( Ctrl-A, Tab, etc. ) 2) send the characters ( using _WinAPI_OemToChar() or your own Chr() or ChrW() mapping ) If you have (1) done, (2) is a matter of creating a translation, held in an array maybe. The mapping of your local char. to the remote, is something to discover by trial and error I guess. Maybe the notepad is not the one. Try using MSWord. Maybe the remote input uses Unicode instead of ASCII or go figure. In any case, this is all I can come up with and know of no other way to go at it 2 minutes ago, mLipok said: You should login to this system by hand. Yes, that too. If corporate is making it difficult and you with little experience in coding going at it, ...be very careful to not open doors for unexpected actors ! Admins are not bad people ( I'm not ), and admins do what is needed so people don't say "oops, I didn't know that". Anyway. Don't do too many fail attempts. The Admin could report the activity to the boss. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
robertocm Posted July 27, 2020 Posted July 27, 2020 (edited) 2 hours ago, argumentum said: Maybe the notepad is not the one. Try using MSWord Another idea just for testing: https://stackoverflow.com/a/22348546/6406135 Quote katalin_2003 Another way of doing this, in Windows, is by using wordpad.exe: Run wordpad.exe Write your script as you usually do, with accents Choose Save as > Other formats Choose to save it as Text document MS-DOS (*.txt) Change the file extension from .txt to .bat --- [...] it converts the character codes from ANSI to DOS. – user6017774 Another reference for ideas: https://ss64.org/viewtopic.php?id=2051 Quote bluesxman This a hacky way to do it that I use occasionaly. Paste something like this directly into the cmd window -- don't run it as a script, for (hopefully) obvious reasons: for %X in (a-acc:á e-acc:é i-acc:í o-acc:ó u-acc:ú u:uml:ü n-til:ñ) do (@echo:%X) >> international.txt Open the resulting file in notepad or similar, then copy and paste the "actual" characters to your script in the appropriate places (they'll look wrong in the editor, but should be OK when you run the script). Edited July 27, 2020 by robertocm
Kr4mer Posted July 29, 2020 Author Posted July 29, 2020 Ok, now the script open RDP properly,Second task is launch some application in RDP desktop, I'm trying use ShellExecuteWait("notepad.exe") and Run("notepad.exe") but it works in my local desktop not in RDP window. How can launch the applications in RDP? Thanks
robertocm Posted July 29, 2020 Posted July 29, 2020 (edited) 13 minutes ago, Kr4mer said: How can launch the applications in RDP? Try: Sleep(5000) Send ("#r") Sleep(1000) Send("notepad.exe") If you can save (and execute) compiled scripts in the server: Try to start the compiled script with the "#r" "method" (you can pass parameters in the same command line) Place all the functions in the compiled script saved in the server (not interacting from the local script) A created file in a shared folder can be used as a "semaphore" to coordinate both scripts (local and remote) Be very careful with functions used in remote scripts (screen captures or proccess functions can report false positives) Edited July 29, 2020 by robertocm
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