Leaderboard
Popular Content
Showing content with the highest reputation on 03/22/2018 in all areas
-
reassigning the same value to a variable repeatedly
TheAutomator and one other reacted to Bilgus for a topic
In the end you just caused it extra work because it had to move things around to check the value and then decide to run or jump past run code to set the value It ends up being less instructions for the PC to set the value blindly.. Its down to counting grains of sand in a desert and in Autoit it probably isn't going to make any difference but in C for instance you just added two or 3 instructions and that makes a noticeable difference in a really tight loop where performance counts Really unless you have an issue with performance in the end you are probably better off just going with whatever is easiest to read try something like this Local $t = TimerInit() Local $b = True For $i = 0 to 100000 If $b = true Then $b = False Next ConsoleWrite("T1 " & timerDiff($t) & @CRLF) Local $t = TimerInit() For $i = 0 to 100000 $b = False Next ConsoleWrite("T2 " & timerDiff($t) & @CRLF)2 points -
Names of your arrays are $array, not just array. You can use this code... #include <Array.au3> global $allarrays[3] = ['$array1','$array2','$array3'] global $array1[3] = ['1', '2', '3'] global $array2[3] = ['1', '2', '3'] global $array3[3] = ['1', '2', '3'] for $i = 0 to UBound($allarrays) - 1 Execute("_ArrayDelete(" & $allarrays[$i] & ", 0)") Next _ArrayDisplay($array1)2 points
-
Totally the ampersand, Ive yet to see anything work right trying to match & Also get rid of the spaces at the start of the title WinActive("[TITLE:My Window]", "") next WinWait, WinActive, WinExists, WinWaitActive and their ilk all return a handle to the matched window on success rather than trying to get a match each subsequent time pass the hWnd you already matched Local $hWnd = WinWaitActive(....) ControlClick($hWnd,"", "........")2 points
-
A couple of suggestions -- Either remove the "Title:" or wrap the parameter in square brackets. More info here. Try removing the ampersand from the 2nd parameter2 points
-
The new _DebugArrayDisplay has built-in functionality to do exactly that: #include <Debug.au3> Global $aArray1 = [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ] Global $aArray2 = [ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 ] Global $aArray3 = [ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 ] _DebugArrayDisplay( $aArray1, "$aArray1", "", 0, Default, Default, Default, ShowArray2 ) Func ShowArray2( $p1, $p2 ) _DebugArrayDisplay( $aArray2, "$aArray2", "", 0, Default, Default, Default, ShowArray3 ) EndFunc Func ShowArray3( $p1, $p2 ) _DebugArrayDisplay( $aArray3, "$aArray3" ) EndFunc2 points
-
Automatically connect to Wifi network
Earthshine reacted to JLogan3o13 for a topic
Again - why are you unwilling to read that second link, wanting someone to spoon feed it all back to you??? You have to use netsh wlan add --- In order to add a new profile, you need an XML file - which the link spells out for you in the comments section. The only additional help anyone can give you is to write the whole thing for you.1 point -
Copy a file to clipboard to be manually pasted as shortcut
Earthshine reacted to masvil for a topic
OK, you put me in the right direction. Thank you! So for now my best solution is to create the shortcut and then copy the shortcut itself to clipboard, so on the next manual Explorer's "Paste" command the trick is done. #include <Misc.au3> $FileCreateShortcut = FileCreateShortcut("path\to\file", @TempDir & "\shortcut.lnk", @ScriptDir, "", "", "", "") _ClipPutFile(@TempDir & "\shortcut.lnk")1 point -
Copy a file to clipboard to be manually pasted as shortcut
masvil reacted to Earthshine for a topic
Oh, I thought you meant pasting as shortcut from the clipboard. I don't think copying the file to clipboard what you want to do as it only yields the one result. You can create lnk shortcut files in AutoIt for sure. And since you know the file exists and where it lives, this should not be a lot of problems. Explorer is just creating the .lnk file for you with paste as shortcut. Again, I am sure you can do this programatically with AutoIt. update, found it! FileCreateShortcut here is the sample from that page. #include <MsgBoxConstants.au3> Example() Func Example() ; Create a constant variable in Local scope of the shortcut filepath. Local Const $sFilePath = @DesktopDir & "\FileCreateShortcutExample.lnk" ; Create a shortcut on the desktop to explorer.exe and set the hotkey combination Ctrl+Alt+T or in AutoIt ^!t to the shortcut. FileCreateShortcut(@WindowsDir & "\explorer.exe", $sFilePath, @WindowsDir, "/e,c:\", _ "Tooltip description of the shortcut.", @SystemDir & "\shell32.dll", "^!t", "15", @SW_SHOWMAXIMIZED) ; Retrieve details about the shortcut. Local $aDetails = FileGetShortcut($sFilePath) If Not @error Then MsgBox($MB_SYSTEMMODAL, "", "Path: " & $aDetails[0] & @CRLF & _ "Working directory: " & $aDetails[1] & @CRLF & _ "Arguments: " & $aDetails[2] & @CRLF & _ "Description: " & $aDetails[3] & @CRLF & _ "Icon filename: " & $aDetails[4] & @CRLF & _ "Icon index: " & $aDetails[5] & @CRLF & _ "Shortcut state: " & $aDetails[6] & @CRLF) EndIf ; Delete the shortcut. FileDelete($sFilePath) EndFunc ;==>Example so, since you know where it is, and that it exists, you can just adapt that to your needs as a test mule.1 point -
Copy a file to clipboard to be manually pasted as shortcut
masvil reacted to Earthshine for a topic
you can't do that. it needs to live somewhere, the file that is being shortcut-ted to. a shortcut is a .LNK file that contains the information where the app or file it points to lives. You can create lnk files but that actual app or file needs to live on a drive somewhere. what you want is not possible. in short, there is NO pasting as shortcut. period.1 point -
If you are going to be dropping whole drives a few changes need to be made One we need a way to limit the recursion not sure of the limit but there will for sure be one.. Autoit will bail if you reach it Two is it could take a while so you need to inform the user somehow I just put in a message box you'll probably want a status item and to change the cursor to busy etc.. #include <GUIConstantsEx.au3> ; $GUI_EVENT_CLOSE #include <WindowsConstants.au3> #include <GuiListBox.au3> #include <WinAPISys.au3> ;WinAPI_ChangeWindowMessageFilterEx ;_WinAPI_DragQueryFileEx #include <WinAPIFiles.au3> ;_WinAPI_FindFirstFile $hGUI = GUICreate("FileDrop", 550, 300, Default, Default, Default, $WS_EX_ACCEPTFILES) $cList = GUICtrlCreateList("", 0, 0, 450, 300) $bClear = GUICtrlCreateButton("Clear", 460, 0, 75, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $cDrop_Dummy = GUICtrlCreateDummy() ;Dummy control recieves notifications on filedrop GUISetState(@SW_SHOW) If IsAdmin() Then ; Allow WM_DROPFILES to be received from lower privileged processes (Windows Vista or later) _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW) _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_DROPFILES, $MSGFLT_ALLOW) EndIf ; Register $WM_DROPFILES function to detect drops anywhere on the GUI GUIRegisterMsg($WM_DROPFILES, "_WM_DROPFILES") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cDrop_Dummy _On_Drop(GUICtrlRead($cDrop_Dummy)) Case $bClear GUICtrlSetData($cList, "") EndSwitch WEnd Func _On_Drop($hDrop) Local $aDrop_List = _WinAPI_DragQueryFileEx($hDrop, 0) ; 0 = Returns files and folders Local $aList[1000][2] = [[0]] ;[FileName][FileSz] For $i = 1 To $aDrop_List[0] GUICtrlSetData($cList, $aDrop_List[$i]) ;Dumps dropped files to listview IF StringLen($aDrop_List[$i]) < 4 Then MsgBox(0,"Test", "This Will Take a While Message Etc...") Find_AllFiles($aDrop_List[$i], $aList, 100) ;Recursively finds files Next _GUICtrlListBox_BeginUpdate ($cList) For $i = 1 To $aList[0][0] ;Dumps found files to listview GUICtrlSetData($cList, $aList[$i][0]) Next _GUICtrlListBox_EndUpdate ($cList) EndFunc ;==>_On_Drop ; React to items dropped on the GUI Func _WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam GUICtrlSendToDummy($cDrop_Dummy, $wParam) ;Send the wParam data to the dummy control EndFunc ;==>_WM_DROPFILES Func Find_AllFiles($sPath, ByRef $aList, $iMaxRecursion, $bRecurse = True) Local $tData = DllStructCreate($tagWIN32_FIND_DATA) Local $sFile If StringRight($sPath, 1) <> "\" Then $sPath &= "\" Local $hSearch = _WinAPI_FindFirstFile($sPath & '*', $tData) While Not @error $sFile = DllStructGetData($tData, 'cFileName') Switch $sFile Case '.', '..' Case Else If Not BitAND(DllStructGetData($tData, 'dwFileAttributes'), $FILE_ATTRIBUTE_DIRECTORY) Then $aList[0][0] += 1 If $aList[0][0] > UBound($aList) - 1 Then ReDim $aList[UBound($aList) + 4096][2] EndIf $aList[$aList[0][0]][0] = $sPath & $sFile;;$sFile ;if you want full path.. $sPath & "\" & $sFile $aList[$aList[0][0]][1] = _WinAPI_MakeQWord(DllStructGetData($tData, 'nFileSizeLow'), DllStructGetData($tData, 'nFileSizeHigh')) Elseif $bRecurse Then if $iMaxRecursion > 0 Then Find_AllFiles($sPath & $sFile, $aList, $iMaxRecursion - 1, $bRecurse) Else Msgbox(0,"Error", "Max Recursion Exceeded") EndIF EndIf EndSwitch _WinAPI_FindNextFile($hSearch, $tData) WEnd _WinAPI_FindClose($hSearch) EndFunc ;==>Find_AllFiles1 point
-
close Excel file
JNutt reacted to JLogan3o13 for a topic
@JNutt again, doing a little research will help you with these questions early on. AutoIt has a full range of Excel capabilities, all outlined in the help file. If you look at _Excel_BookAttach, you will see an example of attaching to a workbook object so you can then manipulate it as needed.1 point -
1 point
-
What is $hWnd
JNutt reacted to JLogan3o13 for a topic
@JNutt Google is your friend: https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx1 point -
WindowInfo - control ID
Earthshine reacted to JNutt for a topic
I really appreciate your help Earthshine. When I run it the code the different options will hightlighte the Scite editor and part of the taskbar, but not the app I want it to. Should the Output panel show me anthing? Below is the what I see in the output: >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Program Files (x86)\AutoIt3\bin\open_button.au3" deep find in subtree oP1;Desktop deep find in subtree oP2;Desktop deep find in subtree oP3;Desktop deep find in subtree oP3;Desktop >Exit code: 0 Time: 10.821 point -
If you are hard set on names rather than array references you'll need some extra overhead As far as removing the first item of an array your best bet is to set it to "" or some other sentinel value and then ignore that value OR delete all 'Empty' sentinels in a big batch there just isn't a way around shifting the array down otherwise in the includes folder have a look inside array.au3 you might be able to eliminate some of the code and make your own arraydelete function1 point
-
Instead of putting the names of the arrays into an array, you could put the actual arrays into the array. #include <Array.au3> example() ;========================================================================== ; ;========================================================================== Func example() local $array1[3] = ['1', '2', '3'] local $array2[3] = ['1', '2', '3'] Local $array3[3] = ['1', '2', '3'] Local $allarrays[3] = [$array1, $array2, $array3] for $i = 0 to UBound($allarrays) - 1 _ArrayDelete($allarrays[$i], 0) Next _ArrayDisplay($allarrays[0]) EndFunc1 point
-
Example of Intercepting WM_MOVING to restrict area the window can be moved to ;Autoit v3.3.14.5 Limit Form Move Example-- Bilgus 2018 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> ;_WinAPI_DefWindowProc() Global $g_hGUI, $g_idLimit Global $g_aWindowLimits = [15, 10, @DesktopWidth / 2, @DesktopHeight / 2] ; Min X, Min Y, Max X, Max Y GUIRegisterMsg($WM_MOVING, WM_MOVING) ;Register a callback function for $WM_MOVING Example() Func Example() ; Create a GUI with various controls. $g_hGUI = GUICreate("Example") $g_idLimit = GUICtrlCreateCheckbox("Limit Drag", 10, 370, 85, 25) Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $g_hGUI) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($g_hGUI) EndFunc ;==>Example Func WM_MOVING($hWnd, $iMsg, $wParam, $lParam) If $hWnd = $g_hGUI Then Local $bLimited = False ;Current rect is passed in lParam Local $tRect = DllStructCreate($tagRect, $lParam) ; (IS NOT X, Y, W, H) => (IS X, Y, X+W, Y+H) Local $iLeft = DllStructGetData($tRect, 1) Local $iTop = DllStructGetData($tRect, 2) Local $iRight = DllStructGetData($tRect, 3) Local $iBottom = DllStructGetData($tRect, 4) Local $iWidth, $iHeight ;Check left and right of window against imposed limits If $iLeft < $g_aWindowLimits[0] Then $iWidth = $iRight - $iLeft ;Calculate Original Width $iLeft = $g_aWindowLimits[0] $iRight = $iLeft + $iWidth ;Have to keep our same Width $bLimited = True ElseIf $iRight > $g_aWindowLimits[2] Then $iWidth = $iRight - $iLeft ;Calculate Original Width $iRight = $g_aWindowLimits[2] $iLeft = $iRight - $iWidth ;Have to keep our same Width $bLimited = True EndIf ;Check top and bottom of window against imposed limits If $iTop < $g_aWindowLimits[1] Then $iHeight = $iBottom - $iTop ;Calculate Original Height $iTop = $g_aWindowLimits[1] $iBottom = $iTop + $iHeight ;Have to keep our same Height $bLimited = True ElseIf $iBottom > $g_aWindowLimits[3] Then $iHeight = $iBottom - $iTop ;Calculate Original Height $iBottom = $g_aWindowLimits[3] $iTop = $iBottom - $iHeight ;Have to keep our same Height $bLimited = True EndIf If $bLimited And BitAND(GUICtrlRead($g_idLimit), $GUI_CHECKED) Then ;Limit happened -- Pass new Values Back to WndProc DllStructSetData($tRect, 1, $iLeft) DllStructSetData($tRect, 2, $iTop) DllStructSetData($tRect, 3, $iRight) DllStructSetData($tRect, 4, $iBottom) _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam);Pass new Rect on to default window procedure Return 1 ; True EndIf EndIf Return $GUI_RUNDEFMSG ;Default Handler EndFunc ;==>WM_MOVING1 point
-
Great work once again, Bilgus! I am profoundly impressed.1 point
-
maybe Ctrl Shift 0 Is in use by the OS yep.. https://support.microsoft.com/en-us/help/967893/input-method-editor-keyboard-shortcut-ctrl-shift-0-switches-the-input1 point
-
Winexists/winactive IF block, not recognising the window is there
Bilgus reacted to Earthshine for a topic
post your real code. pictures don't cut it.1 point -
Extended Message Box - New Version: 16 Feb 24
mLipok reacted to GordonShumway for a topic
Thank you Melba23 I'm very happy with your modifications/improvements And I have secretly renamed your "ExtMsgBox_Test.au3" to "ExtMsgBox.au3"1 point -
How to Check / Uncheck all checkedboxlist item
Earthshine reacted to water for a topic
As the tools has been written by your company, can't you simply add a "select all" button to the application?1 point -
The Windows way is to capture the WM_MOVING message and update the Rect accordingly1 point
-
If you know the form number, then use the $iIndex parameter to directly retrieve the desired form -- Local $oForm = _IEFormGetCollection($oIE, 0)1 point
-
If you know there is only one form then you could use _IETagNameGetCollection($oIE, "form"), you can also use another element within the form to make changes, i.e. you don't need to use the _IEForm... functions to make changes to a form.1 point
-
@CYCho You can read about the Capabilities implementation in the W3C specs. Note that each webdriver may support it's own unique options. I am not aware of any issues with not calling _WD_DeleteSession.1 point
-
WindowInfo - control ID
Earthshine reacted to Bilgus for a topic
1 point -
The Document object does have a cookie property that you can use to read and write cookies. Typically this would be done from the source document coming from the server, so I am uncertain about security restrictions that may get in your way since I haven't tested. In any case, something like this: #include <IE.au3> $oIE = _IECreate("http://you.web.site") $oDoc = _IEDocGetObj($oIE) $oDoc.cookie = $sCookie $sCookie would be a semi-colon separated string of name-value pairs. The names and values can be arbitrary, but there is one expected one - expires=timeInGMT. If you do not set an expiration, the cookie will not persist when the browser exits. So, for example: $sCookie = "name=JohnSmith;password=OurDepartment;expires=Mon 05 Aug 2006 02:33:22 GMT" Dale1 point
-
Copy a file to clipboard to be manually pasted as shortcut
Earthshine reacted to masvil for a topic
How can I copy a file to clipboard to be manually pasted as shortcut through Explorer? If I use _ClipPutFile then only "Paste" command is available in Explorer context menu. I need "Paste as shortcut" to be available too.0 points