Leaderboard
Popular Content
Showing content with the highest reputation on 11/28/2017 in all areas
-
CompileIt - an experimental AutoIt-to-machine code compiler
Dotaznik and 2 others reacted to scintilla4evr for a topic
Okay, this is exciting. I'm proud to introduce CompileIt - an experimental compiler, that allows to compile AutoIt to machine code. ...Kind of. CompileIt does compilation in a similar way the Glasgow Haskell compiler does: translates the code into a lower-level language (in CompileIt's case it's C), and then compiles the code in that language. Now, this project is still in its infancy, since, although it is simple to use, AutoIt is incredibly complex on the inside (automation, COM, etc.). So, CompileIt can compile only a very small subset of what we know as AutoIt. Here's a list of things CompileIt (partially) supports (or not): Numbers, booleans, strings Some built-in functions If, For and While statements Exporting DLL functions (you can now write DLL's in AutoIt, guys!) No arrays, automation, GUI or COM. A more detailed list is included with CompileIt. CompileIt is written in AutoIt (the compiler interface), JavaScript (parser, executed with ChakraCore), and of course C. GCC is required to compile scripts. After you extract the files, run CompileIt.exe and configure it to work with GCC.3 points -
CompileIt - an experimental AutoIt-to-machine code compiler
scintilla4evr and one other reacted to Skysnake for a topic
Got this far -------------- Build: Debug in CompileItExample (compiler: GNU GCC Compiler)--------------- mingw32-gcc.exe -Wall -g -c "C:\AutoIt\CompileIt\project\#1 - Hello, World!.c" -o "obj\Debug\#1 - Hello, World!.o" mingw32-gcc.exe -Wall -g -c C:\AutoIt\CompileIt\project\AutoItFuncs.c -o obj\Debug\AutoItFuncs.o C:\AutoIt\CompileIt\project\AutoItFuncs.c: In function 'au3_stringlen': C:\AutoIt\CompileIt\project\AutoItFuncs.c:32:5: warning: passing argument 1 of 'wcslen' from incompatible pointer type [enabled by default] return int_variant(wcslen(vt.data_ptr)); ^ In file included from C:\AutoIt\CompileIt\project\AutoItFuncs.c:4:0: c:\program files (x86)\codeblocks\mingw\include\string.h:133:40: note: expected 'const wchar_t *' but argument is of type 'int *' _CRTIMP size_t __cdecl __MINGW_NOTHROW wcslen (const wchar_t*); ^ C:\AutoIt\CompileIt\project\AutoItFuncs.c: In function 'au3_stringreverse': C:\AutoIt\CompileIt\project\AutoItFuncs.c:38:5: warning: passing argument 1 of 'wcsrev' from incompatible pointer type [enabled by default] return string_variant(wcsrev(vt.data_ptr)); ^ In file included from C:\AutoIt\CompileIt\project\AutoItFuncs.c:4:0: c:\program files (x86)\codeblocks\mingw\include\string.h:185:42: note: expected 'wchar_t *' but argument is of type 'int *' _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcsrev (wchar_t*); ^ C:\AutoIt\CompileIt\project\AutoItFuncs.c: In function 'au3_stringcompare': C:\AutoIt\CompileIt\project\AutoItFuncs.c:44:5: warning: passing argument 1 of 'wcscmpi' from incompatible pointer type [enabled by default] return int_variant(wcscmpi(vt1.data_ptr, vt2.data_ptr)); ^ In file included from C:\AutoIt\CompileIt\project\AutoItFuncs.c:4:0: c:\program files (x86)\codeblocks\mingw\include\string.h:173:29: note: expected 'const wchar_t *' but argument is of type 'int *' int __cdecl __MINGW_NOTHROW wcscmpi (const wchar_t * __ws1, const wchar_t * __ws2); ^ C:\AutoIt\CompileIt\project\AutoItFuncs.c:44:5: warning: passing argument 2 of 'wcscmpi' from incompatible pointer type [enabled by default] return int_variant(wcscmpi(vt1.data_ptr, vt2.data_ptr)); ^ In file included from C:\AutoIt\CompileIt\project\AutoItFuncs.c:4:0: c:\program files (x86)\codeblocks\mingw\include\string.h:173:29: note: expected 'const wchar_t *' but argument is of type 'int *' int __cdecl __MINGW_NOTHROW wcscmpi (const wchar_t * __ws1, const wchar_t * __ws2); ^ mingw32-gcc.exe -Wall -g -c C:\AutoIt\CompileIt\project\CompileIt.c -o obj\Debug\CompileIt.o C:\AutoIt\CompileIt\project\CompileIt.c: In function 'variant_getstring': C:\AutoIt\CompileIt\project\CompileIt.c:86:9: warning: return makes pointer from integer without a cast [enabled by default] return *((wchar_t*)vt.data_ptr); ^ mingw32-g++.exe -o bin\Debug\CompileItExample.exe "obj\Debug\#1 - Hello, World!.o" obj\Debug\AutoItFuncs.o obj\Debug\CompileIt.o Output file is bin\Debug\CompileItExample.exe with size 53.05 KB Process terminated with status 0 (0 minute(s), 0 second(s)) 0 error(s), 5 warning(s) (0 minute(s), 0 second(s)) My cbp project file <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <CodeBlocks_project_file> <FileVersion major="1" minor="6" /> <Project> <Option title="CompileItExample" /> <Option pch_mode="2" /> <Option compiler="gcc" /> <Build> <Target title="Debug"> <Option output="bin/Debug/CompileItExample" prefix_auto="1" extension_auto="1" /> <Option object_output="obj/Debug/" /> <Option type="1" /> <Option compiler="gcc" /> <Compiler> <Add option="-g" /> </Compiler> </Target> <Target title="Release"> <Option output="bin/Release/CompileItExample" prefix_auto="1" extension_auto="1" /> <Option object_output="obj/Release/" /> <Option type="1" /> <Option compiler="gcc" /> <Compiler> <Add option="-O2" /> </Compiler> <Linker> <Add option="-s" /> </Linker> </Target> </Build> <Compiler> <Add option="-Wall" /> </Compiler> <Extensions> <code_completion /> <envvars /> <debugger /> <lib_finder disable_auto="1" /> </Extensions> </Project> </CodeBlocks_project_file> which results in You rock man! Skysnake2 points -
need working examples of WinHttp
Earthshine reacted to junkew for a topic
https://support.microsoft.com/en-us/help/837104/implement-a-single-sign-on-solution-by-using-basic-authentication-and search google for winhttp sso1 point -
Question on UIA / find all
Earthshine reacted to zenocon for a topic
Solved it. The loop was wrong. It was copy/paste from another example. Didn't realize it was trying to ensure there was only one element in the array when I was looking for more.1 point -
GDI+: Clipping fails after rotation
Earthshine reacted to UEZ for a topic
The problem is that the file is locked by the load process. You have to release the handles first before you can overwrite it: ... Local $hImageClone2 = _GDIPlus_BitmapCloneArea($ghImage,$nsrcX,$nsrcY,$nSrcWidth,$nSrcHeight) _GDIPlus_GraphicsDispose($hGfxClone) _GDIPlus_ImageDispose($ghImage) MsgBox(0,'filedelete',FileDelete($filspc)) _GDIPlus_ImageSaveToFile($hImageClone2,$filspc) _GDIPlus_ImageDispose($hImageClone2) ShellExecute($filspc) $ghImage = _GDIPlus_ImageLoadFromFile($filspc) $hGfxClone=_GDIPlus_ImageGetGraphicsContext($ghImage) ... It will save your rotated image BUT your have to create the handles again otherwise CRASH.1 point -
Scripting MSI Uninstall
Earthshine reacted to Jos for a topic
have you tried with @RequireAdmin at the top of the script? Jos1 point -
Ending a copy and paste loop
Earthshine reacted to idontknow989 for a topic
Thank you JLogan3o13 that ended up working.1 point -
Ending a copy and paste loop
Earthshine reacted to JLogan3o13 for a topic
@idontknow989 just a couple of questions for clarification. You activate the window, copy the patient name, then hit the down button to move to the next. So: When you reach the last patient record, copy it and then hit down, what is the behavior? Does it just stay on that same line in the app? Are the patient names full names, first names only, etc.? Are they unique enough that you could compare the last string placed on the clipboard and be reasonably sure of the outcome? For example: Notepad with first names: Jim John James Joey Diana Diana ....Should fail here Jim John James Joey Diana ClipPut('') ;Clear the Clipboard Local $sName = "" Local $x = 1 While 1 WinActivate("Untitled - Notepad") Sleep(500) Send("+{END}") ;Shift end to capture whole line Send("^c") ;Copy Send("{DOWN}{HOME}") ;Down arrow then Home button to the beginning of the next line If $sName == ClipGet() Then ;If what was just captured is Case-sensitive equal to what is on the clipboard ConsoleWrite(ClipGet() & " already in the clipboard" & @CRLF) ExitLoop Else $sName = ClipGet() ConsoleWrite("Turn " & $x & ": " & $sName & @CRLF) EndIf $x += 1 WEnd You would have to modify this a bit to fit your needs, but it should give you an idea of a way to go about it. If the application's behavior is different when you reach the last line, please explain in greater detail. If possible, a screenshot would be helpful.1 point -
oh thanks again,it seems everything easy for you thanks for replay but as you said @mikell solution matching exactly in my needs.about january concept i will put the whole word"january".1 point
-
CompileIt - an experimental AutoIt-to-machine code compiler
Deye reacted to scintilla4evr for a topic
Well, according to some simple tests I performed while developing new features, CompileIt reached about 2x faster execution. But when I got to loops with a lot of iterations, it sometimes executed slower than AutoIt, because the whole thing is not optimized in any way. But then again, let us wait and maybe things will change1 point -
CompileIt - an experimental AutoIt-to-machine code compiler
scintilla4evr reacted to Deye for a topic
Well done, So this potentially will have faster execution times to what it can support so far ... Was looking to see something like this already done ! Thanks for sharing1 point -
Scripting MSI Uninstall
Earthshine reacted to JLogan3o13 for a topic
If you do an msiexec /? in the run line it will show you proper syntax: msiexec <install option> <product.msi> <display option> So msiexec /x <product> /qn for silent1 point -
Something like this. But, you will need to use the AutoIT Window Info tool to figure out the Window and controls to enter $iPID = ShellExecute("www.yahoo.com") ;Use AutoIT Window Info tool to get the Save-As file name input box If WinWait("Save As", "", 90) Then ControlSetText("Save As", "", "FileNameEditBoXControlName", "xXx-" & @HOUR & @MIN & @SEC & @MSEC & ".csv") ControlClick("Save As", "", "OKbuttonName") Else MsgBox(0, "Error", "The Save-As window did not appear within 90 seconds") EndIf1 point
-
1 point
-
Error handling
Earthshine reacted to Floops for a topic
Because you are calling a function every x milliseconds. That doesn't guarantee that it runs after every line of code. You could set the interval very low but then that function gets spammed which could be CPU-heavy.1 point -
I see, what about AdlibRegister() ? Might not be the prettiest solution but it's better than putting an if-statement on every line.1 point
-
Error handling
Earthshine reacted to water for a topic
Welcome to AutoIt and the forum! Which program do you automate? Most programs have an API to allow automation.1 point -
The following is an AutoIt application designed to allow LastPass for Applications to launch and log into Remote Desktop Session also known as RDP or mstc.exe. LastPass is a cloud based password manager, their clients support the widest range of browsers and OS's out there. All clients sync the data well, while maintaining a local catch for when you are offline. For premium users, (which I have been for 4 years) they have available Lastpass for Application which is designed for Applications verus Websites. Unfortunately it does not work with the Windows Remote Desktop Client. This is where the following script comes in. LastPass for applications launches RDPlp.EXE passing it the server name, user name, and password. RDPlp.EXE then launches the Remote Desktop session using the information pass to it by LastPass. RDPlp.EXE also insures full screen sessions are moved to the second monitor if it exist. Why do this when RDP settings files can be used as shortcuts that will launch a Remote Desktop Session? 1) I have a lot of servers I need to connect to on a periodic bases, the corresponding collection of short cuts would be hard to manage 2) RDP settings files with saved passwords only work on the computer they where created for. With this utility and LastPass's cloud approach all my remote Desktop entries work on any of my computers that have LastPass for Application and this LastPass Helper install. That turns out to be any computer I use. 3) When I do a routine password change LastPass offers to update all my password entries for the same domain/username. In this way all my remote desktop connections get updated as well. If I used a collection of RDP setting files I would need to update each separately. Further documentation can be found in the source code and the help screen created by RDPlp.exe The attached ZIp contains the source, compiled EXE and two sample RDP settings files. This application has been tested on Win7, Win8, Win10. It was marginally written to work on XP as well but since the version 2 rewrite this has not been tested, I have no XP development machines anymore. It works with Remote Desktop sessions on all versions of Server 2003, 2008, 2012 and 2014. Below is the source for those who want to take a peek. I hope someone else finds this as useful as I have. As of 2020 LogMeIn has depreciated LastPass for Applications so to regain some storage space on the Forum I have removed the ZIP file with this code. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=RDPlp_icon.ico #AutoIt3Wrapper_Res_Description=Launch RDP from LastPass #AutoIt3Wrapper_Res_Fileversion=2.2.0.3 #AutoIt3Wrapper_Res_FileVersion_AutoIncrement=P #AutoIt3Wrapper_Res_ProductVersion=2.2 #AutoIt3Wrapper_Res_Field=ProductVersion|Version 2.2 #AutoIt3Wrapper_Res_Field=Productname|RDPlp #AutoIt3Wrapper_Res_Field=Publisher|Paul Verboom #AutoIt3Wrapper_Res_LegalCopyright=© Copyright Paul Verboom 2015 #AutoIt3Wrapper_Res_Comment=Launch Remote Desktop Session from LastPass for Applications #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> #include <WinAPIGdi.au3> #include <WindowsConstants.au3> #comments-start Revisions Ver 2.0 - First rewrite that edits RPD settings file directly Ver 2.1 - Added labels to field in training window, moved splash off to pre pixel count for old login style login window Ver 2.2 - Added check for Windows 10 RDP credentials screen #Comments-end ;RDPlp #comments-start LastPast Helper to Launch RDP session. The formate of the command is straight forward. Lastpast for applications is used to launch this program. If the program is launched with no parameters a help screen is displayed that explains how to set up an entry in last past to use this program. RDPlp Server UserName Password [RDP Settings file] If Domain needs to be specified as part of the user name place it in front of User name in format domain\user A RDP settings file is required. This program will edit it and use it to make the connection. By default a settings file with the same name as this executable will be used, switching the extension from .EXE to .RDP The executable can be renamed and the default RDP settings file will also change OR a alternate RDP file can be specified as the 4th parameter A RDP settings file can be created by launching Remote Desktop Connection usually located under Start->Programs->Accessories. Click options in the bottom right corner. Use the Save Connection Settings that is now availble to save the file as RDPlp.RDP You may wish to set other settings such as screen size, bandwidth etc. before saving the connect file. This program will add the server and username so the same connection file can be used for numerous servers and logins. Do not check Allow me to save credentials as this program will enter the password each time. You may wish to change the "If Server authentication fails" setting on the Advanced tab so these warning do not interrupt the login process. The Remote Desktop Connection file only allows standard screen sizes be set however the RDP file can be edited directly in notepad and these settings made to any arbitrary value look for the entries where X is the screen width and Y is it's height desktopwidth:i:X desktopheight:i:Y This is very useful when doing remoted on windows 8 tablets with limited screen size. This script will edit the specified RDP settings file adding the Server and UserName If will also adjust the window position to one of the following conditions - Full Screen RDP session and 2 or more monitors RDP session moved to 2nd monitor on right - Full Screen RDp session and 1 window move window to primary monitor - Not Full Screen adjust window size to be big enough to display RDP session It will then launch the RDP file watching for one of the following windows 1) Windows Security 2) RDPlp - SERVERNAME - Remote Desktop Connection (where SERVERNAME is the address of the server being connected to) 3) Remote Desktop Connection with OK as part of the visable text (this indicates an error in making the connection) RDP Settings for Remote Desktop Services in Windows Server 2008 R2 can be found at https://technet.microsoft.com/en-us/library/ff393699%28v=ws.10%29.aspx #comments-end ;RDP command line options #comments-start --------------------------- Remote Desktop Connection Usage --------------------------- MSTSC [<connection file>] [/v:<server[:port]>] [/admin] [/f[ullscreen]] [/w:<width> /h:<height>] [/public] | [/span] [/edit "connection file"] [/migrate] "connection file" -- Specifies the name of an .rdp file for the connection. /v:<server[:port]> -- Specifies the remote computer to which you want to connect. /admin -- Connects you to the session for administering a server. /f -- Starts Remote Desktop in full-screen mode. /w:<width> -- Specifies the width of the Remote Desktop window. /h:<height> -- Specifies the height of the Remote Desktop window. /public -- Runs Remote Desktop in public mode. /span -- Matches the remote desktop width and height with the local virtual desktop, spanning across multiple monitors if necessary. To span across monitors, the monitors must all have the same height and be aligned vertically. /edit -- Opens the specified .rdp connection file for editing. #comments-end Local $Server Local $User Local $Password ;Debug variable set to 2 or higher to run from devolpment enviroment $Debug = 0 ;! for debugging If $Debug > 1 Then $Server = "" $User = "" $Password = "" EndIf ;Help screen with fields to train lastPass ;a simple dialog to capture 3 values If ($CmdLine[0] < 3 or $CmdLine[0] > 5) and $Debug = 0 Then #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1_1 = GUICreate("RDPlp Ver 2.0", 480, 550, 341, 203) $Label0 = GUICtrlCreateLabel("LastPass Training window", 180, 16, 127, 17) $Label1 = GUICtrlCreateLabel("Server", 85, 50, 217, 21) $Input1 = GUICtrlCreateInput("Server", 124, 48, 217, 21) $Label2 = GUICtrlCreateLabel("User", 90, 90, 217, 21) $Input2 = GUICtrlCreateInput("User", 124, 88, 217, 21) $Label3 = GUICtrlCreateLabel("Password", 70, 130, 217, 21) $Input3 = GUICtrlCreateInput("Password", 124, 128, 217, 21) $Button1 = GUICtrlCreateButton("Exit", 164, 160, 145, 33) $Button2 = GUICtrlCreateButton("Copy to clipboard", 200, 473, 120, 17) $T1 = GUICtrlCreateLabel("RDPlp allows LastPass for Applications to Launch Remote Desktop sessions.",20,210,400,17) $T2 = GUICtrlCreateLabel("Use this help screen to add a Remote Desktop session as an Application to ",20,230,500,17) $T3 = GUICtrlCreateLabel("LastPass for Applications. ",20,245,500,17) $T4 = GUICtrlCreateLabel("- Use the Add Application option in Last Pass for Applications.",20,265,400,17) $T5 = GUICtrlCreateLabel("- Find this window.",20,280,400,17) $T6 = GUICtrlCreateLabel("- Click Next.",20,295,400,17) $T7 = GUICtrlCreateLabel("- Edit The Name to reflect the actual server being connected to.",20,310,400,17) $T8 = GUICtrlCreateLabel("- Edit the 3 Fields as indicated.",20,325,400,17) $T9 = GUICtrlCreateLabel("- Click OK.",20,340,400,17) $T10 = GUICtrlCreateLabel("If you need to specify a domain use this format in the User field;",20,360,400,17) $T11 = GUICtrlCreateLabel("domain\username",40,375,400,17) $T12 = GUICtrlCreateLabel("Be sure to change the Password field to the password type so it is hidden by default.",20,390,500,17) $T13 = GUICtrlCreateLabel("The following password will cause the program to not do the login;",20,405,500,17) $T14 = GUICtrlCreateLabel("pause ",40,420,500,17) $T15 = GUICtrlCreateLabel("Once the application is added you will need to edit it.",20,440,500,17) $T16 = GUICtrlCreateLabel("Adding the following to the end of the application entry.",20,455,500,17) $T17 = GUICtrlCreateLabel("%field0% %field1% %field2%",40,475,150,17) $T18 = GUICtrlCreateLabel("RDPlp requires a RDP connection settings file of the same name be located in the same",20,495,500,17) $T19 = GUICtrlCreateLabel("folder as RDPlp.EXE This connect file is used to setup session values, screen size etc.",20,510,500,17) $T20 = GUICtrlCreateLabel("OR a different RDP connection file can be specified as the 4th parameter on the command line.",20,525,500,17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit Case $Button2 IF $Debug Then ConsoleWrite("Placed %field0% %field1% %field2% into clipboard") EndIf ClipPut(" %field0% %field1% %field2%") EndSwitch WEnd EndIf ;Place Splash Window up so User Knows Auto Login is running ;Options used in 3rd from last parameter ;$DLG_NOTITLE = 1 ;$DLG_MOVEABLE = 16 SplashTextOn("","Starting Remote Desktop Login", 400, 50,@DesktopWidth/2 - 200, @DesktopHeight/2 -150, 17, "", 18) If $Debug = 0 Then If $CmdLine[0] > 2 Then $Server = $CmdLine[1] $User = $CmdLine[2] $Password = $CmdLine[3] ENDIF EndIf If $Password = "pause" Then MsgBox(0,"RDPlp","Password = pause. Login will not be completed") $Login = "N" Else $Login = "Y" EndIf IF $Debug Then ConsoleWrite("@WorkingDir = "&@WorkingDir&@CRLF) ConsoleWrite("@WindowsDir = "&@WindowsDir&@CRLF) ConsoleWrite("Server = -"&$Server&"-"&@CRLF) ConsoleWrite("User = -"&$User&"-"&@CRLF) ConsoleWrite("Password = -"&$Password&"-"&@CRLF) EndIf ;-------------------------- ;Get RDP settings file name ;-------------------------- $RDPSettings = StringReplace(@ScriptName,".exe",".RDP",1) ;same as name of executable $RDPSettings = StringReplace($RDPSettings,".au3",".RDP",1) ;or script name If $CmdLine[0] >= 4 Then ;unless it is specified as 4th paramter $RDPSettings = $CmdLine[4] IF StringUpper(StringRight($RDPSettings ,4)) <> ".RDP" Then $RDPSettings = $RDPSettings & ".RDP" EndIf EndIf IF $Debug Then ConsoleWrite("RDP Settings file: "&$RDPSettings&@CRLF) EndIf IF NOT StringInStr($RDPSettings,"\") Then ;add path to file name if not already there $FullRDPSettings = @WorkingDir & "\" & $RDPSettings EndIf IF FileExists($FullRDPSettings) = 0 Then ;Should be in working directory of script MsgBox(0,"RDPlp","RDP Settings file: " & $FullRDPSettings & " not found." & @CRLF & "Should be located in same folder as RDPlp.EXE") SplashOff() ;turn off Auto Login Starting message Exit EndIf ;------------------------------------------- ;Check for extended desktop with 2nd display ;------------------------------------------- Local $SecondMonitor = False Const $monitor_count = _WinAPI_GetSystemMetrics($SM_CMONITORS) IF $Debug Then ConsoleWrite("Number of monitors = " & $monitor_count & @CRLF) EndIf IF $monitor_count > 1 Then Const $aMonitor = _WinAPI_EnumDisplayMonitors() If NOT @error Then If $aMonitor[0][0] > 1 Then $SecondMonitor = True IF $Debug Then ConsoleWrite("Extended Mode" & @CRLF) EndIf EndIf EndIf EndIf ;---------------------------- ;Edit the RDP connection file ;---------------------------- Local $aRDP ;Array containing RDP settings file Local $i ;index used to process array Local $line ;Line currectly being processed Local $AddServer = True ;Server added to RDP settings file flag Local $AddUser = True ;User added to RDP settings file flag Local $Width = 0 ;Width of remote desktop session Local $Height = 0 ;Height of Remote Desktop session Local $Brder = 100 ;number of pixels added to window sizes to account for boarders Local $OffSt = 100 ;How far out of top left corner to place window Local $Move1st = False ;Flag to move RDP swindow to 1st screen Local $Move2nd = False ;Flag to move RDP swindow to 2nd screen $aRDP = FileReadToArray($FullRDPSettings) ;read the RDP file to a array one line per element FOR $i = 0 to ubound($aRDP)-1 ;look through file for existing server and user entries IF StringInStr($aRDP[$i],"full address:s:") Then ;replacing them if found and set flag so we know $aRDP[$i] = "full address:s:" & $Server ;change has been done $AddServer = False EndIf IF StringInStr($aRDP[$i],"username:s:") Then $aRDP[$i] = "username:s:" & $User $AddUser = False EndIf IF StringInStr($aRDP[$i],"screen mode id:i:2") Then ;If we are in full screen mode IF $SecondMonitor Then ; and have Second Monitor then $Move2nd = True ; set flag to alter the X position in RDP file to move to 2nd screen Else $Move1st = True ;If no second monitor set flag to alter X position so EndIf ;window is on 1sst monitor EndIf IF StringInStr($aRDP[$i],"desktopwidth:i:") Then ;Find the width and heigh of the Remote desktop window $atemp = StringSplit($aRDP[$i],":") IF $atemp[0] = 3 Then $Width = Number($atemp[3]) EndIf EndIf IF StringInStr($aRDP[$i],"desktopheight:i:") Then $aTemp = StringSplit($aRDP[$i],":") IF $aTemp[0] = 3 Then $Height = Number($aTemp[3]) EndIf If $Debug Then ConsoleWrite("Remote Desktop Size: " & STRING($Width) & " x " & STRING($Height) & @CRLF) EndIf EndIf IF StringInStr($aRDP[$i],"winposstr:s:") Then ;Rewrite window position and size IF $Width = 0 Then ;Set default Remote Desktop Size $Width = 1024 EndIf IF $Height = 0 Then $Height = 768 EndIf IF $Move1st Then ;move window position so RDP window is on 1st monitor $aRDP[$i] = "winposstr:s:0,1," & STRING($OffSt) & "," & STRING($OffSt) & "," & STRING($Width + $OffSt + $Brder) & "," & STRING($Height + $OffSt + $Brder) EndIf IF $Move2nd Then ;move window position so RDP window is on 2nd monitor $aRDP[$i] = "winposstr:s:0,1," & String(@DesktopWidth + $OffSt) & "," & STRING($OffSt) & "," & String(@DesktopWidth + $Width + $OffSt + $Brder) & "," & STRING($Height + $OffSt + $Brder) EndIf IF (NOT $Move1st) AND (NOT $Move2nd) THEN ;not moving window therfore not full screen IF @DesktopWidth > $Width OR @DesktopHeight > $Height Then $Width = @DesktopWidth - $Brder - $OffSt ;size of RDP window is larger then current screen $Height = @DesktopHeight - $Brder - $OffSt ;therefore make new size based on screen size EndIf ;write out window in the corrected size $aRDP[$i] = "winposstr:s:0,1," & STRING($OffSt) & "," & STRING($OffSt) & "," & STRING($Width + $OffSt + $Brder) & "," & STRING($Height + $OffSt + $Brder) EndIf EndIf Next IF $AddServer Then ;if server and user entries where not found add them _ArrayAdd($aRDP,"full address:s:" & $Server) ;to the array now EndIf IF $AddUser Then _ArrayAdd($aRDP,"username:s:" & $User) EndIf IF $Debug > 0 Then _ArrayDisplay($aRDP,"Altered Contents of RDP file") EndIf _FileWriteFromArray($FullRDPSettings,$aRDP) ;---------------------------- ;Launch the RDP settings file ;---------------------------- ShellExecute($FullRDPSettings) ;Security warnings are not processed by this script ;Win7 and above versions of RDp have options to remember the bypass selected answers ;uses those options ;-------------------- ;Now provide password ;-------------------- #comments-start Some version of RDP such as the one with Windows 7 will do login on local machine if server is 2008 and above so look for window titles Windows Security or the Login is done on the remote machine so also look for the title of the Remote desktop session in form RDPlp - SERVERNAME - Remote Desktop Connection (Windows 7) or RDPlp - SERVERNAME - Remote Desktop (Windows XP) where RDPlp is the name of the RDP settings file being used where SERVERNAME is the address of the server being connected to or The connection will fail and a Dialog will be displayed Titled "Remote Desktop Connection" Containing the text "can't find the computer" (XP and Win7) not (Win8) Containing the text "PK" (XP, Win7 & Win8) #Comments-end ;Text match mode for window titles AutoItSetOption("WinTextMatchMode",2) ;1=complete, 2=quick ;determine title of created Remote Desktop Window has Server name in it etc. ;RDPlp - DC-SV-MUSE-temp - Remote Desktop Connection $RmDSkWin = StringLeft($RDPSettings, StringLen($RDPSettings)-4) & " - " & $Server & " - Remote Desktop" IF $Debug Then ConsoleWrite("For server < 2008 or XP will be looking for Window Title"&@CRLF) ConsoleWrite($RmDSkWin&@CRLF) EndIf ;Some versions of the RDP client (Windows 7) add word connection to the title ;So do match on leading characters only AutoItSetOption("WinTitleMatchMode",1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Local $hTimer = TimerInit() ;Starting point for timer While TimerDiff($hTimer) < (1000 * 45) ;Total wait 45 seconds in Milliseconds ;Wait for Windows Security Login Screen ; OR ;Remote Desktop Connection where login takes ;Place on remote system ; OR ;Can't connect error message ;See if Windows 10 Security window exist IF WinExists("[TITLE:Windows Security; CLASS:Credential Dialog Xaml Host]","") Then If $Debug Then ConsoleWrite("Windows 10 RDP login was found"&@CRLF) EndIf ;Do we do actual login If $Login = "Y" Then IF $Debug Then ConsoleWrite("Blind Typing Password" & @CRLF) EndIf sleep(750) WinActivate("Windows Security") ;This can be done by direct manipulation of the controls by AutoIt ;BUT the control names have changed between WinXP/Win7 and Win8 ;Blind entry of password works regardless of OS Send($Password,1) Send("{ENTER}") EndIf ;We have done all we set out to do so exit SplashOff() ;turn off Auto Login Starting message Exit EndIf ;See if Windows 7 Security window exist IF WinExists("Windows Security","Remember my credentials") Then If $Debug Then ConsoleWrite("Windows 7 RDP login was found"&@CRLF) EndIf ;Do we do actual login If $Login = "Y" Then IF $Debug Then ConsoleWrite("Blind Typing Password" & @CRLF) EndIf sleep(750) WinActivate("Windows Security") ;This can be done by direct manipulation of the controls by AutoIt ;BUT the control names have changed between WinXP/Win7 and Win8 ;Blind entry of password works regardless of OS Send($Password,1) Send("{ENTER}") EndIf ;We have done all we set out to do so exit SplashOff() ;turn off Auto Login Starting message Exit EndIf ;See if remote Desktop Window to open IF WinExists($RmDSkWin) Then IF $Debug Then ConsoleWrite("Main Remote Desktop Window was found"&@CRLF) EndIf ;Activate the Window WinActivate($RmDSkWin) ;WinSetState($RmDSkWin,"",@SW_MAXIMIZE) SplashOff() ;turn off Splash so it doesn't mess up pixel check sum ;get checksum of side of window and center. ;they need to be different which indicate login window has been generated Local $aPos = WinGetPos($RmDSkWin) Local $ChkXside = $aPos[0] + 100 Local $ChkXcent = $aPos[0] + ($aPos[2] /2) Local $ChkY = $aPos[1] + ($aPos[3] /2 ) Local $ChkSumSide = PixelChecksum($ChkXside,$ChkY,$ChkXside+56,$ChkY+56) Local $ChkSumCent = PixelChecksum($ChkXcent,$ChkY,$ChkXcent+56,$ChkY+56) IF $Debug Then ConsoleWrite("Check Sum Pixels Side of RDP window: "&$ChkSumSide&@CRLF) ConsoleWrite("Check Sum Pixels Center of RDP Window: "&$ChkSumCent&@CRLF) EndIf ;only proceed if something(login in window) is in center of window IF $ChkSumCent <> $ChkSumSide Then ;Do we do actual login If $Login = "Y" Then ;Type in password IF $Debug Then ConsoleWrite("Blind Typing Password" & @CRLF) EndIf Send($Password,1) Send("{ENTER}") EndIf ;We have done all we set out to do so exit Exit Else IF $Debug Then ConsoleWrite("Login dialog not ready yet" & @CRLF) EndIf EndIf EndIf ;Does Failed connect dialog exist ; IF WinWait("Remote Desktop Connection","can't find the computer",1) <> 0 Then IF WinExists("Remote Desktop Connection","OK") Then IF $Debug Then ConsoleWrite("Connection fail dialog found exiting"&@CRLF) EndIf ;nothing more we can do so let's abort SplashOff() ;turn off Auto Login Starting message Exit EndIf Wend MsgBox(0,"RDPlp","No Login Windows seen after wait.") ;We are finished Exit1 point
-
Excel UDF Help
Earthshine reacted to Julia_Muc for a topic
ok, last post from me so far. I found the $excel.Workbooks(1).RefreshAll that helps. Any other ideas or comments on the Topic? I really appreciate your help. Thanks a lot | Dankeschön :-)1 point -
Autoit script at Windows 10 startup (before logon)
Earthshine reacted to argumentum for a topic
Well, you have insufficient experience in AutoIt to write a Send(), writing a service is out of you league right now. I don't wanna put words into @Earthshine's mouth, but he can cook a run once ( a function ) and idle the rest of the time service1 point -
This is real simple when using the WinHTTP UDF Here's some example code -- #include "WinHttp.au3" Opt("MustDeclareVars", 1) Global $sDomain = "braziliex.com" Global $sPage = "/api/v1/public/currencies" ; Initialize and get session handle Global $hOpen = _WinHttpOpen() ; Get connection handle Global $hConnect = _WinHttpConnect($hOpen, $sDomain) ; Make a SimpleSSL request Global $hRequestSSL = _WinHttpSimpleSendSSLRequest($hConnect, Default, $sPage) ; Read... Global $sReturned = _WinHttpSimpleReadData($hRequestSSL) ConsoleWrite($sReturned & @CRLF) ; Close handles _WinHttpCloseHandle($hRequestSSL) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)1 point
-
In your example, you could also do Case $Radio1 To $Radio4 as long as the radio buttons are created in sequence order and no other controls in between (because each control is assigned an integer index which increments by 1 each time). #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 539, 438, 192, 124) $Radio1 = GUICtrlCreateRadio("Radio1", 112, 80, 113, 17) $Radio2 = GUICtrlCreateRadio("Radio2", 112, 120, 113, 17) $Radio3 = GUICtrlCreateRadio("Radio3", 112, 160, 113, 17) $Radio4 = GUICtrlCreateRadio("Radio4", 112, 200, 113, 17) $Button1 = GUICtrlCreateButton("Button1", 112, 272, 75, 25) GUICtrlSetState($Button1, $GUI_DISABLE) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Radio1 To $Radio4 If BitAND(GUICtrlRead($nMsg), $GUI_CHECKED) Then GUICtrlSetState($Button1,$GUI_ENABLE) Else GUICtrlSetState($Button1,$GUI_DISABLE) EndIf Case $Button1 MsgBox(0,"Clicked!","Clicked OK",3) GUICtrlSetState($Radio1,$gui_UNCHECKED) GUICtrlSetState($Radio2,$gui_UNCHECKED) GUICtrlSetState($Radio3,$gui_UNCHECKED) GUICtrlSetState($Radio4,$gui_UNCHECKED) GUICtrlSetState($Button1,$GUI_DISABLE) EndSwitch WEnd However, Danyfirex is right, you'll likely want to evaluate each radio button on it's own. Also, there's not much point evaluating if a radio button is checked if clicking it is what triggered the event, unless I'm not considering / overlooking something?1 point
-
The correct way is. Case $Radio1, $Radio2, $Radio3, $Radio4 Saludos1 point
-
You can set the control size depending on the DPI. I use this GDI+ function to get the DPI size: Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) If @error Then Return SetError(1, @extended, 0) Local $aResult = DllCall($ghGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) If @error Then Return SetError(2, @extended, 0) Local $iDPI = $aResult[2] _GDIPlus_GraphicsDispose($hGfx) Local $aResults[2] = [$iDPIDef / $iDPI, $iDPI / $iDPIDef] Return $aResults EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio According the information you can set the size of your control or the font size. Br, UEZ1 point