Jump to content
Sign in to follow this  
Pagi

How to click this menu button? - (Moved)

Recommended Posts

 

<a href="index.php=4143b27b41db0a40c499202865c3e24d" class="menuitem " target="\_self"> "Menu Item 1" </a>

Can you tell me if it´s possible to click this menu button? If yes, how? Cause I have no idea, I think i should use _IETagNameGetCollection

Share this post


Link to post
Share on other sites

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
12 minutes ago, Pagi said:
$currenturl = _IEPropertyGet($oIE,"locationurl")
$oDivs = _IETagNameGetCollection($currenturl, "div")

 

Not sure why you are doing this, as you can't pass the URL as the first parameter of _IETagNameGetCollection. Try this instead --

$oDivs = _IETagNameGetCollection($oIE, "div")

However, I was suggesting to use _IELinkClickByText, like this --

_IELinkClickByText($oIE, "Menu Item 1")

This may not work given the fact that it is part of a menu.

Share this post


Link to post
Share on other sites
$oClasses = _IETagNameGetCollection($oIE, "class")
For $oClass in $oClasses
   If StringInStr($oClass.innertext, "Menu Item 1") Then
      _IEAction($oClass, "click")
   EndIf
Next

 

I tried to identify it by the class but it still doesn´t work. Any other idea? Or is there any mistake?

Danp, thanks for your reply, _IELinkClickByText does´nt work and also I don´t want to solve it like that. I just need to identify some element and then click on the menu button.

 

Share this post


Link to post
Share on other sites

But there is no div in HTML code..  Only tag <a> and class but problem with class is, that the same class has got more elements

Share this post


Link to post
Share on other sites

Ok... but you had previously shown code where you were searching by div, so this led me to believe that the link was contained within a div.

You've only shown us a single element, so it's not possible to guess the context that it resides in. Suggest that you shown us more of the surrounding HTML code. Also, it would be good to know if there are any events attached to these elements. If so, which ones?

Share this post


Link to post
Share on other sites

Have you tried accessing the div element and then the contained links? Something like this --

$oDiv = _IEGetObjById($oIE, "submenu2")
$oLinks = _IETagNameGetCollection($oDiv, "a")

For $oLink In $oLinks
   If StringInStr($oLink.innerText,"Menu Item 1") Then
      _IEAction($oLink, "click")
      ExitLoop
   EndIf
Next

 

Share this post


Link to post
Share on other sites

It´s working! But only on Main Button. I think the reason are apostrophes. I tried to include them in code but nothing...

Share this post


Link to post
Share on other sites

It´s not working on other buttons, only on button called "Main Button".  Look at the screenshot up and u will understand.

Share this post


Link to post
Share on other sites

You should show your code because the code I posted was intended to target "Menu Item 1". If you've changed the code so that it now works for "Main Button", then it helps if you include these details in your responses.

Also, since you posted a screenshot instead of the actual HTML code, it isn't possible for me to take a closer look at the HTML.

Share this post


Link to post
Share on other sites

Page is not uploaded yet so <a> href links will not work. Here is the offline file of the HTML. That´s just random links I put in

Pagi_blog.html

Edited by Pagi

Share this post


Link to post
Share on other sites
$oDiv = _IEGetObjById($oIE, "submenu2")
$oLinks = _IETagNameGetCollection($oDiv, "a")

For $oLink In $oLinks
   If StringInStr($oLink.innerText,"Menu Item 1") Then
      _IEAction($oLink, "click")
   EndIf
   ExitLoop
   Next
EndFunc

Doesn´t work. If I write in code "Main Button" to target Main Button like this,

$oDiv = _IEGetObjById($oIE, "submenu2")
$oLinks = _IETagNameGetCollection($oDiv, "a")

For $oLink In $oLinks
   If StringInStr($oLink.innerText,"Main Button") Then
      _IEAction($oLink, "click")
   EndIf
   ExitLoop
   Next
EndFunc

 

it works. But for menu items 1,2,3,4,5 not.

Share this post


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
Sign in to follow this  

  • Similar Content

    • By topgundcp
      Hi, 
      This is my very first post in this forum and am also new with Autoit programming so be easy on me.
      Below is the code that I am trying to get the index of the item selected. No problem getting the text.
      Case $listEdition   ; handle of the list             local $index=0             $item=GUICTRLRead($listEdition)    ; This will return the text in the list             ; ==============   The loop below always fails  ==================             ; Meaning _GUICtrlListView_GetItemSelected($listEdition, $i) always return FALSE. WHY ???????              For $i = 0 To $editionArray[0] - 1   ; The content of the list in an array where editionArray[0] contains total count of items                 If _GUICtrlListView_GetItemSelected($listEdition, $i) Then                     $index = $i                     exitloop                 EndIf              Next              ;===================================================             ConsoleWrite( "Select Edition:     " & $item & "  index: " & $index & @CR) ....... Please look at the comments in the code & the pix attached.
      _GUICtrlListView_GetItemSelected($listEdition, $i) always returns FALSE.
      Another problem is on the list. It also populate  the total count of items from the Array. How can I skip this item from populating to the list ?.
      Please advise and thanks

    • By Irios
      I have several context menus that's been built using _GUICtrlMenu_CreatePopup() and _GUICtrlMenu_AddMenuItem().
      When using _GUICtrlMenu_CreatePopup() it returns the identifier of the clicked item, sure. But it blocks the main loop while the menu is open.
      When using _GUICtrlMenu_CreatePopup($MNS_MODELESS) it returns immediately (of course), but I cannot figure out how/where to read the item that was clicked. Is there a Windows Message (WM) somewhere that is triggered? I've spend an entire day trying to figure out how to do this, but I'm not getting anywhere. My google fu is depleted (I must have tried like hundreds of script variations today), I'm about to smash my keyboard and just go to bed, and abandon the entire endeavor of making pretty menus and go back to using Koda and forget about using menu icons, colors,  etc.
      Anyone wanna help me out with how to read the clicked item? Before I smash my keyboard, please...
       
      Example script here:
       
      #include <GuiMenu.au3> #include <WinAPIError.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> GUIRegisterMsg($WM_CONTEXTMENU, "_WM_CONTEXTMENU") Global $idMenuItem = 10000, $counter = 0 Global $hGUI = GUICreate("Menu test", 400, 300) Global $hListview = GUICtrlCreateListView("", 2, 2, 396, 200) GUISetState(@SW_SHOW) ;~ Global $hMenuContext = _GUICtrlMenu_CreatePopup() Global $hMenuContext = _GUICtrlMenu_CreatePopup($MNS_MODELESS) _GUICtrlMenu_AddMenuItem($hMenuContext, "Menu item", $idMenuItem) Global $hTimer = TimerInit() Do If TimerDiff($hTimer)>200 Then $counter += 1 ConsoleWrite($counter & " " ) $hTimer = TimerInit() EndIf Until GUIGetMsg() = $GUI_EVENT_CLOSE Exit Func _WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Switch $wParam Case GUICtrlGetHandle($hListview) ConsoleWrite( @CRLF & "_GUICtrlMenu_TrackPopupMenu = " & _GUICtrlMenu_TrackPopupMenu($hMenuContext, $wParam, -1, -1, 1, 1, 2) & @CRLF) EndSwitch EndFunc  
       
    • By MarkIT
      Hi AutoIT masters,
      Good day! Sorry to have bothered this forum but we really need help. We are working on an automation project that is running on VDI server. The BOTS are in .exe are running fine until AV detected them and deleted the files. The files were re-compiled and AV kept on deleting them. The copy of the .exe BOT deleted were sent to Symantec for whitelisting. After whitelisting, it is no longer deleted but no longer working as designed (showing Line script error). We checked the scripts and there were no issues since we run it using SciTE editor and it performed the desired task. Good thing we found on this thread the solution using .a3x and the BOTS worked fine and no longer deleted. Now, the problem is they are asking why the BOTS won't run in .EXE and what is the reason behind Symantec AV deleting them. We raised a case with Symantec but they cannot provide further information as they are always seeing the file as "False Positive". We even tested with Symantec turned off and those .EXE files are working fine, however, after re-enabling, it got deleted.
      Just seeking help on how to better convince them that it is really Symantec causing the issue and the .a3x file.
    • By n0ktar
      is it possible to make a wall chams in rainbow six siege using autoit scripts? tell me please and how . 
    • By Rskm
      Hi, I am using excel as input media for my program. The excel file (i tried with .xls, .xlsx and .xlsm format) has inputs which the autoit script reads during the run and performs few calculations. Some times (not always), after the run, when i try to open the excel file manually, the file doesnt open at all in excel. see the screenshot attached. However, if the execute the autoit script, the scripts still reads the existing data from that excel and performs the calcs. I copied the excel file to another computer and there too, it doesnt open.  So, after this, i cannot edit the excel forever (if i need to change any inputs). It is only this particular file that got affected. other excel files works normal.  What could be the problem here.  please help as this is a new challenge for me during my program development. 

×
×
  • Create New...