Leaderboard
Popular Content
Showing content with the highest reputation on 04/12/2016 in all areas
-
Really? this is a Joke right? OS behavior is the same... I'm done with you. I wish you best of luck and also to your therapist. Regards Alien.2 points
-
I never worked with Groups but _GUICtrlListView_SetGroupInfo seems the func you are searching for.2 points
-
New version 1.7.3.0 is out! Download current release Place to post bugs and suggestions (Bug tracker) Online help (Wiki) What's new: Graphic editorBetter support of limited accounts and UAC under Vista/SevenStyles editor allow multiple selectionIcons in additional controls (Tab, ListView, TreeView)Redone Object tree, with support of editable descriptionsAwareness of GUI_SS_DEFAULT stylesAnd many smaller changes (see full history) New version 1.7.2.0 is out! What's new: Added small abilities that become in latest beta of AutoitImproved language systemImproved update checkingImproved siteNew version 1.7.1.0 is out! What's new: Customizing colorsExternal import frameworkCustom controls (ones that available via standard UDFs)Rewritten support for icon - now it support full color onesBetter support (bugtracker, wiki)Bugfix release 1.7.0.1 is out! After another year, new version 1.7.0.0 is out! Most significant changes in this release: Customizable toolbarsUndo supportAligning paletteImport Autoit GUI scriptsFull help file, with context sensitive help supportAnd as usually, lots of bugfixes and small changes. After long period of development and testing, new release 1.6.0.0 is finally here! Thanks to all who support us and help done this work! Most significant changes from previous release: New, more fast and reliable form read/write routines.Rewritten form list handling codeMenus support (with visual editor)Obj support (with visual browser)Templates-based code generationGenerating event-based codeHelp file (unfinished)Old topic is here, some bugs posted there are not resolved yet, so please check it too.1 point
-
ZIP.au3 UDF in pure AutoIt
HouseRockerZz reacted to torels for a topic
Hi there! I just wrote a ZIP udf in AutoIt (without external files) which lets you create archives, fill them with files and folders and extract them to your computer these are the functions <<go to the last release's section and jump previous releases's posts>> ======================= Updated ======================= UPDATED 30/6/2008 UPDATED 24/9/2008 Fixed Various Bugs Added Wait Function to let the script sleep until the files havn't been zipped Changed Function Names new format is: _Zip_TheFunction() UPDATED 13/10/2008 _Zip_AddFolder() now changed in _Zip_AddFolderContents() New Function : _Zip_AddFolder() that now adds the whole folder creating a subdirectory in the zip file _Zip_Count() Bug Finally fixed UPDATED 6/11/2008 New Function : _Zip_CountAll() that counts all elements in the archive. Including SubDirectories UPDATED 28/11/2008 New Virtual Zipping Functions this is actually very cool stuff! Maybe useless, but cool. UPDATED 17/03/2009 Added _Zip_Delete($hZipFile, $hFilename, $flag = 1). Very slow but it works... It'll be improved FLAGS WORK! Here are the User CallTip Entries: _Zip_Create($FileName) Create Zip File. Required #include <Zip.au3> _Zip_AddFile($ZipFile, $File2Add, [$flag]) Add file to Zip Archive. Required #include <Zip.au3> _Zip_AddFolder($ZipFile, $Folder, [$flag]) Add folder to Zip Archive. Required #include <Zip.au3> _Zip_AddFolderContents($ZipFile, $Folder, [$flag]) Add folder's content to Zip Archive. Required #include <Zip.au3> _Zip_Delete($ZipFile, $hFileName, [$flag]) _Zip_UnzipAll($ZipFile, $DestPath, [$flag]) Extract all files from Zip Archive. Required #include <Zip.au3> _Zip_Unzip($ZipFile,$FileName, $DestPath, [$flag]) Extract file from Zip Archive. Required #include <Zip.au3> _Zip_Count($ZipFile) Count items in zip. Required #include <Zip.au3> _Zip_CountAll($ZipFile) Count All items in the Zip Archive Including SubDirectories. Required #include <Zip.au3> _Zip_List($ZipFile) List items in zip. Required #include <Zip.au3> _Zip_Search($ZipFile, $SearchString) Search a File in the Zip Archive. Required #include <Zip.au3> _Zip_SearchInFile($ZipFile, $SearchString) Search In each File of the Zip Archive. Required #include <Zip.au3> _Zip_VirtualZipCreate($ZipFile, $Path) Create a Virtual Zip. Required #include <Zip.au3> _Zip_VirtualZipDelete($VirtualZipHandle) Delete a Virtual Zip. Required #include <Zip.au3> Example Script ; Zip Example ; _________________________________ ; ; Zip UDF Example by torels_ ; _________________________________ #include "Zip.au3" Dim $Zip, $myfile $myfile = @DesktopDir & "\foo.au3" $Zip = _Zip_Create(@DesktopDir & "\zip_002.zip") ;Create The Zip File. Returns a Handle to the zip File _Zip_AddFile($Zip,$myfile) ;add $myfile to the zip archive _Zip_AddFolder($Zip,@desktopdir & "\Folder_001",4) ;Add a folder to the zip file (files/subfolders will be added) _Zip_AddFolderContents($Zip, @DesktopDir & "\MyFolder") ;Add a folder's content in the zip file MsgBox(0,"Items in Zip","there are " & _Zip_Count($Zip) & " items in " & $Zip) ;Msgbox Counting Items in $Zip MsgBox(0,"Items in Zip","there are " & _Zip_CountAll($Zip) & " Elements in " & $Zip) ;Msgbox Counting Elements in $Zip $search = _Zip_Search($Zip,"foo.au3") ;Returns an array containing the search results For $i = 0 to UBound($search) - 1 ; Print Each ConsoleWrite($search[$i]) & @LF ; Corresponding value Next ; In The Console $list = _Zip_List($Zip) ;Returns an array containing all the files in the zip file ConsoleWrite("============== ZIP Contents ============" & @LF) For $i = 0 to UBound($list) - 1 ConsoleWrite($list[$i] & @LF) ;Print Search Results in the console Next Exit Comments are welcome previous number of downloads: 1787 & a few more XD Zip.au31 point -
"The why" I've been working over 15 years in the IT industry and have realised that the best way of streamlining operations and support is by combining the concept of selling services (instead of hours) along with a tool built for managing those services. For the past 10 years i've been working with some of the leading providers of MSP-tools. The prize set on these comercial tools is quite high and there are usually few licence models to choose from. A smaller it-company will find the cost hard to motivate and in turn have dificulties converting its busines model in order to make more money, classic catch 22 "The how" During the years, i've gathered the pros and cons of these tools, dissected their core and realised there is no magic or rocket science going on. There is however a whole lot of scripting used and that's why i feel AutoIT would be a great foundation for a new project. So, i've decided to compile my years of experiance and create a tool for remote management and monitoring of machines over WAN. Instead of monetizing it and try to compete with the big companies i felt it more efficiant to make it open source and hope for community interest and development. "The what" The following features are under development, some arn't started, some are finished. Check the changelog for more info. Base components - Agent running as service - Central server with MySQL (hub engine) - Management client (AutoitGUI/WebGUI) Main features - Remote execution of shell commands as system or specific user - File transfer from/to agent - Live monitoring of system resources Consequential features (based on main features) - Hardware/software inventory - Software deployment/updating - Patch management - Antivirus management - OS deployment - Disaster recovery - Hardware/software/network monitoring - Wake on LAN - Reporting - Remote registry, event viewer, task manager - Scripting (obviously) Additional features (stand-alone modules) - Remote control - Servicedesk (based on ITIL) - AD-integration Security - Secure communication with SSL and rotating key for every session. - SHA256 encryption. Remmanaut network overview My knowledge of AutoIT is average but i'm novice when it comes to programing structure for collaboration, so if you're willing to help me out in making the project easy to share, i'd be very thankfull. Unfortunatly i'm no php-guru so i'll be concentrating on the AutoitGUI until the agent and hub engine reaches an adequate version. If you feel that this tool could benefit you in any way or just want to join the project for the fun of development, don't hesitate to post constructive feedback or hit me a PM. Code optimisation to do: Download:1 point
-
I routinely need to log information for my scripts. In the past, I've usually just created functions in each script to write to a log file. I also use ConsoleWrite in conjunction with SciTE a lot when I'm trying to debug scripts. After using some logging libraries for other languages (namely NLog (C#) and Java (log4j)) I decided to write a logging UDF for AutoIt. I decided to base it loosely upon the log4j and NLog libaries. I say loosely because this one is not nearly as feature rich as either one of those, but I think it still provides a nice logging interface. What can it do? Output types: Console, File, or Both. Additionally, you can configure the logger to output differently based on whether the script is compiled or not. This way you can output to the console (SciTE) while you're writing a script, and output to a log file when you've compile the script. Log levels: While I don't think it's really necessary to have this many log levels, these are the levels in ascending order of severity: Trace Debug Info Warn Error Fatal Log Filtering: The log can be enabled and disabled. There are also minimum and maximum log levels that can be configured to only show a range of log levels (i.e. a minimum level of warn would not log messages for trace, debug, or info). These filter levels can be overridden when logging a message if the need be. Error Stream: Logging can be configured to write to the stderr (i.e. ConsoleWriteError). When enabled, any log messages at the error level and above will be written to the error stream. Message Format Macros: The logging message format can be customized to your liking using the following macros: ${date} = Long date (i.e. MM/DD/YYYY HH:MM:SS) ${host} = Hostname of local machine ${level} = The current log level ${message} = The log message ${newline} = Insert a newline ${shortdate} = Short date (i.e. MM/DD/YYYY) Available Functions: Configuration Functions _log4a_SetCompiledOutput - Sets the logging output type for the compiled version of the script (Default: $LOG4A_OUTPUT_FILE) _log4a_SetEnable - Enables or disables logging messages (Default: Disabled) _log4a_SetErrorStream - Enables or disables logging of the standard error stream (Default: Enabled) _log4a_SetFormat - Configures the format of logging messages (Default: "${date} ${level} ${message}") _log4a_SetLogFile - Sets the path of the log file (Default: "<ScriptFullPath>.log") _log4a_SetMaxLevel - Configures the maximum log level to process messages (Default: $LOG4A_LEVEL_FATAL) _log4a_SetMinLevel - Configures the minimum log level to process messages (Default: $LOG4A_LEVEL_TRACE) _log4a_SetOutput - Sets the logging output type for the non-compiled version of the script (Default: $LOG4A_OUTPUT_CONSOLE) Logging Functions _log4a_Debug - Logs a message at the debug level _log4a_Error - Logs a message at the error level _log4a_Fatal - Logs a message at the fatal level _log4a_Info - Logs a message at the info level _log4a_Message - Logs a message to the configured outputs _log4a_Trace - Logs a message at the trace level _log4a_Warn - Logs a message at the warn level See the source file for full documentation of available functions. A quick example script: #include "log4a.au3" ; Enable logging and don't write to stderr _log4a_SetEnable() _log4a_SetErrorStream(False) log_messages() ; Write to stderr, set min level to warn, customize message format _log4a_SetErrorStream() _log4a_SetMinLevel($LOG4A_LEVEL_INFO) If @compiled Then _log4a_SetMinLevel($LOG4A_LEVEL_WARN) ; Change the min level if the script is compiled _log4a_SetFormat("${shortdate} | ${host} | ${level} | ${message}") log_messages() ; Disable logging (except for those that override) _log4a_SetEnable(False) log_messages() Func log_messages() _log4a_Trace("A TRACE message", True) ; overrides filters _log4a_Debug("A DEBUG message") _log4a_Info("A INFO message") _log4a_Warn("A WARN message") _log4a_Error("A ERROR message", True) ; overrides filters _log4a_Fatal("A FATAL message") EndFunc Without further adieu, the UDF: log4a.au31 point
-
I think it's the other way around : empty string converted to a number. I'm not sure though: it's a complicated piece of code which I don't fully understand (200+ lines without comments). If only I had lots of time to study it, but I am overwhelmed with several of my own projects. I mentioned it to the last person working on the code, but he doesn't seem to be around right now. I'm sure someone will take a look at it shortly.1 point
-
Take a look at Listview Group WM_NOTIFY trigger ?.1 point
-
ListView control, is it possible the collapse/expand of groups ??
FrancescoDiMuro reacted to mLipok for a topic
@AutoBert is right. And this is quite interesting feature (I never used it before). https://msdn.microsoft.com/en-us/library/windows/desktop/bb774936(v=vs.85).aspx btw. Using the example from HelpFile for: _GUICtrlListView_SetGroupInfo if you change: ; change this following line ; _GUICtrlListView_SetGroupInfo($idListview, 1, "New Group 1") ; to this two following line _GUICtrlListView_SetGroupInfo($idListview, 1, "New Group 1", 0, $LVGS_COLLAPSIBLE + $LVGS_COLLAPSED) _GUICtrlListView_SetGroupInfo($idListview, 2, "New Group 2", 0, $LVGS_COLLAPSIBLE + $LVGS_SELECTED) Then you get exactly effect which you ask in OP.1 point -
Sending Email
Balmukundam reacted to Jos for a topic
Believe the emal addresses should be comma delimited: $ToAddress = "balmukundam2012@gmail.com,sagnihotrisw@gmail.com" Jos1 point -
Generated script can easily modified: #include <Array.au3> #include <File.au3> Global $sTempFile=@ScriptDir&'\~scriptomatic.tmp' Global $aResult[0] $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $sComputer = "localhost" $Output = "" $sLvTitle = "Computer: " & $sComputer $oWMIService = ObjGet("winmgmts:\\" & $sComputer & "\") $colItems = $oWMIService.ExecQuery("SELECT * FROM CIM_VideoControllerResolution", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then $Output = $Output & "Caption: " & @TAB $Output = $Output & "Description: " & @TAB $Output = $Output & "HorizontalResolution: " & @TAB $Output = $Output & "MaxRefreshRate: " & @TAB $Output = $Output & "MinRefreshRate: " & @TAB $Output = $Output & "NumberOfColors: " & @TAB $Output = $Output & "RefreshRate: " & @TAB $Output = $Output & "ScanMode: " & @TAB $Output = $Output & "SettingID: " & @TAB $Output = $Output & "VerticalResolution: " & @CRLF For $objItem In $colItems $Output = $Output & $objItem.Caption & @TAB $Output = $Output & $objItem.Description & @TAB $Output = $Output & $objItem.HorizontalResolution & @TAB $Output = $Output & $objItem.MaxRefreshRate & @TAB $Output = $Output & $objItem.MinRefreshRate & @TAB $Output = $Output & $objItem.NumberOfColors & @TAB $Output = $Output & $objItem.RefreshRate & @TAB $Output = $Output & $objItem.ScanMode & @TAB $Output = $Output & $objItem.SettingID & @TAB $Output = $Output & $objItem.VerticalResolution & @CRLF Next $hTmp=FileOpen($sTempFile,2) FileWrite($hTmp,$Output) FileClose($hTmp) _FileReadToArray($sTempFile,$aResult,$FRTA_NOCOUNT, @TAB) _ArrayDisplay($aResult) FileDelete($sTempFile) Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "CIM_VideoControllerResolution") EndIf no you have all posible resolution from VideoControllerResolution in a Array1 point
-
It would look something like this (with thanks to Chimp for the initial adaptation): #include <Array.au3> #include <GUIConstants.au3> #include <GDIplus.au3> #include <Math.au3> Global Const $GUIwidth = 600 Global Const $GUIheight = 400 Global Const $citysize = 10 Global Const $halfcitysize = $citysize / 2 $hwnd = GUICreate("Straight-Angle Travelling Salesman Problem (using Simulated Annealing), by RTFC", $GUIwidth, $GUIheight) GUISetState() ; Load GDI+ resources _GDIPlus_Startup() Global $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) Global $bitmap = _GDIPlus_BitmapCreateFromGraphics($GUIwidth, $GUIheight, $graphics) Global $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) Global $hPenLine = _GDIPlus_PenCreate(0xFF0000FF, 4) Global $hPenCircle = _GDIPlus_PenCreate(0xFFFF0000, 4) ; Simulated Annealing vars Global $temperat, $path, $kk, $nswap, $nswapstep, $cost, $tempstep, $absimp, $lowestcost ; initialise SRandom(@MSEC + @AutoItPID); initialise randomising seed $verbose = True ; T: write regular progress updates to console ; define cities Global $XY[12][2] = [[0, 0],[15, 0],[15, 3],[0, 3],[6, 3],[9, 3],[9, 12],[6, 12],[0, 12],[15, 12],[15, 15],[0, 15]] Global $ncity = UBound($XY) ; 20 Global $wrongAnglePenalty=10 Global $maxcity = $ncity * 50 Global $n[7], $xx[7], $yy[7] ; base-1 indexed Global $x[$ncity + 1], $y[$ncity + 1], $iorder[$ncity + 1], $jorder[$maxcity + 1] ; base-1 indexed ;______START OF ANNEALING ROUTINE____________ $nover = 100 * $ncity ; maximum number of paths at any temperature $nlimit = 10 * $ncity ; maximum number of successful path changes before continuing $nwrite = Int($nover / 5) ; default status update interval if verbose=.t. $tempsteps = 100 ; number of temperature steps to try $tfactor = 0.90 ; annealing schedule: temperature is reduced by this factor after each step $path = 0 While True $temperat = 0.5 ; initial temperature; smaller = more aggressive + more myopic search $absimp = 0 ; counter $nswapstepzero = 0 ; counter ; prep the buffers For $cc = 1 To 6 $n[$cc] = 0 Next For $cc = 0 To $ncity - 1 $x[$cc] = 0.2 + $XY[$cc][0] * 0.020 ; Random() $y[$cc] = 0.2 + $XY[$cc][1] * 0.020 ; Random() $iorder[$cc] = $cc $jorder[$cc] = 0 Next For $cc = $ncity + 1 To $maxcity $jorder[$cc] = 0 Next ; prep the cost vars $path=_CalcPathLength() $prevpath=$path $initcost = $path $lowestcost = $path ; main loop starts here For $tempstep = 1 To $tempsteps ; try up to N temperature steps $nswap = 0 $nswapstep = 0 For $kk = 1 To $nover $n[1] = Random(1, $ncity, 1) ; choose beginning and end of segment $n[2] = Random(1, $ncity, 1) If $n[2] >= $n[1] Then $n[2] = 1 + Mod(($n[2] + 1), $ncity) ; count number of cities not on segment ($nn) $nn = 1 + Mod(($n[1] - $n[2] + $ncity - 1), $ncity) If $nn < 3 Then ContinueLoop ; store original situation $oldiorder=$iorder $oldjorder=$jorder ; decide whether to do a segment transport or reversal (equal chances) $doTransport = (Random() <= 0.5) If $doTransport Then ; try a segment transport $n[3] = $n[2] + Int(Abs($nn - 2) * Random()) + 1 $n[3] = 1 + Mod($n[3] - 1, $ncity) ; transport to a location not on the path _DoTransport() Else _DoReversal() EndIf $cost=_CalcPathLength()-$prevpath ; Listen to the wind, talk to the trees... Switch _AskOracle() Case True $nswap += 1 $path += $cost $prevpath=$path If $lowestcost > $path Then $nswapstep += 1 $absimp += 1 $lowestcost = $path EndIf If $nswap >= $nlimit Then ExitLoop case Else ;restore $path=$prevpath $iorder=$oldiorder $jorder=$oldjorder EndSwitch Next If $verbose Then _ScreenOut() If $nswapstep = 0 Then $nswapstepzero += 1 If $nswapstepzero = 30 Then ExitLoop ; no more improvements in the last N temperature steps ; reduce temperature = likelihood of following a trajectory away from the nearest LOCAL optimum (in the hope of getting nearer to the GLOBAL optimum) $temperat *= $tfactor Next ; show final result MsgBox($MB_OKCANCEL, "Simulated Annealing Test Result", "Shortest Path Length: " & $lowestcost) Exit WEnd _GDIclose() Exit Func _AskOracle() If $cost < 0 Then Return True Else ; this is where all the magic happens! Return (Random() < Exp(-($cost / $temperat))) EndIf EndFunc ;==>_AskOracle Func _CalcPathLength() Local $path = 0 Local $cc, $index1, $index2 For $cc = 1 To $ncity - 1 $index1 = $iorder[$cc] $index2 = $iorder[$cc + 1] $path += _Distance($x[$index1], $x[$index2], $y[$index1], $y[$index2]) Next $index1 = $iorder[$ncity] ; close the loop by tying path ends together $index2 = $iorder[1] $path += _Distance($x[$index1], $x[$index2], $y[$index1], $y[$index2]) For $cc = 1 To $ncity - 2 $index1 = $iorder[$cc] $index2 = $iorder[$cc + 1] $index3 = $iorder[$cc + 2] Switch $x[$index1]=$x[$index2] case True Switch $y[$index1]<>$y[$index2] case False $path += $wrongAnglePenalty EndSwitch case Else Switch $y[$index1]=$y[$index2] case False $path += $wrongAnglePenalty EndSwitch EndSwitch Switch $x[$index2]=$x[$index3] case True Switch $y[$index2]<>$y[$index3] case False $path += $wrongAnglePenalty EndSwitch case Else Switch $y[$index2]=$y[$index3] case False $path += $wrongAnglePenalty EndSwitch EndSwitch If $x[$index1]=$x[$index2] And $x[$index2]=$x[$index3] Then $path += $wrongAnglePenalty If $y[$index1]=$y[$index2] And $y[$index2]=$y[$index3] Then $path += $wrongAnglePenalty Next $index1 = $iorder[$ncity-1] $index2 = $iorder[$ncity] $index3 = $iorder[1] Switch $x[$index1]=$x[$index2] case True Switch $y[$index1]<>$y[$index2] case False $path += $wrongAnglePenalty EndSwitch case Else Switch $y[$index1]=$y[$index2] case False $path += $wrongAnglePenalty EndSwitch EndSwitch Switch $x[$index2]=$x[$index3] case True Switch $y[$index2]<>$y[$index3] case False $path += $wrongAnglePenalty EndSwitch case Else Switch $y[$index2]=$y[$index3] case False $path += $wrongAnglePenalty EndSwitch EndSwitch If $x[$index1]=$x[$index2] And $x[$index2]=$x[$index3] Then $path += $wrongAnglePenalty If $y[$index1]=$y[$index2] And $y[$index2]=$y[$index3] Then $path += $wrongAnglePenalty $index1 = $iorder[$ncity] $index2 = $iorder[1] $index3 = $iorder[2] Switch $x[$index1]=$x[$index2] case True Switch $y[$index1]<>$y[$index2] case False $path += $wrongAnglePenalty EndSwitch case Else Switch $y[$index1]=$y[$index2] case False $path += $wrongAnglePenalty EndSwitch EndSwitch Switch $x[$index2]=$x[$index3] case True Switch $y[$index2]<>$y[$index3] case False $path += $wrongAnglePenalty EndSwitch case Else Switch $y[$index2]=$y[$index3] case False $path += $wrongAnglePenalty EndSwitch EndSwitch If $x[$index1]=$x[$index2] And $x[$index2]=$x[$index3] Then $path += $wrongAnglePenalty If $y[$index1]=$y[$index2] And $y[$index2]=$y[$index3] Then $path += $wrongAnglePenalty return $path EndFunc ;==>_CalcPathLength Func _Distance($x1, $x2, $y1, $y2) Return Sqrt((($x1 - $x2) ^ 2) + (($y1 - $y2) ^ 2)) EndFunc ;==>_Distance Func _DoReversal() $n[3]=1+Mod(($n[1]+$ncity-2),$ncity) ; find the city before n[1]... $n[4]=1+Mod($n[2],$ncity) ; and after n[2] ; find coordinates of the four cities local $ii,$jj,$dex For $jj=1 to 4 $dex=$n[$jj] $ii=$iorder[$dex] $xx[$jj]=$x[$ii] $yy[$jj]=$y[$ii] Next Local $mm = (1 + Mod(($n[2] - $n[1] + $ncity), $ncity)) * .5 Local $ii, $jj, $ll, $itmp For $jj = 1 To $mm $ii = 1 + Mod(($n[1] + $jj - 2), $ncity) $ll = 1 + Mod(($n[2] - $jj + $ncity), $ncity) $itmp = $iorder[$ii] $iorder[$ii] = $iorder[$ll] $iorder[$ll] = $itmp Next EndFunc ;==>_DoReversal Func _DoTransport() $n[4]=1+Mod($n[3],$ncity) ; find the city following n[3] $n[5]=1+Mod(($n[1]+$ncity-2),$ncity) ; find the city before n[1]... $n[6]=1+Mod($n[2],$ncity) ; and after n[2] ; find coordinates of the six cities local $jj,$dex For $jj=1 to 6 $dex=$n[$jj] $ii=$iorder[$dex] $xx[$jj]=$x[$ii] $yy[$jj]=$y[$ii] Next Local $m1, $m2, $m3, $pp $m1 = 1 + Mod(($n[2] - $n[1] + $ncity), $ncity) ; find # cities from n1->n2 $m2 = 1 + Mod(($n[5] - $n[4] + $ncity), $ncity) ; find # cities from n4->n5 $m3 = 1 + Mod(($n[3] - $n[6] + $ncity), $ncity) ; find # cities from n6->n3 Local $mm = 1 For $pp = 1 To $m1 $jj = 1 + Mod($pp + $n[1] - 2, $ncity) $jorder[$mm] = $iorder[$jj] $mm += 1 Next For $pp = 1 To $m2 $jj = 1 + Mod($pp + $n[4] - 2, $ncity) $jorder[$mm] = $iorder[$jj] $mm += 1 Next For $pp = 1 To $m3 $jj = 1 + Mod($pp + $n[6] - 2, $ncity) $jorder[$mm] = $iorder[$jj] $mm += 1 Next For $pp = 1 To $ncity $iorder[$pp] = $jorder[$pp] Next EndFunc ;==>_DoTransport Func _ScreenOut() ConsoleWrite("Simulated Annealing. Initial Path length: " & $initcost & @CRLF) ConsoleWrite("Step: " & $tempstep & " of " & $tempsteps & "; Temperature: " & $temperat & @CRLF) ConsoleWrite("Executed Swaps: " & $nswap & "; shortest Path length: " & $lowestcost & @CRLF) ConsoleWrite("Total Improvements: " & $absimp & "; Improvements this step: " & $nswapstep & @CRLF & @CRLF) _DrawTSroute() EndFunc ;==>_ScreenOut Func _DrawTSroute() _GDIPlus_GraphicsClear($backbuffer) For $cc = 1 To $ncity - 1 $index1 = $iorder[$cc] $index2 = $iorder[$cc + 1] _DrawLine($x[$index1], $x[$index2], $y[$index1], $y[$index2]) Next $index1 = $iorder[$ncity] ; close the loop by tying path ends together $index2 = $iorder[1] _DrawLine($x[$index1], $x[$index2], $y[$index1], $y[$index2]) _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $GUIwidth, $GUIheight) EndFunc ;==>_DrawTSroute Func _DrawLine($x1, $x2, $y1, $y2) Local $x1scaled = Round($GUIwidth * $x1, 0) Local $y1scaled = Round($GUIheight * $y1, 0) Local $x2scaled = Round($GUIwidth * $x2, 0) Local $y2scaled = Round($GUIheight * $y2, 0) _GDIPlus_GraphicsDrawArc($backbuffer, $x1scaled - $halfcitysize, $y1scaled - $halfcitysize, $citysize, $citysize, 0, 360, $hPenCircle) _GDIPlus_GraphicsDrawLine($backbuffer, $x1scaled, $y1scaled, $x2scaled, $y2scaled, $hPenLine) EndFunc ;==>_DrawLine Func _GDIclose() _GDIPlus_PenDispose($hPenLine) _GDIPlus_PenDispose($hPenCircle) _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_Shutdown() EndFunc ;==>_GDIclose Of course, the new cost function as crudely implemented here is favouring right angles and non-overlapping line segments as additional constraints (through var $wrongAnglePenalty). A more general solution to close polygons would need more sophisticated cost functions. The problem is how to define a generic optimal solution; that'll still depend on your specific requirements. So this specific solution won't work for angles other than 90/270 degrees, for example.1 point
-
"/c" stands for "close". Means: Run( @comspec & ' /c starts the DOS environment and executes the command. When finished it closes the window and exits. Try "/k" to "keep" the window. Useful when you need to debug your code. "|" is the DOS pipe character. Means: It grabs the output of the command left of the pipe character and passes it as input to the command right of the character.1 point
-
Using AutoItX.dll in Visual Studio 2012 in Selenium test
verycoogreg reacted to gritter for a topic
I just solved my problem myself. I was so close the last time. In addition to adding the 2 dll's to the project as files, I need to change their VS properties so they are copied to the output folder. By default, they are not copied. Maybe most everyone already knows that. I didn't. IMHO, it would be a nice addition to the documentation.1 point -
ale1981, If you want the {TAB} key to run the check and move on if correct in the same manner as the {ENTER} key, just set it as another accelerator linked to the same dummy control: Local $aAccelKeys[2][2] = [["{ENTER}", $cEnter], ["{TAB}", $cEnter]] Now pressing either of the 2 keys will run the handler. M231 point
-
Didn't spend much time thinking about what the _IsPressed() example from the help file was doing...? Take out the ExitLoop, and get the mouse pos: #include <Misc.au3> HotKeySet("{END}", "_Quit") ; Hit "END" to quit $dll = DllOpen("user32.dll") While 1 If _IsPressed("01", $dll) Then $avMousePos = MouseGetPos() ToolTip("x = " & $avMousePos[0] & " y = " & $avMousePos[1]) EndIf WEnd Func _Quit() DllClose($dll) Exit EndFunc ;==>_Quit1 point