Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/24/2020 in all areas

  1. It's not that hard. Here is an example with the context menu in Notepad. Run the code in SciTE with F5. Only tested in Windows 7. Should also work in Windows 10. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include <Misc.au3> #include <GuiMenu.au3> #include <WindowsConstants.au3> Example() Func Example() ; Open Notepad Run( "notepad.exe" ) WinWait( "[CLASS:Notepad]" ) ; Open context menu Send( "{APPSKEY}" ) WinWait( "[CLASS:#32768]" ) ; Get menu handle Local $hMenu = GetMenuHandle() If Not $hMenu Then Return ConsoleWrite( "$hMenu ERR" & @CRLF ) ConsoleWrite( "$hMenu OK" & @CRLF ) ; Add new menu item Local $iItem = _GUICtrlMenu_AddMenuItem( $hMenu, "My new menu item" ) If Not $iItem Then Return ConsoleWrite( "$iItem ERR" & @CRLF ) ConsoleWrite( "$iItem OK" & @CRLF ) ; Show all menu items Local $iCount = _GUICtrlMenu_GetItemCount( $hMenu ), $sText For $i = 0 To $iCount - 1 $sText = _GUICtrlMenu_GetItemText( $hMenu, $i ) If $sText <> "" Then ConsoleWrite( "$sText = " & $sText & @CRLF ) ConsoleWrite( "$iIndex = " & $i & @CRLF ) EndIf Next ; Detect menu item click While Sleep(10) And Not _IsPressed( "01", "user32.dll" ) WEnd $iItem = _GUICtrlMenu_MenuItemFromPointEx( 0, $hMenu ) ; Works in both 32 and 64 bit code ConsoleWrite( "Clicked item = " & $iItem & @CRLF ) If $iItem <> $iCount - 1 Then Return ConsoleWrite( "My new menu item NOT clicked" & @CRLF ) ConsoleWrite( "My new menu item clicked" & @CRLF ) EndFunc Func GetMenuHandle() Local $hDesktop = _WinAPI_GetDesktopWindow(), $i = 0 Local $hChild = _WinAPI_GetWindow( $hDesktop, $GW_CHILD ) While $hChild And $i < 50 If _WinAPI_GetClassName( $hChild ) = "#32768" Then ExitLoop $hChild = _WinAPI_GetWindow( $hChild, $GW_HWNDNEXT ) $i += 1 WEnd If $i = 50 Then Return 0 Local $hMenu = _SendMessage( $hChild, $MN_GETHMENU ) If $hMenu > 0 Then Return $hMenu Return 0 EndFunc Func _GUICtrlMenu_MenuItemFromPointEx( $hWnd, $hMenu, $iX = -1, $iY = -1 ) If $iX = -1 Then $iX = _WinAPI_GetMousePosX() If $iY = -1 Then $iY = _WinAPI_GetMousePosY() Local $tPOINT = DllStructCreate( "long;long" ) DllStructSetData( $tPOINT, 1, $iX ) DllStructSetData( $tPOINT, 2, $iY ) Local $tPOINT64 = DllStructCreate( "int64", DllStructGetPtr( $tPOINT ) ) Local $aResult = DllCall("user32.dll", "int", "MenuItemFromPoint", "hwnd", $hWnd, "handle", $hMenu, "int64", DllStructGetData( $tPOINT64, 1 ) ) If @error Then Return SetError(@error, @extended, -1) Return $aResult[0] EndFunc SciTE output: $hMenu OK $iItem OK $sText = &Undo $iIndex = 0 $sText = Cu&t $iIndex = 2 $sText = &Copy $iIndex = 3 $sText = &Paste $iIndex = 4 $sText = &Delete $iIndex = 5 $sText = Select &All $iIndex = 7 $sText = &Right to left Reading order $iIndex = 9 $sText = &Show Unicode control characters $iIndex = 10 $sText = &Insert Unicode control character $iIndex = 11 $sText = &Open IME $iIndex = 13 $sText = &Reconversion $iIndex = 14 $sText = My new menu item ; <<<<<<<< $iIndex = 15 Clicked item = 15 My new menu item clicked ; <<<<<<<< Once the new menu item is clicked, you can either execute a menu function directly, or you can open your own context menu with several items and possibly submenus. Both with straightforward AutoIt code.
    2 points
  2. JockoDundee, Yes, many of the MsgBox styles are based on powers of 2. I always try to set the parameter styles in my UDFs in this way - this is from GUIListViewEx: ; $iAdded - 0 - No added features (default). To get added features add any of the following values ; + 1 - Sortable by clicking on column headers ; + 2 - Do not "select all" when editing item text ; + 4 - Continue edit within same ListView by triple mouse-click on editable column ; + 8 - Headers editable by Ctrl-click (only if column editable) ; + 16 - User coloured header ; + 32 - User coloured items ; + 64 - No external drag ; + 128 - No external drop ; + 256 - No delete on external drag/drop ; + 512 - No internal or external drag/drop ; + 1024 - Single cell highlight (forces single row selection) But I would still recommend using BitOr in all cases, just to be on the safe side. As a further complication some of the styles values occasionally overlap - for example some ListView $LVS_EX_* styles have the same numerical value as standard $WS_EX_* styles. So applying extended styles to a ListView should always be done using the _GUICtrlListView_SetExtendedListViewStyle function and not added to the ListView creation line as they will always be interpreted as the $WS_EX_* parameter in that case and you will not get the result you expect. Nothing to do with Autoit - blame MS! M23
    2 points
  3. Hello everyone, I started this project alone in May 2020 as project in my spare time at work, I'm working for a IT company that started opening their services to residential customers few months ago and now my position in the company kind of drifted in the doom and gloom world of repetitive tasks like: Reinstallation + Configuration of Windows 10. The procedure is very repetitive and I started feeling like being a robot which is the main reason I started this project. ==============================FAQ================================== 1. Q: Do you want this project to be accomplished with the usage of AutoIt ONLY or 3rd party tools / Scripts (BATCH / POWERSHELL / VB) ? A: No, if I cannot find a way using AutoIt to accomplish a task I will move to my Plan B which consist of automating an 3rd party tool to accomplish the affected task until a solution is found. 2. Q: What do I get from helping/collaborating in this project? A: I will personally take the responsibility to mention you in the credits of this project. 3. Q: If I have more questions, can I ask? A: Certainly! feel free to ask any questions related to this project! 4. Q: What is the main goal of this project? A: Automating Windows 10 configuration without user interaction needed (as much as possible) ______________________________________________________________________________________________________________________________ Current progression of the project (more will be added in future) « Blue = Info || Yellow = Unfinished/Untested || Purple = Could be better || Green = Done ||Red = Not Yet Started » ***Very early Stage *** Connect Network Attached Storage(NAS) (Work but missing configuration in GUI - AutoIt only) Download & Install up to 600+ softwares (Tested & Working - using 3rd party tool + 50/50 Powershell/AutoIt) Auto prediction of Apps name of text typed inside input (Tested & Working - AutoIt Only) Change OEM Informations (Tested & Working - AutoIt) Disable hibernation (Tested & Working - AutoIt only) Change Computer Name (Work but require testing - AutoIt only) Show Computer Information and Smart status on GUI (Tested & Working - AutoIt Only) Change .pdf / .pdfxml from Edge to Adobe Reader DC (Tested & Working - using 3rd party tool) Change Edge to Google Chrome as Default Browser (Tested & Working - using 3rd party tool) Windows Updater (Seems to work but require further testing - AutoIt only) Install Office 365 / 2013 + Activation (To Do) Add L2TP VPN Configuration for Windows Built-in VPN (To Do) Save / Load tasks configuration profile in (.ini file) to avoid repeating same configuration twice (In progress - AutoIt Only) (EXPERIMENTAL) Install Apps from Microsoft Store with UIAutomation UDF made by @junkew(Work if you know what your doing) P.S: Installing Apps from Microsoft Store will require usage of UIA spy tool made by @LarsJ which you can download & learn how to use it on UIA Spy Tool thread. *** If this project interest you, Reply here This will greatly help me to see if you'd like this project to become real *** ______________________________________________________________________________________________________________________________ Best Regards, ~WilliamasKumeliukas
    1 point
  4. jguinch

    Printers Management UDF

    Sorry, @mLipok I didn't take enough time to correct all. I just downloaded your corrected version (and also added corrections) + updated/corrected the example code.
    1 point
  5. Depending on the OS this maybe needs to be adapted but a simple way to add an entry to the Windows context menu is to add a registry key key : HKEY_CLASSES_ROOT\*\shell\my_script\command REG_SZ value : C:\my_script.exe "%1" and to use $CmdLine[1] in your script 'my_script.exe'
    1 point
  6. Your script is crashing in x64 mode. Your issue is here -- _Timer_KillTimer($GUI_HWNDPARENT, $Starting_Screen_Timer) From the help file -- Commenting out this line and your script runs fine for me.
    1 point
  7. here you are, waiting for your results
    1 point
  8. fwiw, one thing Autoit could use is fork() :)
    1 point
  9. GMK

    Read PDFs

    $App = ObjCreate("AcroExch.App") ;; start Adobe Acrobat $App.Show ;; show Acrobat or comment out for hidden mode ;; actions $AVDoc = ObjCreate("AcroExch.AVDoc") ;; connect to Ac Viewer If $AVDoc.Open($FilePath,"") Then ;; open the file $PDDoc = $AVDoc.GetPDDoc ;; get PdDoc from AvDoc $JSO = $PDDoc.GetJSObject ;; get JS Object from PDDoc $test = $oJSO.GetField($fieldname).Value ;; get field value msgbox(0,"",$test) ;~ $PDDoc.save(1,$fileOut) ;~ $app.closeAlldocs() $app.exit() Else msgbox(0,"","Coudn't open report") endif ;; release objects $JSO = 0 $PdDoc = 0 $AvDoc = 0 $App = 0
    1 point
  10. Thank you for the update! I wait, test and seek high speed data transfer function!
    1 point
  11. You may have a look at : https://www.autoitscript.com/wiki/Setting_Styles#Multiple_Styles
    1 point
  12. Nine

    Excel read filtered only

    Here the approach I would use. Instead of creating a single 2D array containing all the values of all the areas, I suggest you store the range object into the first column of an array, and the second column would contain its corresponding matrix. That way you can have different size of area. You can modify each matrix individually and rewrite them into the excel sheet easily by using its range object. #include <Excel.au3> $oExcel = _Excel_Open() $oWorkBook = _Excel_BookAttach("65000.xls","FileName") $oRange = $oWorkbook.ActiveSheet.range("A1:B5;C10:E15;D20:G30") $oRange.select Local $aResult[$oRange.Areas.count][2], $i = 0 For $oArea In $oRange.Areas ConsoleWrite ("Area " & $i & " = " & $oArea.rows.count & "/" & $oArea.columns.count & @CRLF) $aResult[$i][0] = $oArea $aResult[$i][1] = _Excel_RangeRead($oWorkbook, Default, $oArea) _ArrayDisplay($aResult[$i][1]) $i += 1 Next ; Make some modifications to the areas ; Example : Double the values of first column Local $aTmp For $i = 0 to UBound($aResult)-1 $aTmp = $aResult[$i][1] For $j = 0 to UBound($aTmp)-1 $aTmp[$j][0] *= 2 Next _Excel_RangeWrite($oWorkBook, Default, $aTmp, $aResult[$i][0]) Next
    1 point
  13. water

    Excel read filtered only

    A member of the Areas collection is a Range object. You could use the Address property to retrieve the address of the upper left cell in this Range and then the .Columns.Count and .Rows.Count properties for the Area to retrieve the number of columns and rows to calculate the other addresses.
    1 point
  14. I personally use this (found somewhere on this forum) While Singleton doesn't allow a 2nd instance, this one allows the new one and kills the previous ones Func _killOriginal($winTitle) Local $processID = WinGetProcess($winTitle) While WinExists($winTitle) WinClose($winTitle) Sleep(10) ; allow window to exit ProcessClose($processID) Sleep(10) ; allow process to exit WEnd EndFunc ;==>_killOriginal
    1 point
  15. Here is a complete example of combining Autoit with PHP and MySQL was written by me. Include: Sign in, sign out.Create, read, update and delete data between client (AutoIt) and server (PHP/MySQL).Only allow user to log into a client at the same time. Video demo: https://www.youtube.com/watch?v=gQyfXLO0pls Screenshot (Main GUI) Usage If you want to test on your computer, you will need to create a localhost. I recommend to use WAMP or XAMPP. First, create a new database by importing from SETUP.sql file (see video for more info). Then, edit your path to SERVER in AutoIt-PHP-MySQL.au3: Global Const $SERVER = 'http://localhost/AutoIt/index.php?act='Make sure you have copied all files in the folder "PHP + MySQL" into a folder named AutoIt in your Localhost (www or htdocs directory). Yeah, now you can open the file "AutoIt-PHP-MySQL.au3" and try it yourself! Default username and password is: admin Download: Tutorial-AutoIt-PHP-MySQL-v1.0.rar[Tutorial] AutoIt - PHP - MySQL v2.0.zip (Thank @JohnOne for having suggested using zip format)Changelog ----- Hope you enjoyed it!
    1 point
  16. Wow, thanks Melba, I really like your Autoit Programming style, always top-notch clean... and helpful! Which is great for the community. Keep it goin' eh!! hench
    1 point
  17. BlockIt Utility is designed to block Files and Folders. (Main idea for this utility by rasim) Screenshot: Changelog: Download: BlockIt_Beta.zip (Counter: )
    0 points
×
×
  • Create New...