Jump to content

I Cannot reach a text area and a button on the same page

Recommended Posts

Hello Everyone,

Hoping someone can help me,

I am totally stuck on this problem,

I cannot reach the textarea and the button in a maps page that I get by clicking on a button in a previus page, the only way I can interact with this is using tab and mouseclick but this is a danger method as  you know.

I get the handle by using: $Posizione = _IEAttach("Ricerca Indirizzo su mappa")

then I tried a lot of things but nothing works, can someone give me a hint?


WinWait("Ricerca Indirizzo su mappa")
$Posizione = _IEAttach("Ricerca Indirizzo su mappa")
WinSetState ("Ricerca Indirizzo su mappa", "", @SW_MAXIMIZE  )
WinActivate("Ricerca Indirizzo su mappa")
;~ $oForm = _IEFormGetObjByName($Posizione, "form1");Punta il Form
$oText = _IEFormElementGetObjByName($Posizione,"indirizzo")

$oText = _IEFormElementGetObjByName($Posizione,"writeAddress")

;~ $LenteTestoMess = _IEFormElementGetValue($oText);Inserisce il PrimoRepertorio nella variabile
;~ _IELinkClickByText($Posizione, $oForm);Clicca su Aggiorna ed invia il form

_IEFormElementSetValue ($oText,"via Ravenna 12" );Completamento campo testo


Mappa.odt Ricerca Indirizzo su mappa.htm

Link to post
Share on other sites

You need to use _IEGetObjById instead of _IEFormElementGetObjByName because AFAICS there isn't a true form involved. Try --

$oText = _IEGetObjById($Posizione, "writeAddress")
_IEFormElementSetValue ($oText,"via Ravenna 12" )

Not clear to me which button you are wanting to click, but the same technique should work. For example --

$oButton = _IEGetObjById($Posizione, "buttCerca")
_IEAction($oButton, "click")


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By philpw99
      Maps variable type has been be in beta for years, and only recently it became officially supported.
      I like the idea of object-oriented maps, and I like the features and simplicity it offers.
      However, in practice it's too easy to confuse with arrays and other object type, like dictionary. When run some tests, I also encounter the same errors listed here:
      After some thinking, I think we really do need to distinguish a map from an array. We cannot just use the same "[]" to reference different types of variables.
      So my propose is like this:
      To declare a map, you need to declare like this:
      local $map:[] ; or even simplier: local $map: ":" indicate that this is a map, not an array, and the difference is enough to be seen right away. You can define the number of elements inside.
      local $map:5 ; Not: local $map:[5] which means create a map with 5 as the first key ; Or $number = 5; local $map:$number means there are 5 empty elements already in the map.
      To set a map element, you just follow the same rule:
      $map:0 = "item 1" ; Set the first map element to be "item 1", with or without a key. $map:["key 1"] = "item with key" ; Set a map element with key "key 1" to "item with key", if this key doesn't exist, add a new item in the map. $map:"key 1" = "item with key" ; It's the same as above. $map:[0] = "itme with 0 as key" ; You can use 0 as the key. =====
      To reference a map element, you can either use a zero-based index, or a string as the key:
      $item = $map:0 ; It will return the first item in the map, with or without a key $item = $map:[0] ; It will return a item with key 0 $item = $map:["key 1"] ; It will return the item with key "key 1" $item = $map:"key 1" ; Same as above. ===== more about the number referencing: $number = 5 $item6 = $map:$number ; It will return the 6th item in the map (zero based) $item = $map:[$number] ; It will return the item with the key "5" =======================
      The reason we need to add ":" before the "[",  is to distinguish what we want to get. Do we want to get the map, or an array?
      Suppose there is a scenario like this:
      local $map[] ; declare a map local $array[5] ; declare an array $map[0] = $array $map[0][0] = 123 ; Error here. The above statement "$map[0][0]" created an confusion that's difficult to process. it can mean either:
      "Set $array[0] to 123 " or "Set $map[0] with key '0' with a new value 123"
      It will make the program hard to understand, and error prone.
      So if we adopt the new syntax, the purpose will become easy:
      $map:0:0 = 123 ; Set the first element $map, which is a map, to first element with value 123 $map:[0]:[0] = 123 ; Set the map element with key 0, which is a map, to element with key 0 to value 123 $map:0[0] = 123 ; Set the first element $map, which is an array, to first data be value 123 $map:[0][0] = 123 ; Set the element in $map with key 0, which is an array, to first data be value 123 $map[0][0] = 123 ; Set the 2D array $map's first data to be 123 $map[0]:0 = 123 ; Set the 1D array $map's first data, which is a map, its first element to be value 123, with or without a key. $map[0]:[0] = 123 ; Set the 1D array $map's first data, which is a map, its element with key 0 to be value 123. To reference map's elements by keys are also easy:
      $map:"Key 1":"Key 2" = 123 ; Referencing $map["key 1"]["key 2"] $map.key1:"Key 2" = 123; Reference a dictionary object $map's item("key 1"), to have a map with "key 2" value set to 123 $map:key1.key2 = 123 ; Referencing a map element with a key string, which value is key1.key2, and set this element to 123. $map:["key1"].key2 = 123 ; Referencing a map elment with key "key1", which is an object, and set its key2 property to 123. $map.key1.key2 = 123 ; Referencing an object map's property key1.key2, and set it to 123 $map:0:0 ; Referencing the first element in map, which is also a map, the first element  
      I think when doing like this, it will be much easier for Jon to program the maps variable, and we will have a much more precise way to reference and set map and array values.
      Please leave your comments for this proposal. Thank you !
    • By t0nZ
      I was searching for a way to highlight zones (regions, provinces, counties, etc) on a map, and I don't need  super precise maps so I wrote this script, based on picking up black and white maps (2 colors BW .png or .gif tested) and filling them with colors, writing down a sqlite database to associate zones with names (and other data as well), and reuse the map and the DB to display data, in my example reading a simple .txt file.
      It's all based on this thread  and this other thread.

      So I have two modes:
      The Map "creation mode" : you provide a map image and you start to pick up colors, set "upper level" region/state, and by clicking on a region you fill it and you name it, and all the data are saved on a sqlite DB (auto-created) when you have the map image and a DB with the correct associations, you can switch the "mode" to "show" (as by .ini file) and the script tries to read a "datafile" showing the zone names listed in datafile. The code:
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Icone\mapFlooder.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;MAP Flooder ;(C) NSC 2021 #include <GUIConstants.au3> #include <_GOLLOG.au3> #include <SQLite.au3> #include <SQLite.dll.au3> #include <Misc.au3> #include <GDIPlus.au3> Opt("mousecoordmode", 2) Global $prgname = "MAP Flooder", $ver = "V.0.7", $Buttoncolor = "0xFF00FF", $MPini = @ScriptDir & "\MapFlooder.ini", $btest Global $dbfullpath, $dbtable, $dbFields, $mapfile, $FloodMode, $datafile Global $HDC, $hBrush, $hGraphics, $obj_orig Global $Pic1, $gui, $width, $height, $bColor, $realtimeCoords, $lastclickcoords, $inputSup, $zonecountNum,$labeltest #Region program Gollog(">>>>>> Start MAP Flooder " & $ver) ctrlini() Gui() SQLiteDBcreate() If $FloodMode = "createdb" Then Gollog("CreateDB Mode") DBFlooder() Else Gollog("Show MAP mode") MapShow("show") EndIf Close() #EndRegion program #Region funcS Func Gui() _GDIPlus_Startup() $Pic1 = _GDIPlus_BitmapCreateFromFile($mapfile) $width = _GDIPlus_ImageGetWidth($Pic1) $height = _GDIPlus_ImageGetHeight($Pic1) If $FloodMode = "createdb" Then $gui = GUICreate($prgname & " " & $ver, $width + 150, $height) $labelLoadedMap = GUICtrlCreateLabel("Loaded Map", $width + 10, 5) $labelLoadedMap2 = GUICtrlCreateLabel(_FileToFileName($mapfile), $width + 10, 25) $labeldim = GUICtrlCreateLabel("Width*Height", $width + 10, 45) $labeldim2 = GUICtrlCreateLabel($width & " * " & $height, $width + 10, 65) $lastclickcoordslabel = GUICtrlCreateLabel("Last Click Coords", $width + 10, 100) $lastclickcoords = GUICtrlCreateLabel("xx - xx", $width + 10, 120, 180, 20) $realtimeCoordslabel = GUICtrlCreateLabel("Real Time Coords", $width + 10, 140) $realtimeCoords = GUICtrlCreateLabel("Real Time Coords", $width + 10, 160, 80, 20) $SuPzonelabel = GUICtrlCreateLabel("Supzone (region-state)", $width + 10, 200) $inputSup = GUICtrlCreateInput("sup", $width + 10, 220, 80, 20) $bColor = GUICtrlCreateButton($Buttoncolor, $width + 10, 250, 130, 30) GUICtrlSetBkColor($bColor, $Buttoncolor) $zonecountlabel = GUICtrlCreateLabel("Done Zone Count:", $width + 10, 320, 100, 20) $zonecountNum = GUICtrlCreateLabel("x", $width + 10, 340, 100, 20) $btest = GUICtrlCreateButton("TEST MAP", $width + 10, 380, 130, 30) $labeltest = GUICtrlCreateLabel("", $width + 10, 420, 130, 30) Else $gui = GUICreate($prgname & " " & $ver, $width, $height) EndIf GUISetState() $HDC = _WinAPI_GetDC($gui) $hGraphics = _GDIPlus_GraphicsCreateFromHDC($HDC) _GDIPlus_GraphicsDrawImageRect($hGraphics, $Pic1, 0, 0, $width, $height) EndFunc ;==>Gui Func MapShow($showmode) ; reading a simple text file with zone names, searching for names in DB and fill the map using stored coordinates If $showmode = "show" Then Local $aLines = FileReadToArray($datafile) Local $iLineCount = @extended EndIf If $showmode = "test" Then $iLineCount = 1 If @error Then MsgBox(48, "MapFlooder", "There was an error reading the data file. @error: " & @error) ; Gollog("There was an error reading the data file. @error: " & @error) Close() Else Gollog("start filling zones") _SQLite_Startup() _SQLite_Open($dbfullpath) ; open Database with zone definitions Local $hQuery, $aRow For $i = 0 To $iLineCount - 1 If $showmode = "show" Then _SQLite_Query(-1, "SELECT * FROM " & $dbtable & " where zone = '" & $aLines[$i] & "' ORDER BY zone ASC;", $hQuery) ; the query EndIf If $showmode = "test" Then _SQLite_Query(-1, "SELECT * FROM " & $dbtable & " ORDER BY zone ASC;", $hQuery) ; the query EndIf While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK $hBrush = DllCall("gdi32.dll", "long", "CreateSolidBrush", "int", $aRow[2]) ; fill color read from DB $obj_orig = DllCall("gdi32.dll", "int", "SelectObject", "int", $HDC, "int", $hBrush[0]) DllCall("gdi32.dll", "int", "FloodFill", "int", $HDC, "int", $aRow[3], "int", $aRow[4], "int", 0x000000) If $showmode = "test" Then GUICtrlSetData($labeltest,$aRow[0]) Sleep(200) GUISetState() EndIf WEnd _SQLite_QueryFinalize($hQuery) Next _SQLite_Close() _SQLite_Shutdown() EndIf While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>MapShow Func DBFlooder() $zonecount = 0 While 1 $mp = MouseGetPos() GUICtrlSetData($realtimeCoords, $mp[0] & " - " & $mp[1]) $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $bColor Then colorP() If $msg = $btest Then MapShow("Test") If $mp[0] < $width And $mp[1] < $height And _IsPressed("01") And WinActive($gui) Then $mp = MouseGetPos() GUICtrlSetData($lastclickcoords, $mp[0] & " - " & $mp[1]) $hBrush = DllCall("gdi32.dll", "long", "CreateSolidBrush", "int", $Buttoncolor) ; fill color ok $obj_orig = DllCall("gdi32.dll", "int", "SelectObject", "int", $HDC, "int", $hBrush[0]) DllCall("gdi32.dll", "int", "FloodFill", "int", $HDC, "int", $mp[0], "int", $mp[1], "int", 0x000000) Local $Zone = InputBox("Map Floode", "Zone ?") If $Zone = "" Or @error = 1 Then ; when manage wrong click, possibility to repeat ; set 'temp' color to highlight the 'wrong' click $hBrush = DllCall("gdi32.dll", "long", "CreateSolidBrush", "int", 0x4ccfc6) ; fill color wrong $obj_orig = DllCall("gdi32.dll", "int", "SelectObject", "int", $HDC, "int", $hBrush[0]) DllCall("gdi32.dll", "int", "FloodFill", "int", $HDC, "int", $mp[0], "int", $mp[1], "int", 0x000000) ; restore color $hBrush = DllCall("gdi32.dll", "long", "CreateSolidBrush", "int", $Buttoncolor) ; fill color ok $obj_orig = DllCall("gdi32.dll", "int", "SelectObject", "int", $HDC, "int", $hBrush[0]) Else _SQLite_Startup() _SQLite_Open($dbfullpath) ; open Database Local $SupZone = GUICtrlRead($inputSup) Local $data = '"' & $Zone & '","' & $SupZone & '","' & $Buttoncolor & '",' & $mp[0] & "," & $mp[1] _SQLite_Exec(-1, "INSERT INTO " & $dbtable & "(" & $dbFields & ") VALUES (" & $data & ");") If @error = -1 Then GOLLOG("Error insert record") MsgBox(48, "Error", "insert record") EndIf $zonecount += 1 GUICtrlSetData($zonecountNum, $zonecount) _SQLite_Close() _SQLite_Shutdown() EndIf EndIf WEnd EndFunc ;==>DBFlooder Func Close() Gollog("<<<<<<< closing...") _WinAPI_ReleaseDC($gui, $HDC) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() Exit EndFunc ;==>Close Func SQLiteDBcreate() ;complete path e filename If Not FileExists($dbfullpath) Then GOLLOG("perform SQLite DB creation") Local $dbfolder = _FileToFilePath($dbfullpath) ;Local $dbfile = _FileToFileName($dbfullpath) If Not FileExists($dbfolder) Then DirCreate($dbfolder) ; =====================>>>>> START SQL DLL _SQLite_Startup() _SQLite_Open($dbfullpath) ; open Database ; creating first table If _SQLite_Exec(-1, "CREATE TABLE " & $dbtable & " (" & $dbFields & ");") = $SQLITE_OK Then GOLLOG("DB table - " & $dbtable & " - creation ok") Else GOLLOG("Error creating DB table : " & @error) EndIf _SQLite_Close() _SQLite_Shutdown() Else Gollog("DB already exist") EndIf EndFunc ;==>SQLiteDBcreate ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FileToFilePath ; Description ...: Returns a folder path from a FQPN (Fully Qualified Path Name) ; Syntax ........: _FileToFilePath($sPath) ; Parameters ....: $sPath - a string value. ; Return values .: Success - String ; Failure - Empty string as returned from StringLeft() ; Author ........: Sam Coates ; =============================================================================================================================== Func _FileToFilePath($sPath) Local $sReturn = StringLeft($sPath, StringInStr($sPath, "\", 0, -1) - 1) Return ($sReturn) EndFunc ;==>_FileToFilePath ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FileToFileName ; Description ...: Returns a filename from a FQPN (Fully Qualified Path Name) ; Syntax ........: _FileToFileName($sPath[, $bIncludeExtension = True]) ; Parameters ....: $sPath - a string value. ; $bIncludeExtension - [optional] a boolean value. Default is True. ; Return values .: Success - String ; Failure - Empty string as returned from StringLeft() ; Author ........: Sam Coates ; =============================================================================================================================== Func _FileToFileName($sPath, $bIncludeExtension = True) Local $sReturn = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1)) If $bIncludeExtension = False Then $sReturn = StringLeft($sReturn, StringInStr($sReturn, ".", 0, -1) - 1) Return ($sReturn) EndFunc ;==>_FileToFileName Func colorP() ; modified for BGR color GOLLOG("Color Picker") Local $color = _ChooseColor(2) If $color = -1 Then GOLLOG("no color selected") Else Local $sCr = Hex($color, 6) Local $RGB_Buttoncolor = '0x' & StringMid($sCr, 1, 2) & StringMid($sCr, 3, 2) & StringMid($sCr, 5, 2) GUICtrlSetBkColor($bColor, $RGB_Buttoncolor) ; BGR color $Buttoncolor = '0x' & StringMid($sCr, 5, 2) & StringMid($sCr, 3, 2) & StringMid($sCr, 1, 2) GUICtrlSetData($bColor, $Buttoncolor) GOLLOG("new color " & $Buttoncolor & " selected") EndIf EndFunc ;==>colorP Func ctrlini() ;ini read If FileExists($MPini) Then GOLLOG("found: " & $MPini) $mapfile = IniRead($MPini, "map", "mapfile", "") $datafile = IniRead($MPini, "map", "datafile", "") $dbfullpath = IniRead($MPini, "db", "dbfullpath", "") $dbtable = IniRead($MPini, "db", "dbtable", "") $dbFields = IniRead($MPini, "db", "dbfields", "") $FloodMode = IniRead($MPini, "mode", "mode", "") Else GOLLOG($MPini & " NOT found..") Close() EndIf EndFunc ;==>ctrlini #EndRegion funcS All the needed files plus some example (image maps and DBs)
      Link to all demo files
      To test, copy all in a single folder and adjust the mapflooder.ini, also you can add to you includes the _gollog.au3 (used for log, you can avoid it deleting all Gollog() lines)
    • By Zobu
      Hey Guys,
      I want to add a new checkbox with its own variable every time the add button is clicked.
      The added checkboxes should remain when I close the window or exit the script and when I reopen I should be able to add new checkboxes aswell.
      here is what I have so far..
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> #include <GuiButton.au3> $test = GUICreate("adding test", 475, 345, 500, 175) $Check1 = GUICtrlCreateCheckbox("Checkbox 1", 15, 25, 300, 25) $Button = GUICtrlCreateButton("Add", 365, 25, 90, 20) $Check2 = GUICtrlCreateCheckbox("Checkbox 2", 15, 50, 300, 25) $Check3 = GUICtrlCreateCheckbox("Checkbox 3", 15, 75, 300, 25) GUICtrlSetState($Check2, $GUI_HIDE) GUICtrlSetState($Check3, $GUI_HIDE) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; Exit Case $Button GUICtrlSetPos($Check2, 15, 50, 300, 25) GUICtrlSetState($Check2, $GUI_SHOW) Case $Button GUICtrlSetPos($Check3, 15, 75, 300, 25) GUICtrlSetState($Check3, $GUI_SHOW) EndSwitch WEnd  
    • By GillesMaisonneuve
      Good morning,
      I am trying to align a two-line text in a button so that it would be centered in the button but can't succeed to do it for the vertical part.
      Can someone tell me what I do wrong ?
      Here is my code:
      $btn3 = GUICtrlCreateButton("Execute " & @LF & " file 1", 100, 65, 60, 50, _ BitOr($BS_CENTER,$BS_BOTTOM,$BS_MULTILINE)) and here is the resulting layout I get in my window.
      I tried to follow the help, made a lot of different parameter combinations (here it's `$BS_BOTTOM`, but I tried `$BS_VCENTER` and `$BS_TOP`), still get the same result : vertical alignement is a no go for me.
      Can someone help ?

    • By Pike
      Hey Everyone, I haven't been here in a while and recently picked up my old project. Still an FNG!
      To the point: I want to be able to push the button and either play an mp3, open a file, or open an exe program (all with the same button). The problem is that I don't know how to code for that at "case 1"
              Case 1                                                                                                                                             
                  Local $sRead = IniRead("config.ini", "Config", "One", "Default")                                
                  SoundPlay($sRead, @HotKeyPressed)                                                                     <-------------------------------
                  Run($sRead, @HotKeyPressed)                                                                                 <------------------------------- This 'Run' doesn't work even by itself!
      See code below for layout. If you need more information I will attach more code or answer any questions. Any help is greatly appreciated.
      Much Respect,
      Func _HandleButton() $iClickCount += 1 $iTimer = TimerInit() AdlibRegister("CheckButtonPress", $CheckTime) EndFunc Func CheckButtonPress() If TimerDiff($iTimer) < $CheckTime Or $iTimer = 0 Then Return Switch $iClickCount Case 1 Local $sRead = IniRead("config.ini", "Config", "One", "Default") SoundPlay($sRead, @HotKeyPressed) Run($sRead, @HotKeyPressed) Case 2 MsgBox(0, "INFORMATION:", "Choose the file you want designated to this button") Local $sFileOpenDialog = FileOpenDialog(0, @ScriptDir & "\", "All (*.*)", $FD_FILEMUSTEXIST + $FD_MULTISELECT) If @error Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") EndIf Local $sFileName = InputBox("INFORMATION:", "Please Name Your File?" & @CRLF _ & @CRLF _ & "6 Characters or Less", "") IniWrite(@ScriptDir & "\config.ini", "Config", "One", $sFileOpenDialog) IniWrite(@ScriptDir & "\config.ini", "Config", "NameOne", $sFileName) EndSwitch $iClickCount = 0 AdlibUnRegister() EndFunc  

  • Create New...