Leaderboard
Popular Content
Showing content with the highest reputation on 11/13/2021 in all areas
-
🙃 ConsoleWrite("- Is Windows 11: " & _IsWindows_11() & @CRLF) ;ConsoleWrite("- Is Windows Server 2022: " &_IsWindows_22() & @CRLF) Func _IsWindows_11() If StringInStr(@OSVersion, "11") Or StringInStr(_GetOS_Name(), "11") Then Return 1 Return 0 EndFunc ;==>_IsWindows_11 Func _IsWindows_22() If StringInStr(@OSVersion, "22") Or StringInStr(_GetOS_Name(), "22") Then Return 1 Return 0 EndFunc ;==>_IsWindows_22 Func _GetOS_Name() Local $OSname, $objItem = "", $strComputer = ".", $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20 Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\") Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $OSname = $objItem.Caption ConsoleWrite("> System: " & $OSname & @CRLF) Return $OSname Next Else ConsoleWrite("! No WMI Objects Found for class: Win32_OperatingSystem" & @CRLF) Return SetError(1, 0, "") EndIf EndFunc ;==>_GetOS_Name ; DAO VAN TRONG - TRONG.LIVE1 point
-
1 point
-
_OpenCV_Open_And_Register and _OpenCV_Unregister_And_Close have an additional parameter "$user". When this parameter is True, which is the default value, the application redirects registry access to the HKEY_CURRENT_USER (HKCU) node. For me, a program that requires admin autorisation should be treated with security concerns. That is why, by default, the script should not be executed as administrator. If you really need to execute the script as an administrator, the are some options for you: Register the classes before running the script. You can either register classes for all users or for the current user (come back to me if you have no idea of how to do it). Then use _OpenCV_Open instead of _OpenCV_Open_And_Register and use _OpenCV_Close instead of _OpenCV_Unregister_And_Close With this option, your script can run both as administrator and as non administrator. With this option, your script will be faster to start. With this option, on every udf update, you should first unregister the old classes, then register the new classes Set the $user parameter of _OpenCV_Open_And_Register and _OpenCV_Unregister_And_Close to False. With this option, your script can only be run as an administrator. Detect wheter the script is run as an administrator or not, and depending of the case, set the $user parameter to the correct value.1 point
-
Question for the best approach to write code in multiple test.
It_is_me_Me reacted to Nine for a topic
Another option is to create like an UDF file where you would put the bulk of the code. Then you could include the UDF file into 5 test case scripts with their own specifics...1 point -
GUI/Tray Menu with icons and colors
argumentum reacted to LarsJ for a topic
A new small update in post 289.1 point -
Question for the best approach to write code in multiple test.
It_is_me_Me reacted to Zedna for a topic
#include <GUIConstantsEx.au3> #include <AutoItConstants.au3> Global $comms $commsTCP = "TCP" $comms485 = "485" $commsUSB = "USB" $commsOptics = "Optical" Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 300, 200) ; Create a button control. Local $idButton_runtest = GUICtrlCreateButton("Run Test", 120, 170, 85, 25) Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) Local $iPID = 0 ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton_Close ExitLoop Case $idButton_runtest test1($commsTCP) ;TCP test1($comms485) ;Serial 485 test1($commsUSB) ;USB test1($commsOptics) ;Optical EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) ; Close the Notepad process using the PID returned by Run. If $iPID Then ProcessClose($iPID) EndFunc ;==>Example Func test_2to5() test2() test3() test4() test5() EndFunc Func test1($comms) SplashTextOn("", "Communicating via " & $comms, 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14) Sleep(1000) test_2to5() SplashOff() EndFunc Func test2() SplashTextOn("", "Test Case 2", 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14) Sleep(1000) EndFunc Func test3() SplashTextOn("", "Test Case 3", 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14) Sleep(1000) EndFunc Func test4() SplashTextOn("", "Test Case 4", 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14) Sleep(1000) EndFunc Func test5() SplashTextOn("", "Test Case 5", 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14) Sleep(1000) EndFunc1 point -
SOLVED. (Silly me!) Finally I found out that MS Edge has already exactly the functionality I described in my first post. No workarounds with .lnk files, user profiles or even AutoIt programming necessary. Functionality is called "Turn a Website Into an App" and is available directly unter the Edge "..." icon as "Apps". A really nice functionality for devices with own web pages. And most of us have several of them: DSL/Wifi router, network printer, NAS stations, ...1 point
-
Question for the best approach to write code in multiple test.
It_is_me_Me reacted to Melba23 for a topic
It_is_me_Me, Welcome to the AutoIt forums. When you post code in future please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. Thanks in advance for your cooperation. M231 point -
... and one year later the mirage line still exists in the helpfile1 point
-
The documentation is obviously incorrect. It is only polled once per statement. You can find out for yourself how long it takes by writing a simple test script. On my PC it is 7ms regardless of whether notepad is active or not. $start = TimerInit() For $i = 1 To 1000 $x = ProcessExists("notepad.exe") Next ConsoleWrite("Per iteration = " & TimerDiff($start) / 1000 & " ms")1 point
-
Couple of ways you could just create a shortcut and pin it to the taskbar, you can use different profiles to load a seperate instance for example, this would use the default profile: Note: if you want a different icon (for example I used Google icon) you'll have to download it and place it in a common area. FileCreateShortcut(@ProgramFilesDir & "\Microsoft\Edge\Application\msedge.exe", @DesktopDir & "\Google Shortcut.lnk", @ProgramFilesDir & "\Microsoft\Edge\Application", "--profile-directory=Default http://www.google.com", "", @ScriptDir & "\favicon.ico") Alternatively you coud just create a script using Run to open Edge and create your own custom icon. Run('"' & @ProgramFilesDir & '\Microsoft\Edge\Application\msedge.exe" --profile-directory=Default http://www.google.com')1 point
-
User32.dll can hide it... #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> Local $hGui, $hRichEdit, $iMsg $hGui = GUICreate("Hide caret example", 320, 350, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY )) _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is more text") GUISetState(@SW_SHOW) Local $aResult = DllCall("user32.dll", "int", "HideCaret", "hwnd", $hRichEdit) ; <--- this hides caret While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; GUIDelete() Exit EndSelect WEnd It reappears if user clicks with the mouse in the box though.1 point
-
In the forums you can find several questions about how to edit the text in a ListView cell with a standard control eg. an Edit control or a ComboBox. The zip below contains three examples with an Edit control, a ComboBox and a DateTimePicker. How? A description from MicroSoft of how to edit a ListView cell with a ComboBox can be found here. When you click a cell the position and size is calculated, and the ComboBox is created on top of the cell. The text is shown in the Edit box. You can edit the text or select a value in the Listbox. Press Enter to save the text in the ListView cell and close the ComboBox. The ComboBox exists only while the text is edited. Code issues Especially because the control to edit the ListView cell is created on top of the ListView and is not part of the ListView, there are some issues you should be aware of. To get everything to look as good as possible most actions should be carried out when a mouse button is pressed and not when it's released. You should also be aware that the new code you add, does not conflict with existing functionality for example multiple selections. The examples consists of small but fairly many pieces of code to respond to events and messages. Keyboard support To edit a text value you are more or less forced to use the keyboard to type in the text. It would be nice if you could also select the current cell in the ListView with the keyboard. Cell selection with the keyboard is not too hard to implement with custom draw code. The current cell is drawn with a specific background color. It looks like this. You can select the current cell with the arrow keys. Open the control There must be a way to initiate the creation of the control. This is typically done with a single or double click in the ListView. Or with Enter or Space key in the examples with keyboard support. Default in the examples is double click and Enter key. You can change this in global variables in top of the scripts. A WM_NOTIFY message handler created with GUIRegisterMsg is used to watch for single and double click in the ListView. This message handler is also used to handle custom draw messages for keyboard support. Because the control is created on top of the ListView cell, it's very important that the ListView is set as the parent window. This ensures that mouse clicks and key presses are captured by the control and not by the ListView. Events in the control In a ComboBox and a DateTimePicker an additional control (Listbox and MonthCal, respectively) is opened if you click the Dropdown arrow (or press <Alt+Down arrow> on the keyboard). Click the Dropdown arrow again to close the control (or press <Alt+Up arrow> on the keyboard). The interesting messages (DROPDOWN, SELECTION, CLOSEUP) from such an additional control are usually contained in WM_COMMAND or WM_NOTIFY messages which are sent to the parent window. The parent window is the ListView. To catch the messages the ListView must be subclassed. Messages from the Edit control, the Edit box of the ComboBox, or the client area of the DateTimePicker are catched by subclassing the controls (Edit control, Edit box and DateTimePicker) directly. The interesting information here is dialog codes to accept (Enter) or cancel (Esc) the value and close the control. Dialog codes are sent as $WM_GETDLGCODE messages. In all examples the value in the control can also be accepted and saved with a double click. Close the control A mouse click in the ListView outside the control should close the control and cancel editing of the current cell. Because the control is not part of the ListView in particular mouse clicks on the Scrollbars should close the control immediately. The control will not be repainted properly on scrolling. Mouse clicks in the ListView and on Scrollbars can be identified by WM_LBUTTONDOWN and WM_NCLBUTTONDOWN messages. The area which is filled by Scrollbars in a ListView is non-client area. Mouse clicks in non-client area generates WM_NCLBUTTONDOWN messages. To catch the messages you have to subclass the ListView. A mouse click in the GUI outside the ListView and in non-client GUI area (eg. the Titlebar) should also close the control. Mouse clicks in GUI are catched through GUI_EVENT_PRIMARYDOWN messages. Mouse clicks in non-client GUI area are catched through WM_NCLBUTTONDOWN messages by subclassing the GUI. Finish the code A great part of the code is running in message handlers created with GUIRegisterMsg or created by subclassing a window. Lengthy code to open or close the control should not be executed in these message handlers. Instead of a message is sent to the AutoIt main loop where the control is opened or closed. Some of the message handlers are only needed while the control is open. They are created and deleted as part of the control open and close code. In the context of the updates May 26 the $LVS_EX_HEADERDRAGDROP extended style (rearranging columns by dragging Header items with the mouse) is added to all ListViews. See post 20 and 21. A few lines of code are added to better support usage of the keyboard. See image above. The code provides for horizontal scrolling of the ListView to make sure that a subitem (or column) is fully visible when it's selected with left or right arrow. Among other things, the code takes into account rearranging and resizing of columns as well as resizing of the GUI and ListView. A new example EditControlKeyboardTenCols.au3 demonstrates the features. See post 22. A few lines of code is added to handle multiple selections. Multiple selections is enabled in all examples. Pressing the Tab key in the control closes the control. The image shows a DateTimePicker control. Zip file The zip contains three examples with an Edit control, a ComboBox and a DateTimePicker. For each control there are two scripts with and without keyboard support. In the script with keyboard support you can select the current cell in the ListView with the arrow keys and open the control with the Enter (default) or the Space key. You need AutoIt 3.3.10 or later. Tested on Windows 7 32/64 bit and Windows XP 32 bit. Comments are welcome. Let me know if there are any issues. (Set tab width = 2 in SciTE to line up comments by column.) ListViewEditingCells.7z1 point
-
I know turning scaling off would change your labels not sure about the app not running with the manifest entry added though. I wonder if maybe it has something to do with this: 'SetProcessDPIAware is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. Instead, use SetProcessDpiAwareness' SetProcessDpiAwareness: https://msdn.microsoft.com/en-us/library/windows/desktop/dn302122(v=vs.85).aspx It seems to have the same caveats as SetProcessDPIAware as in placing in manifest rather than calling the function directly, it also isn't available till win 8 and later. Perhaps W10 won't work with the older function in the manifest which I find odd. If so, I think additions to the manifest or logic would be something that would have to be updated in the Autoit Res_HiDpi Pragma Maybe someone more knowledgeable with aut2Exe would be able to inform us on that. For the time being maybe you should use either your current function or maybe do something like this: If @OsType="WIN_10" Then DllCall("Shcore.dll","long","PROCESS_DPI_AWARENESS",1) Else DllCall("User32.dll","bool","SetProcessDPIAware") EndIf ;hResult is 32bit ;PROCESS_DPI_UNAWARE = 0, PROCESS_SYSTEM_DPI_AWARE = 1, PROCESS_PER_MONITOR_DPI_AWARE = 2 Not sure if I got that dll call right I'm not near a PC to test atm. Also, Not necessarily directed at you: I'm unsure how likely it is that a Dll would cache the dpi data. Would the Dll be something called by Autoit or the OS. What exact situation would result in this Race Condition and what are the consequences? Be something to look into as the MSDN page is kind of vague.1 point
-
This can happen when Win10 auto-rescales (see under display settings, I think 125% is default for 1920x1080) to make them easier to read (as hi-res screens make everything that used to look about the right size look tiny now). To make your original script work in full resolution (with macros returning the correct (full) dimensions), while maintaining rescaling for regular programmes, add: DllCall("User32.dll","bool","SetProcessDPIAware") This causes the script to take advantage of the full current resolution, but at the cost of its text and graphics appearing smaller than if running rescaled.1 point
-
I'm going to use these menus. I've updated the UDF, ModernMenuRaw.au3. Of the posts it appears that Holger updated the code on a regular basis until May 2008. ProgAndy made some updates in August 2008. These updates were about the background color of the menubar, the ability to use icon handles, and better cleanup code on exit. The updates I've made are based on the UDF by ProgAndy attached to post 213. It's my intention to update the UDF to make it run under the current versions of AutoIt, and to get rid of errors. Especially already known errors, which can be fixed in a few lines of code. It's not my intention to add a lot of new code to the UDF. Updates 2014-10-18 This update is based on original code by Holger (first post) and updates by ProgAndy (posts 211 - 213). The update supports AutoIt 3.3.10 and later. Code relating to Windows versions not supported by 3.3.10 is deleted. WindowsConstants.au3 is included and double-defined global constants are commented out. Added an update to be able to use colored controls e.g. buttons with this UDF. Post 222. Update (one line) for x64 support. Post 266 by Holger. Added x64 support to functions by ProgAndy. Declared a few local variables. Updates 2014-10-19 Updates to pass Au3Check. (-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6) Updates 2015-01-24 Updates for tray menus suggested by nickston (posts 298, 299, 312) Most important is an update that makes it possible to use a flashing tray menu icon. There are also a few code optimizations. Updates 2021-11-12 Disabled $IDI_ global constants in ModernMenuRaw.au3. $IDI_ constants are included in AutoItConstants.au3. None of the updates above are script breaking. If you are using tray menus and want to compile your script, you should pay attention to posts 268 - 270. Note also that _TrayIconCreate creates a GUI to receive messages from tray icons. After calling this function you should probably use GUISwitch($hGui) or something. Post 227. In the top of ModernMenuRaw.au3 I've included commands.txt from the original zip by Holger. Two commands of ProgAndy to handle the background color of the menubar are added. I've also added an alphabetical list of functions, and a list of Windows messages (used with GUIRegisterMsg). Examples In order to make it easy the examples are included in the zip. The original examples by Holger are included with no changes at all. The 32 examples by AZJIO in the post above are also included with no changes. There are two versions of the examples: an english and a russian. The examples demonstrates the commands one by one and are named with the name of the command. Copied an example by AZJIO and renamed it to _TrayIconSetState-flashing.au3. Added one line of code to make the tray menu icon flash. Only an english version. A new example by nickston that demonstrates a flashing tray menu icon. The example shows how to turn flashing on and off. Two new examples _GUICtrlCreateODTopMenu.au3 and _GUIMenuBarSetBkColor.au3 that demonstrates the commands by ProgAndy to set the background color of the menubar. _GUIMenuBarSetBkColor.au3 is not working on Windows 7. A new example that shows how to use a bitmap from an image list as an icon in a menu item. The example shows also how to use icon handles. 7z-file ModernMenuRaw.au3 - update on 12.11.2021 ModernMenuRaw.au3 - all previous versions ExamplesAZJIO - 32 examples by AZJIO in english and russian versions ExamplesHolger - the original examples by Holger Examplesnickston - flashing tray menu icon ExampleszNew - three new examples Tested with AutoIt 3.3.10 on Windows 7 32/64 bit and Windows XP 32 bit. 2014-10-19: ModernMenuRaw.7z 2015-01-24: ModernMenuRaw.7z Tested with AutoIt 3.3.14.2/5 and beta 3.3.15.4 on Windows 7/10 32/64 bit. ModernMenuRaw.7z1 point
-
This is a great site for regular expressions: http://www.regular-expressions.info/ () = a group, anything captured can be backreferenced in the replace string . = any character, but not newline or empty string '' {n} = quantifier (or repeating modifier) (.{8})(.{8}) = get any 8 characters and make them available in $0, then repeat for $11 point
-
Then you do something like this: $sIn = "This is Text" $sOut = StringRegExpReplace(Hex(Binary($sIn & StringLeft(" ", BitAND(16 - Mod(StringLen($sIn), 16), 15)))), "(.{8})(.{8})", "$1 $2" & @CRLF) MsgBox(0,"", $sOut)1 point
-
Here are two methods achieving what you desire. #include <String.au3> Local $String = "1234567812345678" Local $Hex = _StringToHex($String) $Hex = StringRegExpReplace($Hex, "(.{0,8})", "1 ") ; Insert a space after ever 8th character. $Hex = StringRegExpReplace($Hex, "(.{0,17}) ", "1" & @LF) ; Replace every 18th character with a linefeed, @LF. MsgBox(0, "Hex", "Original String: " & $String & @LF & " Hex: " & @LF & $Hex) ; Or ; --------------------------------------------------------------- Local $Ascii2Hex = AscToHex("1234567812345678") MsgBox(0, "The Output", $Ascii2Hex) Func AscToHex($strString) Local $ah = "" For $i = 1 To StringLen($strString) $ah &= Hex(Asc(StringMid($strString, $i, 1)), 2) If Mod($i, 8) = 0 Then $ah &= @LF ; Insert a line feed, @LF, after every 8th character. ElseIf Mod($i, 4) = 0 Then $ah &= " " ; Insert a space after ever 4th character EndIf Next Return $ah EndFunc ;==>AscToHex1 point