Jump to content

Can we create a single context menu on more than one control?


Recommended Posts

Hello my friends
Can we create a single context menu on more than one item?
For example, a context menu includes standardized options on more than one control, such as buttons or check boxes
to Create a context menu on one item am using this function
GUICtrlCreateContextMenu ($ HWND)
How to link it with more than one element please?
or if we can't do that, please give me a solution
so i tried to add an context menus to all the controls but the script will be long, for that if their are any solutions i hope to give it to me
thanks in advanced

Edited by nacerbaaziz
Link to post
Share on other sites
3 hours ago, nacerbaaziz said:

Can we create a single context menu on more than one item?

Yes

 

3 hours ago, nacerbaaziz said:

How to link it with more than one element please?

Possible

3 hours ago, nacerbaaziz said:

thanks

np, glad I could help

Link to post
Share on other sites
53 minutes ago, nacerbaaziz said:

can you help me to do that?

maybe

54 minutes ago, nacerbaaziz said:

please give me the solution

read help file

Link to post
Share on other sites

The UDF functions are much more powerful than the built-in functions. Look at _GUICtrlMenu_TrackPopupMenu (). Add a new post if you need more help.

Link to post
Share on other sites

This is a way to create the same context menu for multiple items. Essentially create the controls on an array, then loop through them and create the context for each one that way.

; right click on gui to bring up context Menu.
; right click on the "ok" button to bring up a controll specific context menu.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
GUICreate("My GUI Context Menu", 300, 200)
;=============================================================================
Global $Controls[3]
$Controls[0] = GUICtrlCreateButton('1', 10, 10, 50, 20)
$Controls[1] = GUICtrlCreateButton('2', 10, 40, 50, 20)
$Controls[2] = GUICtrlCreateButton('3', 10, 70, 50, 20)
;=============================================================================
GUISetState(@SW_SHOW)
;=============================================================================
For $c = 0 To UBound($Controls)-1
Local $idContextmenu = GUICtrlCreateContextMenu($Controls[$c])
Local $idNewsubmenu = GUICtrlCreateMenu("new", $idContextmenu)
Local $idNewsubmenuText = GUICtrlCreateMenuItem("text", $idNewsubmenu)
Local $idMenuInfo = GUICtrlCreateMenuItem("Info", $idContextmenu)
ConsoleWrite($Controls[$c] &@CRLF)
Next
;=============================================================================
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example

 

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to post
Share on other sites

hi brothers

please i tried this but i did not succeed

can you show me my error

note this is just a section from an big script

please help me to add the context menu into $label and $label0

 

global $label0 = GUICtrlCreateLabel(str("title"), 150, 90, 250, 20, $WS_TABSTOP)
GUICtrlSetResizing (-1, 1)
GUICtrlSetBkColor(-1, 0x461B7E)
GUICtrlSetFont(-1, 14, 400, 0, "Arial", 0)
GUICtrlSetOnEvent(-1, "order")

GUICtrlSetState(-1, $GUI_focus)
GUIStartGroup("")

Global $listFile2 = GUICtrlCreateIcon("", -1, 10, 130, 32, 32)
GUICtrlSetResizing (-1, 1)
GUICtrlSetOnEvent(-1, "order")
_Resource_SetToCtrlID(-1, 'files', $RT_ICON, Default, True)
GUICtrlSetBkColor(-1, 0x461B7E)
GUICtrlSetColor(-1, 0x461B7E)


Global $Label = GUICtrlCreateLabel(str("noopened"), 50, 130, 420, 40, $WS_TABSTOP +  $WS_GROUP, $WS_EX_ACCEPTFILES)
;GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetResizing (-1, 1)
GUICtrlSetBkColor(-1, 0x461B7E)
GUICtrlSetFont(-1, 11, 400, 0, "Arial", 0)
GUICtrlSetOnEvent(-1, "order")
GUICtrlSetCursor(-1, -1)
GUIStartGroup("")
Global $Label1 = GUICtrlCreateLabel("", 100, 180, 200, 60)
GUICtrlSetResizing (-1, 1)
GUICtrlSetState(-1, $GUI_disable + $GUI_NOFOCUS + $GUI_hide)
GUICtrlSetBkColor(-1, 0x461B7E)
GUICtrlSetFont(-1, 11, 400, 0, "Arial", 0)
Global $LabelMenu = GUICtrlCreateContextMenu($Label0)
GUICtrlSetOnEvent(-1, "order")
Global $LabelOpen = GUICtrlCreateMenuItem(str("opentofolder") & "... (control+f)", $LabelMenu)
GUICtrlSetOnEvent(-1, "order")
GUICtrlSetState(-1, $GUI_disable)
Global $Labelinfo = GUICtrlCreateMenuItem(str("fileInfo") & "...", $LabelMenu)
GUICtrlSetOnEvent(-1, "order")
GUICtrlSetState(-1, $GUI_disable)
Global $LabelCopyPath = GUICtrlCreateMenuItem(str("copyPath"), $LabelMenu)
GUICtrlSetOnEvent(-1, "order")
GUICtrlSetState(-1, $GUI_disable)
Global $labelCopy = GUICtrlCreateMenuItem(str("copy") & "... (control+shift+C)", $LabelMenu)
GUICtrlSetOnEvent(-1, "order")
GUICtrlSetState(-1, $GUI_disable)
Global $LabelPaste = GUICtrlCreateMenuItem(str("paste") & "... (control+v", $LabelMenu)
GUICtrlSetOnEvent(-1, "order")
Global $labelRemove = GUICtrlCreateMenuItem(str("PLRemove") & "... (del)", $LabelMenu)
GUICtrlSetOnEvent(-1, "order")
GUICtrlSetState(-1, $GUI_disable)
Global $labelDel = GUICtrlCreateMenuItem(str("delete") & "... (shift+del)", $LabelMenu)
GUICtrlSetOnEvent(-1, "order")
GUICtrlSetState(-1, $GUI_disable)
Global $LabelRename = GUICtrlCreateMenuItem(str("rename") & "... (shift+f2)", $LabelMenu)
GUICtrlSetOnEvent(-1, "order")
GUICtrlSetState(-1, $GUI_disable)
Global $LabelProperties = GUICtrlCreateMenuItem(str("Properties") & "... (alt+enter)", $LabelMenu)
GUICtrlSetOnEvent(-1, "order")
GUICtrlSetState(-1, $GUI_disable)
_GUICtrlMenu_TrackPopupMenu($LabelMenu, $label, -1, -1, 1, 1, 1, 0)

 

Link to post
Share on other sites

Could you post a reproducible script? One where i dont have to put all the necessary includes and so on?

Also, could you enclose your code with the <code> frame/tool? It's right next to the smiley face.

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to post
Share on other sites

hi the section that i put here is just for give you an Idea about what i want to do

i have created an big window whitch have multy GUICtrls such as buttons and labels and check boxes and more

and i have a context menu that have items, and i want to link this context menu with more then one control e.g 2 labels

i dont know the right way to do that, please help me by a simple example or gid me to do it.

am sorry about my bed english

Link to post
Share on other sites

Are you just ignoring my example? you know, the example right on top of your code.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to post
Share on other sites

dear @careca
 I never ignore your example.
but on this code just the items on the last Context menu can use it because the vars are the same
if you have an other suggestions please give it to me

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Example()

Func Example()
GUICreate("My GUI Context Menu", 300, 200)
Global $Controls[3]
$Controls[0] = GUICtrlCreateButton('1', 10, 10, 50, 20)
$Controls[1] = GUICtrlCreateButton('2', 10, 40, 50, 20)
$Controls[2] = GUICtrlCreateButton('3', 10, 70, 50, 20)

GUISetState(@SW_SHOW)

For $c = 0 To UBound($Controls)-1
Local $idContextmenu = GUICtrlCreateContextMenu($Controls[$c])
Local $idNewsubmenu =  GUICtrlCreateMenu("new", $idContextmenu)
Local $idNewsubmenuText = GUICtrlCreateMenuItem("text", $idNewsubmenu)
Local $idMenuInfo = GUICtrlCreateMenuItem("Info", $idContextmenu)
Next
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
case $idMenuInfo
msgBox(0, "", "")
EndSwitch
WEnd
GUIDelete()
EndFunc

 

Edited by nacerbaaziz
Tidied the code and AutoIt3 syntax for codebox
Link to post
Share on other sites
  • Developers

@nacerbaaziz, Please Tidy your code and use AutoIt3 in stead of plain text in the CodeBox when posting sourcecode. :)

Thanks Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
40 minutes ago, nacerbaaziz said:

...on this code just the items on the last Context menu can use it because the vars are the same

Can you clarify what you mean? Maybe i didn't understand it correctly, i got the idea that what you want to do is create the same context menu for many items.

This is what it does, puts a context menu in the 3 buttons.

I dont know what you want to do later on, but you can differentiate between the buttons.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to post
Share on other sites

here is a simple example

i want to show the same context menu when press right click on the all labels

please help me

local $hGUI, $HMenu, $ID_Open, $ID_save, $ID_cut, $ID_Label0, $ID_label
$hGUI = GUICreate("menu", 400, 400)
$label0 = GUICtrlCreateLabel("right click to get options", 100, 50, 200, 30)
$label = GUICtrlCreateLabel("right click to get the same options", 100, 110, 200, 30)

$hMenu = GUICtrlCreateContextMenu($label0)
$ID_Open = GUICtrlCreateMenuItem("&open", $hmenu)
$ID_save = GUICtrlCreateMenuItem("save the &file....", $hmenu)
$ID_cut = GUICtrlCreateMenuItem("move the &file....", $hmenu)
GUISetState(@sw_show, $hGUI)

while 1
switch GUIGetMSG()
case -3
exit
case $id_Open
_openFunc()
case $id_save
saveFunc()
case $id_Cut
moveFunc()

endSwitch
Wend
func OpenFunc()
;orders....
endFunc
func saveFunc()
;orders....
endFunc
func MoveFunc()
;orders....
endFunc

 

Link to post
Share on other sites
  • Developers
39 minutes ago, nacerbaaziz said:

here is a simple example

50%...  Correct color coding but totally unreadable as the script isn't tidied. You need to learn to properly format code to make it soooo much easier to read and understand!

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Developers

Use SciTE and it is easy....   I simply move on when I see unreadable code.   your choice though... ;)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

Hi nacerbaaziz,

Here is a way to do it. You can add as many controls ID's as you wish in " >>>>>> The 'OR' line <<<<<<"

$hGUI = GUICreate("Menu", 400, 300)
$id_Label_1 = GUICtrlCreateLabel("Right click to get options in menu", 100, 50, 165)
$id_Label_2 = GUICtrlCreateLabel("Right click to get the same options", 100, 110, 165)

$id_Label_hard_to_find = GUICtrlCreateLabel("", 1, 1, 1, 1)
$id_Context = GUICtrlCreateContextMenu($id_Label_hard_to_find)
$id_Open = GUICtrlCreateMenuItem("&Open", $id_Context)
$id_Save = GUICtrlCreateMenuItem("Save the &file....", $id_Context)
$id_Cut = GUICtrlCreateMenuItem("Move the &file....", $id_Context)
$hMenu = GUICtrlGetHandle($id_Context)

GUISetState()

While 1
    $aInfo = GUIGetCursorInfo()
    If Not @error And $aInfo[3] = 1 And _
      ($aInfo[4] = $id_Label_1 Or $aInfo[4] = $id_Label_2) Then ; >>>>>> The 'OR' line <<<<<<
        $mPos = MouseGetPos()
        DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, _
            "int", 0, "int", $mPos[0], "int", $mPos[1], "hwnd", $hGUI, "ptr", 0)
    EndIf

    Switch GUIGetMSG()
        Case -3
            Exit

        Case $id_Open
            OpenFunc()

        Case $id_Save
            SaveFunc()

        Case $id_Cut
            MoveFunc()
    EndSwitch
Wend

Func OpenFunc()
    Msgbox(0, "OpenFunc", "Here we are #1")
EndFunc

Func SaveFunc()
    Msgbox(0, "SaveFunc", "Here we are #2")
EndFunc

Func MoveFunc()
    Msgbox(0, "MoveFunc", "Here we are #3")
EndFunc

Good luck :)

Link to post
Share on other sites

@pixelsearch
thank you for your example

dear this way unfortunately   don't work with the screens readers, because Usually the screen readers have a virtual cursor.
and its work with the focus items only
i'am waiting for other solutions.
 please help me because am now making an audio player for the blinds users, for that i need to this option.
with my greetings

Edited by nacerbaaziz
Link to post
Share on other sites

careca, If you had tested your own code you would have seen that it does not work for buttons 1 and 2. You do not save ControlIds for the corresponding context menu items and are therefore unable to detect when the menu items are clicked.

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 DJ143
      I have a autoit exe file which is used in upload/browse file functionality.  This has been integrated with selenium framework and I am invoking the autoit exe using Java process and runtime. 
      Now the issue is when I run the scripts and invoke the autoit exe in local it works perfectly.  But when I use selenium grid or jenkins to run the scripts in another windows server it is not working.
      Can anyone please suggest any solution for this?
    • By Hermes
      Hello, the script below will read column A from an excel file - and if a value matches in the browser, it will click the corresponding link and click on a specific button to paste the data, then writes "Completed" in Column B. It will continue to read from the excel file and do the same thing for all the remaining rows.
      #Include "Chrome.au3" #Include "wd_core.au3" #Include "wd_helper.au3" #Include "WinHttp.au3" #include <MsgBoxConstants.au3> #include <File.au3> #include <IE.au3> #include <Array.au3> #include <INet.au3> #include <AutoItConstants.au3> #include <WinAPIFiles.au3> #include <GDIPlus.au3> #include <Excel.au3> #Include "WinHttp.au3" #Include "_HtmlTable2Array.au3" Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_LoadWait($sSession) _WD_Navigate($sSession, "table1.html") _WD_LoadWait($sSession) _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//table[@class='main']") Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//table[@class='main']") ;ConsoleWrite ("mat-table " & $sElement & @CRLF) Local $aArray1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//td[contains(@class,'data')]", $sElement, True) sleep(1000) For $i = 0 to UBound($aArray1) - 1 $aArray1[$i] = _WD_ElementAction($sSession, $aArray1[$i], 'text') Next ;_ArrayDisplay($aArray1) ;Email variables $SmtpServer = "" ; address for the smtp-server to use - REQUIRED $FromName = "Hermes" ; name from who the email was sent $FromAddress = "sender@gmail.com" ; address from where the mail should come $ToAddress = "recipient@gmail.com" ; destination address of the email - REQUIRED, use commas (,) to add more email addresses $Subject = "File not found" ; subject from the email - can be anything you want it to be $Body = "File not found!" ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed $CcAddress = "" ; address for cc - leave blank if not needed $BccAddress = "" ; address for bcc - leave blank if not needed $Importance = "High" ; Send message priority: "High", "Normal", "Low" $Username = "" ; username for the account used from where the mail gets sent - REQUIRED $Password = "" ; password for the account used from where the mail gets sent - REQUIRED $IPPort = 25 ; port used for sending the mail $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS $tls = 0 ; enables/disables TLS when required Local $oAppl = _Excel_Open() Local $sWorkbook = "c:\test.xlsx" Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook) ;open excel and pass both parameters If FileExists($sWorkbook) Then ;Check if the file exist. Local $oAppl = _Excel_Open() Local $sWorkbook = "c:\test.xlsx" Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook) ;open excel and pass both parameters Local $aArray2 = _Excel_RangeRead($oWorkbook,Default,$oWorkbook.ActiveSheet.Usedrange.Columns("A:A")) Local $iIdx Local $Skipline = 0 ;0==> first line Do Local $temprf For $i = 0 To UBound($aArray2) - 1 $temprf &= $aArray2[$i] _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, ".//a[contains(@class,'edit') and contains(text(),'Edit')]") Local $aElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//a[contains(@class,'edit') and contains(text(),'Edit')]", $sElement, True) $iIdx = _ArraySearch($aArray1, $aArray2[$i]) If @error Then ContinueLoop _WD_ElementAction($sSession, $aElement[$iIdx], 'click') If $i < $Skipline Then ContinueLoop $oRange = $oWorkbook.ActiveSheet.Range("B" & $i + 1 & ":XFD" & $i + 1) _Excel_RangeCopyPaste($oWorkbook.Activesheet, $oRange) ;Paste Local $oTest4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "pastebutton") _WD_ElementAction($sSession, $oTest4, 'click') Sleep(1000) ;Save Button Local $save3 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "button.button") _WD_ElementAction($sSession, $save3, 'click') _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "Completed", "B" & $i+1) sleep(1000) Next Until (Not @error) _Excel_Close($oWorkbook) Else _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl, $tls) Exit EndIf _WD_LoadWait($sSession) ;Attaching files to emails Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0, $tls = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 then $IPPort = 25 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf ; Set security params If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True If $tls Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendtls") = True ;Update settings $objEmail.Configuration.Fields.Update ; Set Email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update ; Sent the Message $objEmail.Send $objEmail="" EndFunc ;==>_INetSmtpMailCom Local $aDir = _FileListToArrayRec(@TempDir, "scoped_dir*;chrome_*", $FLTAR_FOLDERS, $FLTAR_NORECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) Sleep(2000) For $i = 1 To $aDir[0] DirRemove($aDir[$i], $DIR_REMOVE) Next _WD_LoadWait($sSession) _WD_Shutdown() Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}' EndFunc ;==>SetupChrome If the excel file doesn't exists in the folder, it will send an email to a specific recipient.
      What i am trying figure out now is if the excel crashes while the script/loop is running, I want to relaunch the excel file continue to the last row before the excel crashed. So if the value of column B is not marked as "completed", it should continue from that row
      Appreciate any help that I can get to achieve this.
      table1.html test.xlsx
    • By adityaparakh
      Hello ,
      I am trying to use Websockets in AutoIt.
      It is to fetch live stock market prices , API is provided and documentation available for python language.
      The link for the code snippet is :
      https://symphonyfintech.com/xts-market-data-front-end-api-v2/#tag/Introduction
      https://symphonyfintech.com/xts-market-data-front-end-api-v2/#tag/Instruments/paths/~1instruments~1subscription/post
       
      https://github.com/symphonyfintech/xts-pythonclient-api-sdk
       
      Second Link is to subscribe to a list of ExchangeInstruments.
      Now I would like to get live stock ltp (LastTradedPrice) for a few stocks whose "ExchangeInstrumentID" I know.
      I am able to use the WinHttp object to perform actions using simple codes like below :
      I have the secretKey and appkey and can generate the needed token. And get the unique ExchangeInstrumentID.

      Below code is just for example of how I am using WinHttp. Unrelated to socket part.
      Global $InteractiveAPItoken = IniRead(@ScriptDir & "\Config.ini", "token", "InteractiveAPItoken", "NA") $baseurl = "https://brokerlink.com/interactive/" $functionurl = "orders" $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", $baseurl & $functionurl, False) $oHTTP.SetRequestHeader("Content-Type", "application/json;charset=UTF-8") $oHTTP.SetRequestHeader("authorization", $InteractiveAPItoken) $pD = '{ "exchangeSegment": "NSEFO", "exchangeInstrumentID": ' & $exchangeInstrumentID & ', "productType": "' & $producttype & '", "orderType": "MARKET", "orderSide": "' & $orderside & '", "timeInForce": "DAY", "disclosedQuantity": 0, "orderQuantity": ' & $qty & ', "limitPrice": 0, "stopPrice": 0, "orderUniqueIdentifier": "' & $orderidentifier & '"}' $oHTTP.Send($pD) $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status
          
          
      But am struggling to understand and use socket.
      Would be of great help if you can have a look at the link mentioned above and help with the code sample for AutoIt.
      To connect and listen to a socket.
      Thanks a lot
       
    • By Hermes
      Hi, I have a site that has the following elements below: 
      <div>More element here</div> <div>More element here</div> <div>More element here</div> When I do this in Auto It:
      Local $oSelectDiv = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "div") _WD_HighlightElement($sSession, $oSelectDiv, 1) I also tried to add [3], but it doesnt seems to work:
      Local $oSelectDiv = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "div[3]") _WD_HighlightElement($sSession, $oSelectDiv, 1) It always highlight the first one, but I am trying to highlight the 3rd in the list. Is there anyway to select the 3rd div without having to add any class/id in the divs, and without using XPATH? The structure of the elements in that site were built that way.
    • By meety
      My au3 script program needs administrator privileges on win10 to be executed correctly, because it needs to be added to the boot---Script code:RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName, "REG_SZ", @ScriptFullPath)
      I need to let the program automatically get administrator privileges, so I use a function of #RequireAdmin. Although the program can be added to the boot, but does not execute after system boot up? why is that?
      What should I do?
      --------------------------------------------------------------------
      Update:
      I found that after using the #RequireAdmin function, the program cannot be executed after system boot up.
      An example is given below. after it is compiled, it will not be executed after system boot up in the following two ways.
      1. C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\
      2. RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName, "REG_SZ", @ScriptFullPath)
      why is that?
      example
      #include <MsgBoxConstants.au3>
      #RequireAdmin
      Func test()
          MsgBox(0, "", "this is test message")
      EndFunc   ;==>test
      test()
       
       
×
×
  • Create New...