Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all 12506 articles
Browse latest View live

FileOpen $FO_CREATEPATH doesnt work

$
0
0

The FileOpen help file gives these options:

 

[optional] Mode to open the file in.
Can be a combination of the following:
    $FO_READ (0) = Read mode (default)
    $FO_APPEND (1) = Write mode (append to end of file)
    $FO_OVERWRITE (2) = Write mode (erase previous contents)
    $FO_CREATEPATH (8) = Create directory structure if it doesn't exist (See Remarks).
 
and some more options.
 
But this simple code just doesn't work:
dim $hFileOpen
$hFileOpen  = FileOpen ( "c:\test\test.txt", $FO_CREATEPATH )
If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when creating/opening the file.")
        Return False
    EndIf
FileClose($hFileOpen)
 
 
Is the FO_CREATEPATH mode not implementen? Found it weird nobody on the forum ever encountered this...

 


strange behavior

$
0
0

I'm using only variables to store window/control sizes and positions on the screen, hotkeys and mouseclicks (combined with these variables).

 

I noticed, that sometimes after modification - script isn't working correctly (each time) - mouse is shifted from proper positions. But after I push the script through debugger - it works fine there, and after that - it works correctly when running normally.

 

What an be reason for that?

Need help selecting a specific data from a CSV file into a variable

$
0
0

Hi. This is my firs post.

 

I'm using AutoIT to automate a Python script that will wirelessly program sensor nodes that its users will need reprograming by opening several windows asking for the required parameters and then constructing a Python command line with all those parameters and executing it.

This all works very well. When running the AutoIT script, a window pops up and asks for a node number, then the hex file the Python script will upload and the com port of the gateway trough which it will be uploaded it into the node.

 

To select the com port I use this function, that is also working very well:

AutoIt         
Func comPort()    Local $idCombo    ; Create GUI    GUICreate("Click on a COM Port", 250, 150)    $idCombo = GUICtrlCreateCombo("", 2, 2, 250, 150,$WS_TABSTOP)    GUISetState(@SW_SHOW)    For $i = 1 To 100       Local $sVar = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM", RegEnumVal("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM", $i))       If $sVar = "" Then ExitLoop       _GUICtrlComboBox_InsertString($idCombo,$sVar,-1)    Next    Global $idMsg, $comPort    ; Loop until the user exits.    Do       $idMsg = GUIGetMsg()       If $idMsg = $GUI_EVENT_CLOSE Then          ExitLoop       ElseIf $idMsg = $idCombo Then          $comPort = GUICtrlRead($idCombo, 1) ; return the text of the menu item       EndIf    Until $idMsg = $GUI_EVENT_PRIMARYUP ; Until the mouse butten is released after a click    GUIDelete()    If $comPort = "" Then       MsgBox($MB_SYSTEMMODAL, "ERROR!", "COM Port not selected!" & @CRLF & "Script Stopped...")       Exit    EndIf EndFunc ;Func comPort()

This will look into the Registry for any available com ports and allow the user to choose the right one by just clicking on his choice.

This is required because everytime the gateway is plugged in, the com port may change.

 

But to ask for the node number I wanted to do something more besides asking for a destination node number. I want the user to look at a list of available nodes numbers and their respective description to avoid choosing the wrong node. For that each user would have to create a setup.txt file with some CSV data, like  "node number,node function" in each row.

 

But I just can't figure out how to load the CSV data into a table, displaying it and allow the user to just point and click a selection.

I can dispaly a table but then the user have to click on one of three buttons on the bottom that show up to copy data into the clipboard and that won't work.

 

Can anyone please help me create a function that will:

- Open some sort of combobox or table display

- Read data from a setup.txt file in a CSV format (x, y) per each row

- Assign each line of the CSV file to a row in the opened table

- Name the Column headers of the table

- Allow the user to click a row

- Assign the first item of the row (the x) to a global variable to be used later in the script.

- Close that window immediately after the user clicked the row

 

Thank you.

How to script file upload button

$
0
0

<input type="file" name="file" multiple="">

 

Hi guys, our company's website has this button for uploading multiple images. How can I create a script that automatically selects the images then uploads them? I already know the path of each images. I just don't want to script a click on the file upload button since I get a headache trying to make that work. My current goal is to script it with something like:

 

$files1 = "C:\TeamBuilding\Team Games.jpg"

$files2 = "C:\TeamBuilding\Team Prayer.jpg"

$oIE.getelementbyid("file").upload $files1, $files2

 

 

Then after the image upload the form is submitted. Obviously the code above is a fantasy :D I just need the part to script uploading the images instead of clicking the upload button. My Autoit script will modify the innerHTML of this form to add the script for auto-upload. Is this doable? 

Audio files to Audio CD image

$
0
0

Is there an existing AutoIt solution for selecting some audio files and creating the bin/cue (or any other supported image type)?

 

My searches so far have only turned up ripping them back from the Audio CD, not preparing existing audio files for burn.

stringregexp replace leading spaces of every line from edit control

$
0
0

hello world..

 

i am trying to remove the leading spaces for every line in an edit control...

 

i was going to cycle through each line using _GuilCtrlEdit_GetLine and remove the spaces using stringstripws

 

but i think this can probably done faster using stringregexp

 

i found this.. http://www.autoitscript.com/forum/topic/157998-stringregexp-expression-help/but it doesnt seem to work when i replace the - with a $

 

its probably because the $ isnt being read as a literal character so i tried using chr(36) - still didnt work.

 

any ideas?

 

thanks in advance

Tray menu exit not working

$
0
0

Sorry to be a bother. This code seems to be working as I want to except that the exit option on the tray menu doesn't do anything.

AutoIt         
#NoTrayIcon #include <File.au3> #include <MsgBoxConstants.au3> #include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant. #include <funcs.au3> Global $aFileArray Global $mFile = "c:\print\print.txt" _FileWriteLog(@ScriptDir & "\Example.log", "Program Started, lets rock!") Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.     Local $idExit = TrayCreateItem("Exit")     Global $isOpen = 0     TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.     While 1       Switch TrayGetMsg()          Case $idExit ; Exit the loop.          Exit       EndSwitch       Local $checkFile = _FileInUse($mFile)       If $checkFile == 1 Then          $isOpen = 1          sleep(1000)       Elseif $checkfile == 0 Then          $isOpen = 0          sleep(1000)       EndIf       If $isOpen == 0 Then             If Not FileExists($mFile) Then                ;file no exist do nothing             Else                ;check if file is in use one more Time                Local $checkAgain = _FileInUse($mFile)                if $checkAgain == 1 Then                   ; file still open lets sleep for a bit and go again                   Sleep(10000)                Else                   ;print the file                   If FileExists("c:\print\print.txt") Then                      If Not _FileReadToArray("c:\print\print.txt", $aFileArray) Then                         _FileWriteLog(@ScriptDir & "\Example.log", "Read print.txt failed with error code" & @error & ". Program halted.")                         Exit                      Else                         _FileWriteLog(@ScriptDir & "\Example.log", "Read print.txt successful, moving on")                      EndIf                      Global $aStart                      If Not $aStart = _ArrayFindAll($aFileArray , "SEVEN UP" , '' , '' , '' , 1) Then                         _FileWriteLog(@ScriptDir & "\Example.log", "Failed to find Sevenup name. Error " & @error & ". Program halted.")                         Exit                      Else                         _FileWriteLog(@ScriptDir & "\Example.log", "Find Sevenup name, succesful, moving on")                         $aStart = _ArrayFindAll($aFileArray , "SEVEN UP" , '' , '' , '' , 1)                      EndIf                      for $i = 0 to ubound($aStart) - 1                         If $i = ubound($aStart) - 1 Then                              _FileWriteFromArray("c:\print\OUTPUT_" & $i & ".txt" , $aFileArray , $aStart[$i] , $aFileArray[0])                              _FileWriteLog(@ScriptDir & "\Example.log", "Split file " & $i & " created")                              ;_FileWriteLine_top("c:\print\OUTPUT_" & $i & ".txt", @CRLF)                              _FilePrint("c:\print\OUTPUT_" & $i & ".txt")                              _FileWriteLog(@ScriptDir & "\Example.log", "Split file " & $i & " printed")                               Sleep(500)                               FileDelete("c:\print\OUTPUT_" & $i & ".txt")                               _FileWriteLog(@ScriptDir & "\Example.log", "Split file " & $i & " deleted")                         Else                              $next = $i + 1                              _FileWriteFromArray("c:\print\OUTPUT_" & $i & ".txt" , $aFileArray , $aStart[$i] , $aStart[$next] - 1)                              _FileWriteLog(@ScriptDir & "\Example.log", "Split file " & $i & " created")                             ; _FileWriteLine_top("c:\print\OUTPUT_" & $i & ".txt", @CR)                              _FilePrint("c:\print\OUTPUT_" & $i & ".txt")                              _FileWriteLog(@ScriptDir & "\Example.log", "Split file " & $i & " printed")                               Sleep(500)                               FileDelete("c:\print\OUTPUT_" & $i & ".txt")                               _FileWriteLog(@ScriptDir & "\Example.log", "Split file " & $i & " deleted")                         EndIf                      next                      FileDelete("c:\print\print.txt")                   EndIf                EndIf             EndIf       Elseif $isOpen == 1 Then             If Not FileExists($mFile) Then                ;do nothing             Else                Local $check = _FileInUse($mFile)                If $check == 1 Then                   ; file in use drop out and check again                Elseif $check == 0 Then                   ; file is free, check $isOpen to 0                   $isOpen = 0                EndIf             EndIf       Endif WEnd

Thanks for your help. I appreciate it.

imagesearch help

$
0
0

im trying to use this 

 

this imagesearcharea functions a but confused need help

 

#include <ImageSearch.au3>
 
HotKeySet("p", "checkForImage")
 
global $y = 0, $x = 0 ; could i change the y n x to 618,351 or that is compelely different?
 
Func checkForImage()
 
local $search = _ImageSearchArea('opapp.bmp', 1, 800, 40, 900, 80, $x, $y, 0) ; confused about the values on the right.
 
If $search = 1 Then
MouseMove($x, $y, 10)
EndIf
EndFunc
 
while 1
sleep(200)
WEnd

 

my question is image im clicking on is located at 618,351 its square image

i search the forum did find any simple or good explaination

 

 

 


Read from Pastebin private paste!

$
0
0

Hello, I am new here, and I would like to run a program which can read one or two short lines of text from Pastebin PRIVATE paste....I have found somewhere here this nice and simple code:

#include <MsgBoxConstants.au3> Example() Func Example()     ; Read the file without downloading to a folder. The option of 'get the file from the local cache' has been selected.     Local $dData = InetRead("http://pastebin.com/raw.php?i=tspvr1Cw")     ; The number of bytes read is returned using the @extended macro.     Local $iBytesRead = @extended     ; Convert the ANSI compatible binary string back into a string.     Local $sData = BinaryToString($dData)     ; Display the results.     MsgBox($MB_SYSTEMMODAL, "", "The number of bytes read: " & $iBytesRead & @CRLF & @CRLF & $sData)     ConsoleWrite("Raw Paste: " & $iBytesRead & @CRLF & @CRLF & $sData)     MsgBox($MB_SYSTEMMODAL, "", $sData) EndFunc   ;==>Example

But, I am getting this at msgbox and console : Error, this is a private paste. If this is your private paste, please login to Pastebin first

 

I have tried to put my Pastebin credentials here:

InetRead("http://username:password@pastebin.com/raw.php?i=XJaZmVhz")

but to no avail!

 

All I want is to read from my private Pastebin.....I do not want to be able to create pastes....ONLY TO READ and pass the paste text to variable as string.

 

I would really appreciate help on this....I am new to autoit scripting and I would like to extend my knowledge!

 

Thank you all in advance!

hotkey with single function

$
0
0
  1. ;#work in progress.
  2. ;~ #RequireAdmin
  3. Global $Macro = False
  4.  
  5. HotKeySet("{SPACE}", "SpaceMacro")
  6.  
  7.  
  8.     Sleep(100)
  9.  
  10. Func SpaceMacro()
  11.     $Macro = Not $Macro
  12.     While $Macro
  13.         Send("{SPACE}")
  14.         Sleep(250)
  15.         ConsoleWrite("WORK")
  16.     WEnd
  17.     ConsoleWrite("TEST")

i am trying to make that hotkey (SPACE) to call the function and keep running while loop , and when space pressed again stop the loop. but it just runs it one time thats that. what am i doing wrong? 

I know the forum rules, no hacks , cheats. but this isnt hack. keyboard macro are allowed in games. this is exactly what itll be . keyboard macro to save my spacebar

AutoIT image search problems

$
0
0
hey guys, I recently started using the AutoIT image search, and its been working fine... then it just quit working for some reason. No error code it just doesn'Tfind the image. im using the exact same code i was using and it still isnt working.ANY help is very appreciated.Also i have the image and the script in the same folder. Here is one of the 4 scripts ive tried.
#include <ImageSearch.au3> sleep(2000) $X = 0 $Y = 0 $X1 = 0 $Y1 = 0 Func start()    $Search = _ImageSearch('Play.bmp', 0, $X, $Y, 0)    If $Search = 1 Then  MouseMove($X, $Y,10)    EndIf EndFunc
 
 
 
 

Change public IP address

$
0
0

Is there a way to change my public IP address other than "use a robot to unplug my modem and plug it back again" or "change modem daily" or "contact my ISP daily" as i found with some research.

 

I can do it manually by logging in to my IP address. I have an option there where i can disconnect and connect back again. That does change my public IP address but even if i automate that, it wouldn't work on other connections.
 

So any other options?

 

searching for a phrase in a txt file

$
0
0

hi, this is probably a noob question but i did write a script to search for a text in a .txt file but it seems to be not working and i cant seem to figure out why any help would be appretiated

 
#include <File.au3>
Dim $array
 
$file = @ScriptDir & '\DEBUG.log.txt'
$find = 'Unable to Log in: Invalid Login or PIN'
 
If $file <> '' Then
_FileReadToArray($file, $array)
For $i = 1 To UBound($array) - 1
if StringInStr($array[$i], $find) Then
MsgBox(64, 'Failed', 'Login Failed')
Else
MsgBox(64, 'Passed','Login Succesfull')
EndIf
Next
Else
MsgBox(64, 'Failed','Empty file')
EndIf
 
the file contains the $find phrase but the script still returns Login Succesfull and it turns it into an infinite loop.
 

Link for changes in versions

$
0
0

Looking for the link to show what breaks the script with the different versions. Tried the search, but 40 pages is a lot to look at - thanks for your help.

pressing other keys while script is running

$
0
0

i have a script that runs numbers 1-10 and i would like to be able to press other keys inbetween them, if i see somehting, is there a way to maybe have a 1/4 sec pause to see if i press a key or not?


Introspection and Actions; UIA_PaneControlTypeId and A Grid Within

$
0
0

I'm trying to conduct UI automation using AutoIt through use of the UI Automation library provided by @junkew.  The reason why I'm using the UI Automation library and not just AutoIt's out of box controls is because the application I'm trying to automate was created using both standard and non-standard windows controls.  Some were built in-house which is likely the reason for the difficulty I'm experiencing, but I believe there should be a way to do it because both the spy tool provided by @junkew and the Windows inspect.exe tool can both provide information about individual elements of the Grid, but I'm failing to find a coded solution.  I would appreciate help in the right direction.

 

NOTE: I changed the name of the element of interest as well as the Window since the application is not mine to dispense.

 

At this moment I'm trying to solve two problems:

  1. Perform some allowed UI Automation action on the element of a Grid with the specified text.
  2. Extract all the elements within the Grid for analysis.  Similar to the idea of a dump I guess.

The simplespy.exe application produces this code, which works to some degree.  It puts the Grid in focus which brings the previously clicked row into focus, but it does not select a desired element or row with the text specified.

;~ *** Standard code *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) Local $oP4=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=WindowTitle;controltype:=UIA_WindowControlTypeId;class:=ATL:4476F950", $treescope_children)   _UIA_Action($oP4,"setfocus") Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WTL_SplitterWindow", $treescope_children)   _UIA_Action($oP3,"setfocus") Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WTL_PaneContainer", $treescope_children)    _UIA_Action($oP2,"setfocus") Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_PaneControlTypeId;class:=#32770", $treescope_children)   _UIA_Action($oP1,"setfocus") Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=#32770", $treescope_children)   _UIA_Action($oP0,"setfocus") _UIA_setVar("SalesorderEntry.mainwindow","title:=RowOfInterestText;classname:=GRID") _UIA_action("SalesorderEntry.mainwindow","setfocus")

simplespy.exe also produced this information about the focused element:

Mouse position is retrieved 2177-480 At least we have an element [RowOfInterestText][GRID] Having the following values for all properties: Title is: <RowOfInterestText>   Class   := <GRID>   controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    2037;318;588;466 *** Parent Information top down *** 5: Title is: <Desktop>  Class   := <#32769> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    0;0;1920;1200 "Title:=Desktop;controltype:=UIA_PaneControlTypeId;class:=#32769"   4: Title is: <WindowTitle>  Class   := <ATL:4476F950>   controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    2020;250;1256;583 "Title:=WindowTitle;controltype:=UIA_WindowControlTypeId;class:=ATL:4476F950"   3: Title is: <> Class   := <WTL_SplitterWindow> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    2028;300;1240;502 "Title:=;controltype:=UIA_PaneControlTypeId;class:=WTL_SplitterWindow"  2: Title is: <> Class   := <WTL_PaneContainer>  controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    2028;300;1240;502 "Title:=;controltype:=UIA_PaneControlTypeId;class:=WTL_PaneContainer"   1: Title is: <> Class   := <#32770> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    2028;300;1240;502 "Title:=;controltype:=UIA_PaneControlTypeId;class:=#32770"  0: Title is: <> Class   := <#32770> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    2037;305;1224;479 "Title:=;controltype:=UIA_PaneControlTypeId;class:=#32770"
AutoIt         
*** Detailed properties of the highlighted element *** UIA_title:= <RowOfInterestText> UIA_text:= <RowOfInterestText> UIA_regexptitle:= <RowOfInterestText> UIA_class:= <GRID> UIA_regexpclass:= <GRID> UIA_iaccessiblechildId:= <0> UIA_id:= <249> UIA_handle:= <4526846> UIA_RuntimeId:= <42;4526846> UIA_BoundingRectangle:= <2037;318;588;466> UIA_ProcessId:= <6892> UIA_ControlType:= <50033> UIA_LocalizedControlType:= <pane> UIA_Name:= <RowOfInterestText> UIA_HasKeyboardFocus:= <True> UIA_IsKeyboardFocusable:= <True> UIA_IsEnabled:= <True> UIA_AutomationId:= <249> UIA_ClassName:= <GRID> UIA_Culture:= <0> UIA_IsControlElement:= <True> UIA_IsContentElement:= <True> UIA_IsPassword:= <False> UIA_NativeWindowHandle:= <4526846> UIA_IsOffscreen:= <False> UIA_Orientation:= <0> UIA_FrameworkId:= <Win32> UIA_IsRequiredForForm:= <False> UIA_IsDockPatternAvailable:= <False> UIA_IsExpandCollapsePatternAvailable:= <False> UIA_IsGridItemPatternAvailable:= <False> UIA_IsGridPatternAvailable:= <False> UIA_IsInvokePatternAvailable:= <False> UIA_IsMultipleViewPatternAvailable:= <False> UIA_IsRangeValuePatternAvailable:= <False> UIA_IsScrollPatternAvailable:= <False> UIA_IsScrollItemPatternAvailable:= <False> UIA_IsSelectionItemPatternAvailable:= <False> UIA_IsSelectionPatternAvailable:= <False> UIA_IsTablePatternAvailable:= <False> UIA_IsTableItemPatternAvailable:= <False> UIA_IsTextPatternAvailable:= <False> UIA_IsTogglePatternAvailable:= <False> UIA_IsTransformPatternAvailable:= <False> UIA_IsValuePatternAvailable:= <False> UIA_IsWindowPatternAvailable:= <False> UIA_ValueIsReadOnly:= <True> UIA_RangeValueValue:= <0> UIA_RangeValueIsReadOnly:= <True> UIA_RangeValueMinimum:= <0> UIA_RangeValueMaximum:= <0> UIA_RangeValueLargeChange:= <0> UIA_RangeValueSmallChange:= <0> UIA_ScrollHorizontalScrollPercent:= <0> UIA_ScrollHorizontalViewSize:= <100> UIA_ScrollVerticalScrollPercent:= <0> UIA_ScrollVerticalViewSize:= <100> UIA_ScrollHorizontallyScrollable:= <False> UIA_ScrollVerticallyScrollable:= <False> UIA_SelectionCanSelectMultiple:= <False> UIA_SelectionIsSelectionRequired:= <False> UIA_GridRowCount:= <0> UIA_GridColumnCount:= <0> UIA_GridItemRow:= <0> UIA_GridItemColumn:= <0> UIA_GridItemRowSpan:= <1> UIA_GridItemColumnSpan:= <1> UIA_DockDockPosition:= <5> UIA_ExpandCollapseExpandCollapseState:= <3> UIA_MultipleViewCurrentView:= <0> UIA_WindowCanMaximize:= <False> UIA_WindowCanMinimize:= <False> UIA_WindowWindowVisualState:= <0> UIA_WindowWindowInteractionState:= <0> UIA_WindowIsModal:= <False> UIA_WindowIsTopmost:= <False> UIA_SelectionItemIsSelected:= <False> UIA_TableRowOrColumnMajor:= <2> UIA_ToggleToggleState:= <2> UIA_TransformCanMove:= <False> UIA_TransformCanResize:= <False> UIA_TransformCanRotate:= <False> UIA_IsLegacyIAccessiblePatternAvailable:= <True> UIA_LegacyIAccessibleChildId:= <0> UIA_LegacyIAccessibleName:= <RowOfInterestText> UIA_LegacyIAccessibleRole:= <10> UIA_LegacyIAccessibleState:= <1048580> UIA_IsDataValidForForm:= <False> UIA_ProviderDescription:= <[pid:9208,hwnd:0x4512FE Main:Nested [pid:6892,hwnd:0x4512FE Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]> UIA_IsItemContainerPatternAvailable:= <False> UIA_IsVirtualizedItemPatternAvailable:= <False> UIA_IsSynchronizedInputPatternAvailable:= <False>

I experienced success as well with the Windows inspect.exe in identifying the text of the element of interest when I put focus on it:

AutoIt         
This is what inspect.exe shows: How found:  Mouse move (2161,483) hwnd=0x004512FE 32bit class="GRID" style=0x52810371 ex=0x4 RuntimeId:  "[42.4526846]" BoundingRectangle:  {l:2037 t:318 r:2625 b:784} ProcessId:  6892 ControlType:    UIA_PaneControlTypeId (0xC371) LocalizedControlType:   "pane" Name:   "RowOfInterestText" AccessKey:  "" HasKeyboardFocus:   true IsKeyboardFocusable:    true IsEnabled:  true AutomationId:   "249" ClassName:  "GRID" HelpText:   "" IsPassword: false NativeWindowHandle: 0x4512FE IsOffscreen:    false FrameworkId:    "Win32" ProviderDescription:    "[pid:6872,hwnd:0x4512FE Main:Nested [pid:6892,hwnd:0x4512FE Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]" LegacyIAccessible.ChildId:  0 LegacyIAccessible.DefaultAction:    "" LegacyIAccessible.Description:  "" LegacyIAccessible.Help: "" LegacyIAccessible.KeyboardShortcut: "" LegacyIAccessible.Name: "RowOfInterestText" LegacyIAccessible.Role: client (0xA) LegacyIAccessible.State:    focused,focusable (0x100004) LegacyIAccessible.Value:    "" IsDockPatternAvailable: false IsExpandCollapsePatternAvailable:   false IsGridItemPatternAvailable: false IsGridPatternAvailable: false IsInvokePatternAvailable:   false IsLegacyIAccessiblePatternAvailable:    true IsMultipleViewPatternAvailable: false IsRangeValuePatternAvailable:   false IsScrollPatternAvailable:   false IsScrollItemPatternAvailable:   false IsSelectionItemPatternAvailable:    false IsSelectionPatternAvailable:    false IsTablePatternAvailable:    false IsTableItemPatternAvailable:    false IsTextPatternAvailable: false IsTogglePatternAvailable:   false IsTransformPatternAvailable:    false IsValuePatternAvailable:    false IsWindowPatternAvailable:   false IsItemContainerPatternAvailable:    false IsVirtualizedItemPatternAvailable:  false IsSynchronizedInputPatternAvailable:    false FirstChild: [null] LastChild:  [null] Next:   "Menu" text Previous:   [null] Other Props:    Object has no additional properties Children:   Container has no children Ancestors:  "" dialog     "" dialog     "" pane     "" pane     "WindowTitle" window     "Desktop" pane     [ No Parent ]

Image Search not returning error...

$
0
0

Hey guys, so I'm pretty new to this, but I think I have the basic concepts down. I'm trying to use Image Search and it works perfectly, and finds the image and sets the mouse cursor there. However, whenever it cannot find the  the image, I does not return a value, but instead I get this error:

"C:\Program Files (x86)\AutoIt3\Include\ImageSearchUpdate.au3" (58) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $x=Int(Number($array[2])) $x=Int(Number(^ ERROR

It has something to do with the include file, so I dont know how to fix it... Here is the include file that I am using

AutoIt         
#include-once ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.0 ; Language:       English ; Description:    Functions that assist with Image Search ;                 Require that the ImageSearchDLL.dll be loadable ; ; ------------------------------------------------------------------------------ ;=============================================================================== ; ; Description:      Find the position of an image on the desktop ; Syntax:           _ImageSearchArea, _ImageSearch ; Parameter(s): ;                   $findImage - the image file location or HBitmap to locate on the ;                                   desktop or in the Specified HBitmap ;                   $tolerance - 0 for no tolerance (0-255). Needed when colors of ;                                image differ from desktop. e.g GIF ;                   $resultPosition - Set where the returned x,y location of the image is. ;                                     1 for centre of image, 0 for top left of image ;                   $x $y - Return the x and y location of the image ; ;                   $HBMP - optional hbitmap to search in. sending 0 will search the desktop. ; ; Return Value(s):  On Success - Returns 1 ;                   On Failure - Returns 0 ; ; Note: Use _ImageSearch to search the entire desktop, _ImageSearchArea to specify ;       a desktop region to search ; ;=============================================================================== Func _ImageSearch($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance, $HBMP=0)    return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance,$HBMP) EndFunc Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance,$HBMP=0)     ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)     If IsString($findImage) Then         if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage         If $HBMP = 0 Then             $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)         Else             $result = DllCall("ImageSearchDLL.dll","str","ImageSearchEx","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage,"ptr",$HBMP)         EndIf     Else         $result = DllCall("ImageSearchDLL.dll","str","ImageSearchExt","int",$x1,"int",$y1,"int",$right,"int",$bottom, "int",$tolerance, "ptr",$findImage,"ptr",$HBMP)     EndIf     ; If error exit     if $result="0" then return 0     ; Otherwise get the x,y location of the match and the size of the image to     ; compute the centre of search     $array = StringSplit($result[0],"|")    $x=Int(Number($array[2]))    $y=Int(Number($array[3]))    if $resultPosition=1 then       $x=$x + Int(Number($array[4])/2)       $y=$y + Int(Number($array[5])/2)    endif    return 1 EndFunc ;=============================================================================== ; ; Description:      Wait for a specified number of seconds for an image to appear ; ; Syntax:           _WaitForImageSearch, _WaitForImagesSearch ; Parameter(s): ;                   $waitSecs  - seconds to try and find the image ;                   $findImage - the image to locate on the desktop ;                   $tolerance - 0 for no tolerance (0-255). Needed when colors of ;                                image differ from desktop. e.g GIF ;                   $resultPosition - Set where the returned x,y location of the image is. ;                                     1 for centre of image, 0 for top left of image ;                   $x $y - Return the x and y location of the image ; ; Return Value(s):  On Success - Returns 1 ;                   On Failure - Returns 0 ; ; ;=============================================================================== Func _WaitForImageSearch($findImage,$waitSecs,$resultPosition,ByRef $x, ByRef $y,$tolerance,$HBMP=0)     $waitSecs = $waitSecs * 1000     $startTime=TimerInit()     While TimerDiff($startTime) < $waitSecs         sleep(100)         $result=_ImageSearch($findImage,$resultPosition,$x, $y,$tolerance,$HBMP)         if $result > 0 Then             return 1         EndIf     WEnd     return 0 EndFunc ;=============================================================================== ; ; Description:      Wait for a specified number of seconds for any of a set of ;                   images to appear ; ; Syntax:           _WaitForImagesSearch ; Parameter(s): ;                   $waitSecs  - seconds to try and find the image ;                   $findImage - the ARRAY of images to locate on the desktop ;                              - ARRAY[0] is set to the number of images to loop through ;                                ARRAY[1] is the first image ;                   $tolerance - 0 for no tolerance (0-255). Needed when colors of ;                                image differ from desktop. e.g GIF ;                   $resultPosition - Set where the returned x,y location of the image is. ;                                     1 for centre of image, 0 for top left of image ;                   $x $y - Return the x and y location of the image ; ; Return Value(s):  On Success - Returns the index of the successful find ;                   On Failure - Returns 0 ; ; ;=============================================================================== Func _WaitForImagesSearch($findImage,$waitSecs,$resultPosition,ByRef $x, ByRef $y,$tolerance,$HBMP=0)     $waitSecs = $waitSecs * 1000     $startTime=TimerInit()     While TimerDiff($startTime) < $waitSecs         for $i = 1 to $findImage[0]             sleep(100)             $result=_ImageSearch($findImage[$i],$resultPosition,$x, $y,$tolerance,$HBMP)             if $result > 0 Then                 return $i             EndIf         Next     WEnd     return 0 EndFunc

Is there anyway for Imagesearch to return a value if it cannot find the picture?
Thanks!
Rob

How to execut a *REG with admin right ?

$
0
0

i toook very lon gtime to make a script that working perfectly now...

 

but the only thing is when i am executing the code everything work but autoit does not execute a reg file same way than a cmd file look at this code :

AutoIt         
               Case $Num_PC                   Local $MyNum_PC = InputBox("Nump_PC", "Que voulez vous comme numéro de pc?"&@CRLF &"Pour Planitec 2.0")                   Local Const $NumPCPath = "C:\Num_PC.reg"                   _FileCreate ( $NumPCPath )                   Local $hFileOpen = FileOpen($NumPCPath, $FO_APPEND)                         If $hFileOpen = -1 Then                               MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")                         Return False                         EndIf                   FileOpen ($NumPCPath)                   FileWriteLine($hFileOpen, "Windows Registry Editor Version 5.00")                   FileWriteLine($hFileOpen, @CRLF)                   FileWriteLine($hFileOpen, "[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment]")                   FileWriteLine($hFileOpen,@CRLF)                   FileWriteLine($hFileOpen,'"NUM_PC"="999"')                      ShellExecute (@ScriptDir & "\NUM-PC.bat")                   FileClose ($NumPCPath)                   FileDelete ($NumPCPath)

ShellExecute (@ScriptDir & "\NUM-PC.bat") =

AutoIt         
:: BatchGotAdmin :------------------------------------- REM  --> Check for permissions >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" REM --> If error flag set, we do not have admin. if '%errorlevel%' NEQ '0' (     echo Requesting administrative privileges...     goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt     echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"     set params = %*:"=""     echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"     "%temp%\getadmin.vbs"     del "%temp%\getadmin.vbs"     exit /B :gotAdmin     pushd "%CD%"     CD /D "%~dp0" :-------------------------------------- C:\Num_PC.reg

The reg is not applied.

Array sorting, a clarification

$
0
0

Hi guys,

I have a multiple array with some information, like name, address, date etc.

 

For example for the birth date, this is the correct ( and fastest, the main thing ) approach?

AutoIt         
#include <Array.au3> Global $aTEMP[15][2] For $x = 1 To UBound($aTEMP, 1) - 1     $aTEMP[$x][1] = StringFormat("%02i", Random(1,31,1)) & "/" & StringFormat("%02i", Random(1,12,1)) & "/" & Random(1960,2015,1)     $aTEMP[$x][0] = $x Next _ArrayDisplay($aTEMP, "ORIGINAL") Local $iDay, $iMonth, $iYear For $x = 1 To UBound($aTEMP, 1) - 1     $iDay = StringLeft($aTEMP[$x][1], 2)     $iMonth = StringMid ($aTEMP[$x][1], 4, 2)     $iYear = StringRight($aTEMP[$x][1], 4)     $aTEMP[$x][1] = $iYear & $iMonth & $iDay Next _ArrayDisplay($aTEMP, "CONVERTED") _ArraySort($aTEMP, 0, 1, 0, 1) _ArrayDisplay($aTEMP, "SORTED") For $x = 1 To UBound($aTEMP, 1) - 1     $iDay = StringRight($aTEMP[$x][1], 2)     $iMonth = StringMid($aTEMP[$x][1], 5, 2)     $iYear = StringLeft($aTEMP[$x][1], 4)     $aTEMP[$x][1] = $iDay & "/" & $iMonth & "/" & $iYear Next _ArrayDisplay($aTEMP, "FINAL")

If yes, for "numbers" i can use always the same method. If not, please provide a better example so i can study it.

 

Second question. If i have a list of file path in a file, how i can sort it in a correct way? I don't think i need to apply directly ArraySort, and yes is always a 2D array like before [number,path] There is an example for 2D path sorting?

 

Thanks for any help

FileClose Issue

$
0
0
Plain Text         
               Case $Num_PC                   Local $MyNum_PC = InputBox("Nump_PC", "Que voulez vous comme numéro de pc?"&@CRLF &"Pour Planitec 2.0")                   Local Const $NumPCPath = "C:\windows\system32\Num_PC.reg"                   _FileCreate ( $NumPCPath )                   Local $hFileOpen = FileOpen($NumPCPath, $FO_APPEND)                         If $hFileOpen = -1 Then                               MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")                         Return False                         EndIf                   FileOpen ($NumPCPath)                   FileWriteLine($hFileOpen, "Windows Registry Editor Version 5.00")                   FileWriteLine($hFileOpen, @CRLF)                   FileWriteLine($hFileOpen, "[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment]")                   FileWriteLine($hFileOpen,@CRLF)                   FileWriteLine($hFileOpen,'"NUM_PC"="'&$MyNum_PC&'"')                   FileClose ($NumPCPath)                   NumpRunDeletion ()

i got this case in my switch

 

I think if i understand good.... the "Case" keep the file open even if i do FileClose ($NumPCPath) until the "Case" is not ended

 

so i cant run the NumpRunDeletion () function properly becose i got a file usef error this is the commandprompt error message

(i see the file in my system32 and yes he is used becose i cant delet it while the script is running  )

E:\>C:\Windows\System32\cmd.exe /k C:\WINDOWS\System32\reg.exe Import Num_Pc.reg ERROR: Error opening the file. There may be a disk or file system error.

missed to give you the fonction :

Func NumpRunDeletion ()    ShellExecute (@ScriptDir & "\NUM-PC.bat")    FileDelete ($NumPCPath) EndFunc

the strange thing is shellexecute does not work

filedelete work... hmmmmmmmmmmm

 

 

I add this : if i close my script and try again  NumpRunDeletion () it s working

Viewing all 12506 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>