Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/17/2022 in all areas

  1. Hi everyone, I'm new. English is not my native language. I'm learning to use AutoIt, for fun and to automate things that are usually very specific to my environment. But I don't think the forum is for introductions. So I'll keep it short. I had been using a crappy version of this script, but I thought someone might find it useful and reworked it a bit. This is a password generator, and has a simple database record for the options used only. The generated password is never stored anywhere. The operation is very simple: - It generates the Password and puts it in the clipboard. - It has a very simple database to store the options used to generate the password. ----------------- The password is generated by the lesspass-cli executable, which I have conveniently added. If you don't want to use the executable that I have added or for some reason it doesn't work, you have to install python and run the command: python3 -m pip install --user lesspass That should do it, but if it doesn't work, you will have to find the path to the lesspass executable, add it to the windows $PATH, or copy the executable to the script folder. ----------------- The passwords generated with this script are the same as those generated by the web page or browser extensions. The script works, at least on my computer running windows 7. It should work on any windows. You can just use the website: https://www.lesspass.com/ or install the browser extension for chrome or firefox . But where is the fun in that? For me the script is faster to access, more comfortable. It probably has a lot of bugs that I haven't discovered yet, so apologies in advance. ---- edit1: forgot to change the chrome class because i use a sandbox. lesspass_au3.zip
    2 points
  2. There is a pretty good example in that thread : It will give you the process. If the window is required, then you will need to look for it based on the PID, but I believe process should be enough.
    1 point
  3. You could use an array to dynamically change the number of checkboxes for example: #include <GUIConstantsEx.au3> Global $aCheckBox[][2] = [["", "Dance / Electro Pop"],["", "Bass House"],["", "Funky House"],["", "Mainstage | Big Room"],["", "Disco Polo Dance"],["", "Trance"],["", "Hardstyle"],["", "Nu Disco"]] Global $iHeight = 10 + ((UBound($aCheckBox) - 1) * 25) + 55 Global $iY = 10 Global $Form1 = GUICreate("Form1", 800, $iHeight, 192, 124) For $i = 0 To UBound($aCheckBox) - 1 $aCheckBox[$i][0] = GUICtrlCreateCheckbox($aCheckBox[$i][1],10,$iY,150,20,-1,-1) $iY += 25 Next Global $idCheck = GUICtrlCreateButton("Check", 10, $iY, 100, 25) Global $idUncheck = GUICtrlCreateButton("Uncheck", 115, $iY, 100, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idCheck _CheckBox(1) Case $idUncheck _CheckBox(4) EndSwitch WEnd Func _CheckBox($iFlag = 1) For $i = 0 To UBound($aCheckBox) - 1 GUICtrlSetState($aCheckBox[$i][0], $iFlag) Next EndFunc Another method is to use GuiCtrlCreateDummy for example: #include <GUIConstantsEx.au3> Global $Form1 = GUICreate("Form1", 800, 408, 192, 124) Global $iCheckStart = GUICtrlCreateDummy() Global $check1 = GUICtrlCreateCheckbox("Dance / Electro Pop",281,135,150,20,-1,-1) Global $check2 = GUICtrlCreateCheckbox("Bass House",567,216,103,20,-1,-1) Global $check3 = GUICtrlCreateCheckbox("Funky House",445,216,97,20,-1,-1) Global $check4 = GUICtrlCreateCheckbox("Mainstage | Big Room",281,162,150,20,-1,-1) Global $check5 = GUICtrlCreateCheckbox("Disco Polo Dance",281,188,112,20,-1,-1) Global $check6 = GUICtrlCreateCheckbox("Trance",281,216,112,20,-1,-1) Global $check7 = GUICtrlCreateCheckbox("Hardstyle",445,135,112,20,-1,-1) Global $check8 = GUICtrlCreateCheckbox("Nu Disco",445,162,112,20,-1,-1) Global $iCheckEnd = GUICtrlCreateDummy() Global $idCheck = GUICtrlCreateButton("Check", 10, 10, 100, 25) Global $idUncheck = GUICtrlCreateButton("Uncheck", 115, 10, 100, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idCheck _CheckBox(1) Case $idUncheck _CheckBox(4) EndSwitch WEnd Func _CheckBox($iFlag = 1) For $idCheckBox = $iCheckStart To $iCheckEnd GUICtrlSetState($idCheckBox, $iFlag) Next EndFunc
    1 point
  4. I'm not sure if this solves your problem, but ClipPut("") clears the contents of the clipboard. You may also try this code (it's a bit older ) ; There has to be some data in the clipboard for this example : Local $sData $sData = ClipGet() MsgBox(0, "Display data from ClipGet:", $sData) _ClipEmpty() $sData = ClipGet() MsgBox(0, "Display data after _ClipEmpty():", $sData) Func _ClipEmpty() Local $Success = 0 DllCall('user32.dll', 'int', 'OpenClipboard', 'hwnd', 0) IF @error = 0 THEN DllCall('user32.dll', 'int', 'EmptyClipboard') IF @error = 0 THEN $Success = 1 DllCall('user32.dll', 'int', 'CloseClipboard') IF $Success THEN Return 1 ENDIF DllCall('user32.dll', 'int', 'CloseClipboard') Return 0 EndFunc Possibly it also benefits to have a look at the current help regarding : _ClipBoard_Empty
    1 point
  5. An example of updating an excel file with a join between excel range and access tables. #include <Excel.au3> #include <Array.au3> #include <MsgBoxConstants.au3> ;#include <WinAPIFiles.au3> ;Permitir unha única instancia da aplicación #include <Misc.au3> ;_Singleton("ADO_Update_Excel_From_Access", 0) If _Singleton("ADO_Update_Excel_From_Access", 1) = 0 Then MsgBox($MB_SYSTEMMODAL, "Warning", "An occurrence of test is already running") Exit EndIf Opt("MustDeclareVars", 1) Opt("TrayIconDebug", 1) OnAutoItExitRegister("OnAutoItExit") #===== CONFIG ===== Global $sFilePath = @ScriptDir & "\test.xlsx" Global $sFilePath2 = @ScriptDir & "\test.mdb" Global $testmdb = "[;Database=" & $sFilePath2 & ";PWD=123]" ;~ Global $excel = "[Excel 12.0 Xml;HDR=NO;IMEX=1;DATABASE=" & $sFilePath& "]" ;Global $testsqlserver = "[odbc;Driver={SQL Server};SERVER=10.0.0.99;DATABASE=MyDatabaseName;UID=MyUser;PWD=MyPassword]" #===== ADODB ===== Global $cn, $rst, $sSQL, $SubSQL ;Help: COM Error Handling ;_ErrADODB From spudw2k ;https://www.autoitscript.com/forum/topic/105875-adodb-example/ Global $errADODB = ObjEvent("AutoIt.Error","_ErrADODB") Global Const $iCursorType = 3 ;0 adOpenForwardOnly, 3 adOpenStatic Global Const $iLockType = 3 ;1 adLockReadOnly, 3 adLockOptimistic Global Const $iOptions = 1 ; Options, 1 Evaluates as a textual definition of a command or stored procedure call ; 2 adCmdTable $cn = ObjCreate("ADODB.Connection") ; Create a connection object $rst = ObjCreate("ADODB.Recordset") ; Create a recordset object ;Global $sADOConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & $sFilePath2 & ";Jet OLEDB:Database Password=123" ;Global $sADOConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $sFilePath2 & ";Jet OLEDB:Database Password=123" ;Global $sADOConnectionString = 'Driver={Microsoft Access Driver (*.mdb)};Dbq=' & $sFilePath2 & ';uid=;pwd=MyPassword;' ;~ ;Global $sADOConnectionString = 'Provider=SQLOLEDB;Data Source=10.0.0.99;Initial Catalog=MyDatabaseName;User Id=MyUser;Password=MyPassword;' ;~ ;Or if you’re using native client: ;~ ;stConnect = "Provider=SQLNCLI10;Data Source=... ;http://www.connectionstrings.com/ ;Xlsx files: Excel 2007 (and later) files with the Xlsx file extension ;[Also valid for] Using the Office 2007 OLEDB driver (ACE 12.0) to connect to older 97-2003 Excel workbooks ;cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & RutaXls & ";Extended Properties=Excel 12.0 Xml;" Global $sADOConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & $sFilePath & ";Extended Properties=""Excel 12.0 Xml;HDR=NO"";" ;Global $sADOConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & $sFilePath & ";Extended Properties=""Excel 12.0;HDR=NO;IMEX=1"";" ;Global $sADOConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & $sFilePath & ";Extended Properties=Excel 8.0;" ;Global $sADOConnectionString = "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" & $sFilePath & ";ReadOnly=0;" ;https://www.w3schools.com/asp/prop_rs_cursorlocation.asp ;A Recordset object inherits this setting from the associated Connection object. ;This property is read-only on an open Recordset object, and read/write on a Connection object or on a closed Recordset object. $cn.CursorLocation = 2 ;2 adUseServer, 3 adUseClient $cn.CommandTimeout = 30 ;https://stackoverflow.com/questions/31941487/open-adodb-connection-to-excel-file-in-read-only-mode ;try Mode = adModeRead instead ;By the way, do not put adModeRead in the connections string, but just before openning your connection, add this line: rsConn.Mode = adModeRead ;I tried your suggestion, however since in VBA we do not have direct access to the ADODB built-in constants, I set rsCon.Mode = 1 ;as defined in the file adovbs.inc located in the folder "C:\Program Files\Common Files\System\ado" ;and although I watched the rsCon.Mode value being set to adModeRead while debugging, I still have the same problem and the application tries to access the file in Write/Edit mode. ;https://www.w3schools.com/asp/prop_rec_mode.asp ;$cn.Mode = 1 ;Read-only $cn.Open($sADOConnectionString) ; Open the connection ;MsgBox(0, "", $cn.ConnectionString) $sSQL = "UPDATE (([Sheet1$A2:C11] a" _ & " INNER JOIN " & $testmdb & ".[Order_Details] b ON a.F1 = b.ID)" _ & " INNER JOIN " & $testmdb & ".[Orders] c ON b.ID = c.ID)" _ & " INNER JOIN " & $testmdb & ".[Customers] d ON c.CustomerID = d.ID" _ & " SET a.F2 = c.OrderDate, a.F3 = d.CompanyName;" $cn.Execute($sSQL, Default, 1 + 0x80) ;adCmdText = 1 , adExecuteNoRecords = 0x80 $sSQL = "SELECT F2, F3, Sum(Quantity * UnitPrice) As Amount" _ & " FROM [Sheet1$A2:C11] AS a INNER JOIN " & $testmdb & ".[Order_Details] b ON a.F1 = b.ID" _ & " GROUP BY F2, F3" _ & " ORDER BY F2;" $rst.Open($sSQL, $cn, $iCursorType, $iLockType, $iOptions) ; Issue the SQL query If Not $rst.EOF = True Then Local $rstArray = $rst.GetRows() _ArrayDisplay($rstArray, "Test", "", $ARRAYDISPLAY_NOROW, "", "F1|F2|F3") $rst.Close $rst = 0 ;Release the recordset object ;$cmd = 0 $cn.Close ;Close the connection $cn = 0 ;Release the connection object Global $RecCount = UBound($rstArray) #===== EXCEL ===== Global $oMyError = ObjEvent("AutoIt.Error", "ErrFunc") ;Install a custom error handler Global $iEventError ; to be checked to know if com error occurs. Must be reset after handling. ;_DebugSetup() ;_DebugCOMError() ;water: force the Excel UDF to always start up a new instance by using: _Excel_Open(False, Default, Default, Default, True) ;Global $oAppl = _Excel_Open(True, False, False, Default, True) Global $oAppl = _Excel_Open() ;_Excel_Open(Default, Default, False, Default, Default) ;If @error Then Exit MsgBox(0, "Error", "Error _Excel_Open" & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;https://www.autoitscript.com/forum/topic/185789-solved-excel_bookopen-without-wait/?do=findComment&comment=1334509 ;Restaurar en cada arquivo (algún Application.Run pudo cambiar) ;$oAppl.EnableEvents = False $oAppl.DisplayAlerts = False ;~ ;Arquivo non bloqueado ;~ Global $iFileExists ;~ For $j = 0 To 60 ;~ $iFileExists = FileExists($sFilePath2) ;~ If $iFileExists Then ;~ While _WinAPI_FileInUse($sFilePath2) ;~ Sleep(1000) ;~ WEnd ;~ ExitLoop ;~ Else ;~ Sleep(1000) ;~ EndIf ;~ Next ;Create a new workbook with only 1 worksheet Global $oWorkbook = _Excel_BookNew($oAppl, 1) ;If @error Then Exit MsgBox(0, "Excel UDF: _Excel_BookNew Example 1", "Error creating new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;MsgBox(0, "Excel UDF: _Excel_BookNew Example 1", "Workbook has been created successfully with only 1 worksheets.") ;~ Global $oWorkbook = _Excel_BookOpen($oAppl, $sFilePath5, False, True) ;~ ;If @error Then Exit MsgBox(0, "Error", "Error _Excel_BookOpen: " & $sFilePath & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;~ ;Create a new workbook with only 1 worksheet ;~ ;Global $oWorkbook = _Excel_BookNew($oAppl, 1) ;~ ;If @error Then Exit MsgBox(0, "Excel UDF: _Excel_BookNew Example 1", "Error creating new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;~ ;MsgBox(0, "Excel UDF: _Excel_BookNew Example 1", "Workbook has been created successfully with only 1 worksheets.") ;Sleep(3000) ;~ Global $sMessage, $sMessage2 ;~ SplashTextOn("TitleFoo", $sMessage, 580, 60, 900, 840, 1 + 4, "", 16) ;~ For $i = 1 To 10 ;~ $sMessage = $sMessage & "." ;~ $sMessage2 = @TAB & "Pausa " & $sMessage ;~ ControlSetText("TitleFoo", "", "Static1", $sMessage2) ;~ Sleep(1000) ;~ Next $oWorkbook.UpdateLinks = 2 ;xlUpdateLinksNever ;Global $oSheets = $oWorkbook.Sheets Global $oSheet = $oWorkbook.ActiveSheet ;Global $oSheet = $oWorkbook.Sheets("Sheet1") ;MsgBox(0, "", $oSheet.Name) $oSheet.Range("A1:C1").Font.Bold = True $oSheet.Range("A1:A" & $RecCount + 1).NumberFormat = "dd/mm" $oSheet.Range("B1:B" & $RecCount + 1).NumberFormat = "@" Global $oPageSetup = $oSheet.PageSetup With $oPageSetup .PrintTitleRows = "$1:$1" .PrintTitleColumns = "" .PrintArea = "" .LeftHeader = "&D" .CenterHeader = "Report" .RightHeader = "&P of &N" ;.LeftFooter = "&F {&A}" .CenterFooter = "" .RightFooter = "" .LeftMargin = 28 .RightMargin = 28 .TopMargin = 28 .BottomMargin = 28 .HeaderMargin = 15 .FooterMargin = 15 .PrintHeadings = False .PrintGridlines = True .PrintComments = -4142 .CenterHorizontally = False .CenterVertically = False .Orientation = 1 ;2 .Draft = False .FirstPageNumber = -4105 .Order = 1 .BlackAndWhite = True .Zoom = 100 EndWith ;https://www.autoitscript.com/forum/topic/195252-_excel_rangewrite-doesnt-write-array-from-adodb-getrows/ Global $TrstArray = $rstArray _ArrayTranspose($TrstArray) $oSheet.Range("A2:C" & $RecCount + 1).Value = $TrstArray Global $aArray2D[1][4] = [["Date", "Client", "Amount"]] _Excel_RangeWrite($oWorkbook, $oSheet, $aArray2D, $oSheet.Cells(1, 1)) ;Global $aArray1D[11] = ["ID", "Udes", "Descrip", "Matricula", "Kilos", "Proveedor", "Corredor", "Fecha", "Contrato", "Restan", "Tanque"] ;$oSheet.Range("A1:K1").value = $aArray1D ;Global $aArray2D[1][6] = [[$rstArray[$i][1], $rstArray[$i][2], $rstArray[$i][3], $rstArray[$i][4], $rstArray[$i][5], $rstArray[$i][6]]] ;_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aArray2D, $oSheet.Cells($UltimaFila, 1).Resize(1, 6)) ;If @error Then Exit MsgBox(0, "Error", "Error _Excel_RangeWrite: " & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;Global $aArray2D[3][5] = [[11, 12, 13, 14, 15], [21, 22, 23, 24, 25], [31, 32, 33, 34, 35]] ;_Excel_RangeWrite($oWorkbook, Default, $aArray2D, "B1") ;Local $aArray1D[13] = ["Ped", "Archivo", "Abono", "NomCli", "H+I", "ACIDEZ", "CERAS", "E+U", "aa", "aa", "aa", "aa", "aa"] ;$oSheet.Range("A1:M1").value = $aArray1D ;$oSheet.Cells(1, 1).Resize(1, 13).value = $aArray1D ;_Excel_BookSaveAs($oWorkbook, $sFilePath, $xlOpenXMLWorkbook, True) ;$xlOpenXMLWorkbook 51 ;$xlExcel8 56 ;_Excel_BookClose($oWorkbook, False) ;_Excel_BookClose($oWorkbook, True) ;If @error Then Exit MsgBox(0, "Error", "Error _Excel_BookClose: " & $sFilePath & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;~ While _WinAPI_FileInUse($sFilePath5) ;~ Sleep(1000) ;~ Wend ;~ Sleep(3000) ;$oAppl.EnableEvents = True $oAppl.DisplayAlerts = True ;https://www.autoitscript.com/forum/topic/136414-excel-close-problem/?do=findComment&comment=953433 ;$oAppl.Application.Quit ;$oAppl = "" ;https://www.autoitscript.com/forum/topic/166043-close-the-entire-application-of-excel/ ;https://www.autoitscript.com/forum/topic/166043-close-the-entire-application-of-excel/?do=findComment&comment=1262478 ;Run(@ComSpec & " /c " & 'taskkill /im excel.exe /f /t', "", @SW_HIDE) ;https://www.autoitscript.com/forum/topic/166043-close-the-entire-application-of-excel/?do=findComment&comment=1262830 ;water / Ok. Let's see if the problem is caused by open/close or by working with a workbook. Could you please try: ;#include <Excel.au3> ;$oExcel = _Excel_Open(False, False, False, False, True) ;$oExcelClose = _Excel_Close($oExcel, False, True) ;~ _Excel_Close($oAppl, False, Default) ;If @error Then Exit MsgBox(0, "Error", "Error _Excel_Close" & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;~ Sleep(1000) ;~ ;Check excel closed ;~ Local $aProcesses = ProcessList("Excel.exe") ;~ ;_ArrayDisplay($aProcesses) ;~ If $aProcesses[0][0] > 0 Then ;~ ;https://www.autoitscript.com/forum/topic/166043-close-the-entire-application-of-excel/?do=findComment&comment=1263191 ;~ ;@water, thanks for your help so far, at least we pinned down that it's not a UDF bug. :) ;~ ;For now I will use a crude workaround by closing the most recent Excel.exe instance: ;~ ProcessClose($aProcesses[$aProcesses[0][0]][1]) ;~ Sleep(100) ;just to allow some time for the process to definitely close (if it does close) ;~ EndIf Else $rst.Close $rst = 0 ; Release the recordset object $cn.Close ; Close the connection $cn = 0 ; Release the connection object ;Disconnect MsgBox(262144, "", "Empty Recordset", 5) EndIf ;This is a custom error handler Func ErrFunc() Local $HexNumber = Hex($oMyError.number, 8) ;~ MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _ ;~ "Number is: " & $HexNumber & @CRLF & _ ;~ "WinDescription is: " & $oMyError.windescription) ConsoleWrite("-> We intercepted a COM Error !" & @CRLF & _ "-> err.number is: " & @TAB & $HexNumber & @CRLF & _ "-> err.source: " & @TAB & $oMyError.source & @CRLF & _ "-> err.windescription: " & @TAB & $oMyError.windescription & _ "-> err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF) $iEventError = 1 ; Use to check when a COM Error occurs EndFunc ;==>ErrFunc Func _ErrADODB() Msgbox(0,"ADODB COM Error","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $errADODB.description & @CRLF & _ "err.windescription:" & @TAB & $errADODB.windescription & @CRLF & _ "err.number is: " & @TAB & hex($errADODB.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $errADODB.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $errADODB.scriptline & @CRLF & _ "err.source is: " & @TAB & $errADODB.source & @CRLF & _ "err.helpfile is: " & @TAB & $errADODB.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $errADODB.helpcontext, 5) Local $err = $errADODB.number If $err = 0 Then $err = -1 ;Devolver datos error Local $sFilePath = @DesktopDir & "\error.txt" ;Open the file for write access. Local $hFileOpen = FileOpen($sFilePath, 2) ;If $hFileOpen = -1 Then ;MsgBox(0, "", "An error occurred when reading/writing the file.") ;EndIf FileWrite($hFileOpen, "ADODB COM Error" & Chr(1) & _ "err.description is: " & @TAB & $errADODB.description & Chr(1) & _ "err.windescription:" & @TAB & $errADODB.windescription & Chr(1) & _ "err.number is: " & @TAB & hex($errADODB.number,8) & Chr(1) & _ "err.lastdllerror is: " & @TAB & $errADODB.lastdllerror & Chr(1) & _ "err.scriptline is: " & @TAB & $errADODB.scriptline & Chr(1) & _ "err.source is: " & @TAB & $errADODB.source & Chr(1) & _ "err.helpfile is: " & @TAB & $errADODB.helpfile & Chr(1) & _ "err.helpcontext is: " & @TAB & $errADODB.helpcontext _ ) ;Close the handle returned by FileOpen. FileClose($hFileOpen) $rst = 0 ;$cmd = 0 $cn.Close $cn = 0 ;Disconnect Exit EndFunc Func OnAutoItExit() $rst = 0 ;Release the recordset object If IsObj($cn) Then If $cn.State > 0 Then $cn.Close ;adStateOpen Close the connection $cn = 0 ; Release the connection object EndIf EndFunc example_files.zip
    1 point
  6. czardas

    GUI design concepts.

    Menu Bar Buttons Yesterday I stumbled upon an idea. I needed to add some buttons to my GUI, but didn't have enough room. There was plenty of room left on the menu bar, so that's where I decided put them. The method works fine on my machine (surprisingly perhaps). Please report if you experience any issues running the script, or if you know of a better way to do this. Thanks. ; #include <GuiconstantsEx.au3> #include <StaticConstants.au3> _MenuButtons() Func _MenuButtons() Local $hGUI = GUICreate("Menu Button Example", 270, 100) GUICtrlCreateMenu(" ") ; A menu has to be created first (this seems logical). GUICtrlSetState(-1, $GUI_DISABLE) ; The above menu is treated as a spacer. Local $hToStart = GUICtrlCreateMenuItem(" << ", -1) ; Menu items are now placed on the menu bar. Local $hStepBack = GUICtrlCreateMenuItem(" < ", -1) Local $hPlay = GUICtrlCreateMenuItem(" P ", -1) Local $hStepForward = GUICtrlCreateMenuItem(" > ", -1) Local $hToEnd = GUICtrlCreateMenuItem(" >> ", -1) Local $hLabel = GUICtrlCreateLabel("", 10, 25, 250, 20, $SS_CENTER) GUISetState(@SW_SHOW) Local $msg While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $hToStart GUICtrlSetData($hLabel, "Back to Start") Case $hStepBack GUICtrlSetData($hLabel, "Step Back") Case $hPlay GUICtrlSetData($hLabel, "Play / Pause") Case $hStepForward GUICtrlSetData($hLabel, "Step Forward") Case $hToEnd GUICtrlSetData($hLabel, "Forward to End") EndSwitch WEnd EndFunc ; The help file states that when setting menuID to -1 with GUICtrlCreateMenuItem(), '-1 refers to the first level menu'. For me, it's difficult to interpret what this means. The controls just appear on the menu bar, which I never (quite) thought of as being a menu: since it has no specific handle (that I know of) and is not clickable by default. Also consider that if you remove the menu created in the example above, the code will no longer work as expected. I am at a loss to explain this. Testers needed!
    1 point
  7. UEZ

    GUI design concepts.

    Found this in my collection: ;another fast hack by UEZ 2011 #include <GDIPlus.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) _GDIPlus_Startup() Global Const $SC_DRAGMOVE = 0xF012 Global Const $W = -1 Global Const $H = 200 Global Const $hGUI = GUICreate("GDI+ Test by UEZ 2011", $W, $H, -1, -1, $WS_POPUP, $WS_EX_LAYERED) Global Const $hGUI_Child = GUICreate("", $W, $H, 0, 0, $WS_POPUP, $WS_EX_MDICHILD + $WS_EX_LAYERED + $WS_EX_TOOLWINDOW, $hGUI) GUISetBkColor(0xABCDEF, $hGUI_Child) GUISwitch($hGUI_Child) Global Const $idButton = GUICtrlCreateButton("Exit", 40, 20, 100, 40) GUICtrlSetOnEvent(-1, "_Exit") Global Const $idLabel = GUICtrlCreateLabel("TEST LABEL HERE!!!", 110, 140, 180, 20) GUICtrlSetFont(-1, 14, 400, 0, "Times New Roman", 3) GUICtrlSetColor(-1, 0xF0F0FF) GUICtrlSetBkColor(-1, -2) _WinAPI_SetLayeredWindowAttributes($hGUI_Child, 0xABCDEF, 0xFF) GUISetState(@SW_SHOW, $hGUI_Child) GUISetState(@SW_SHOW, $hGUI) _SetGuiRoundCorners($hGUI, 40, False, True, True, False) Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global Const $hBitmap = _CreateCustomBk($hGUI, 0x550555) Global Const $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) _CreateCustomGroupPic($hContext, 100, 100, 200, 75, 0xff0000) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $W, $H) SetTransparentBitmap($hGUI, $hBitmap, 0xD0) GUISetOnEvent(-3, "_Exit") GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") While Sleep(2 ^ 16) WEnd Func _Exit() _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI_Child) GUIDelete($hGUI) Exit EndFunc ;==>_Exit Func _CreateCustomBk($hGUI, $hexColor, $alpha = "0xAA") Local $iWidth = _WinAPI_GetClientWidth($hGUI) Local $iHeight = _WinAPI_GetClientHeight($hGUI) Local $oBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($oBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Local $hBrush = _GDIPlus_BrushCreateSolid($alpha & Hex($hexColor, 6)) _GDIPlus_GraphicsFillRect($hGraphics, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_GraphicsFillRect($hGraphics, 2, 2, $iWidth - 6, $iHeight - 6, $hBrush) _GDIPlus_BrushSetSolidColor($hBrush, 0x22FFFFFF) Local $iTimes = Round($iWidth / 50) Local $aPoints[5][2] $aPoints[0][0] = 4 $aPoints[1][1] = $iHeight $aPoints[2][1] = $iHeight $aPoints[4][1] = 0 $aPoints[3][1] = 0 For $i = 0 To $iTimes Local $Random1 = Random(0, $iWidth, 1) Local $Random2 = Random(30, 50, 1) $aPoints[1][0] = $Random1 $aPoints[2][0] = $Random1 + $Random2 $aPoints[4][0] = $aPoints[1][0] + 50 $aPoints[3][0] = $aPoints[2][0] + 50 _GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush) $aPoints[1][0] -= $Random2 / 10 $aPoints[2][0] = $Random1 + $Random2 - ($Random2 / 10 * 2) $aPoints[3][0] = $aPoints[2][0] + 50 $aPoints[4][0] = $aPoints[1][0] + 50 _GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush) Next _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) Return $oBitmap EndFunc ;==>_CreateCustomBk Func _CreateCustomGroupPic($hGraphics, $ix, $iy, $Width, $iHeight, $hexColor, $alpha = "0x55") _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Local $hBrush = _GDIPlus_BrushCreateSolid($alpha & Hex($hexColor, 6)) _GDIPlus_GraphicsFillRect($hGraphics, $ix, $iy, $Width, $iHeight, $hBrush) _GDIPlus_GraphicsFillRect($hGraphics, 2, 2, $Width - 4, $iHeight - 4, $hBrush) _GDIPlus_BrushDispose($hBrush) EndFunc ;==>_CreateCustomGroupPic Func _SetGuiRoundCorners($hGUI, $iEllipse, $iLeftUp = True, $iLeftDown = True, $iRightUp = True, $iRightDown = True) Local $hCornerRgn Local $aGuiSize = WinGetPos($hGUI) Local $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $aGuiSize[2], $aGuiSize[3], $iEllipse, $iEllipse) If $iLeftUp = False Then $hCornerRgn = _WinAPI_CreateRectRgn(0, 0, $aGuiSize[2] / 2, $aGuiSize[3] / 2) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iLeftDown = False Then $hCornerRgn = _WinAPI_CreateRectRgn(0, $aGuiSize[3] / 2, $aGuiSize[2] / 2, $aGuiSize[3]) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iRightUp = False Then $hCornerRgn = _WinAPI_CreateRectRgn($aGuiSize[2] / 2, 0, $aGuiSize[2], $aGuiSize[3] / 2) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iRightDown = False Then $hCornerRgn = _WinAPI_CreateRectRgn($aGuiSize[2] / 2, $aGuiSize[3] / 2, $aGuiSize[2] - 1, $aGuiSize[3] - 1) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf _WinAPI_SetWindowRgn($hGUI, $hRgn) EndFunc ;==>_SetGuiRoundCorners Func SetTransparentBitmap($hGUI, $hImage, $iOpacity = 0xFF) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetTransparentBitmap Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) If @error Then Return SetError(@error, @extended, 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0 Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Screenshot: Br, UEZ
    1 point
  8. Jon

    Forum Information and FAQs

    User Groups and Rights New Members - New members with that joined the forum within the last day. While in this group there are certain restrictions on the number of posts/PMs that can be made. This is to reduce the impact of spammers. After 24 hours members of this group will be promoted the Members group. Members - Members older than one day but with less than 20 posts. Standard access to the forum. Active Members - Members with more than 20 posts have additional rights No advertsSlightly more generous attachment and PM limitsAccess to the Chat forumAbility to upload files to the Downloads section MVPs - Members who are judged by the community to be helpful, who write and share useful code, who help the development of AutoIt. These users have the same rights as normal members but get a team icon, a little more attachment and PM space, and access to the MVP Chat forum section. Moderators - The forum police. This is not a democracy and each of the mods has their own distinct personality. They have the rights to edit posts, delete posts, ban users, delete users, IP ban, etc. Let the poster beware. Developers - A small group of users with access to the AutoIt source code and who have contributed significantly to the internal development of AutoIt. Some of them are also Moderators. Post Count and Rankings Ranks based on increasing post count are as follows: SeekerWayfarerAdventurerProdigyPolymathUniversalistThese titles are auto-generated and have no relation to actual skill level. Once you reach 300 posts you can change the title to whatever you like.
    1 point
×
×
  • Create New...