Leaderboard
Popular Content
Showing content with the highest reputation on 02/19/2023 in all areas
-
How to use GUISetAccelerators for multiply language layouts? - (Moved)
argumentum and one other reacted to mdf4356 for a topic
Bingo! _WinAPI_RegisterHotKey - works with virtual-key codes regardless of keyboard layout #include <APISysConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> Opt('TrayAutoPause', 0) OnAutoItExitRegister('OnAutoItExit') Local $hWnd = GUICreate('Test message' & StringReplace(@ScriptName, '.au3', '()')) GUIRegisterMsg($WM_HOTKEY, 'WM_HOTKEY') ; https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes $VK_S = 0x53 ; Virtual-key code for S key $VK_O = 0x4F ; Virtual-key code for O key $VK_ESCAPE = 0x1B ; Virtual-key code for Esc key #cs <APIConstants.au3> or <APISysConstants.au3> $MOD_ALT = 0x0001 $MOD_CONTROL = 0x0002 $MOD_NOREPEAT = 0x4000 $MOD_SHIFT = 0x0004 $MOD_WIN = 0x0008 #ce _WinAPI_RegisterHotKey($hWnd, 1, $MOD_CONTROL, $VK_S) ; Ctrl+S _WinAPI_RegisterHotKey($hWnd, 2, BitOR($MOD_CONTROL, $MOD_SHIFT), $VK_S); Ctrl+Shift+S _WinAPI_RegisterHotKey($hWnd, 3, $MOD_CONTROL, $VK_O) ; Ctrl+O _WinAPI_RegisterHotKey($hWnd, 4, BitOR($MOD_SHIFT, $MOD_ALT), $VK_S) ; Shift-Alt-S _WinAPI_RegisterHotKey($hWnd, 0, 0, $VK_ESCAPE) ; ESC While 1 Sleep(1000) WEnd Func WM_HOTKEY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Switch $wParam Case 1 MsgBox($MB_SYSTEMMODAL, 'WM_HOTKEY Function', 'You pressed Ctrl+S') Case 2 MsgBox($MB_SYSTEMMODAL, 'WM_HOTKEY Function', 'You pressed Ctrl+Shift+S') Case 3 MsgBox($MB_SYSTEMMODAL, 'WM_HOTKEY Function', 'You pressed Ctrl+O') Case 4 MsgBox($MB_SYSTEMMODAL, 'WM_HOTKEY Function', 'You pressed Shift-Alt-S') Case 0 MsgBox($MB_SYSTEMMODAL, '', 'You pressed ESC') Exit EndSwitch EndFunc ;==>WM_HOTKEY Func OnAutoItExit() _WinAPI_UnregisterHotKey($hWnd, 1) _WinAPI_UnregisterHotKey($hWnd, 2) _WinAPI_UnregisterHotKey($hWnd, 3) _WinAPI_UnregisterHotKey($hWnd, 4) _WinAPI_UnregisterHotKey($hWnd, 0) EndFunc ;==>OnAutoItExit If you want to switch to the main loop? It's pretty simple: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case 1 MsgBox($MB_SYSTEMMODAL, 'Main loop', 'You pressed Ctrl+S') Case 2 MsgBox($MB_SYSTEMMODAL, 'Main loop', 'You pressed Ctrl+Shift+S') Case 3 MsgBox($MB_SYSTEMMODAL, 'Main loop', 'You pressed Ctrl+O') Case 4 MsgBox($MB_SYSTEMMODAL, 'Main loop', 'You pressed Shift-Alt-S') EndSwitch WEnd Func WM_HOTKEY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Switch $wParam Case 1 $nMsg = 1 Case 2 $nMsg = 2 Case 3 $nMsg = 3 Case 4 $nMsg = 4 Case 0 MsgBox($MB_SYSTEMMODAL, '', 'You pressed ESC') Exit EndSwitch EndFunc ;==>WM_HOTKEY ioa747 TNX for help! But it works on the system level, defines a system-wide hotkeys. How to do similar result on the application level?2 points -
now is OK? because I didn't understand and now, and before, the MsgBox is coming #include <APISysConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #include <WinAPIvkeysConstants.au3> Opt('TrayAutoPause', 0) OnAutoItExitRegister('OnAutoItExit') Local $hWnd = GUICreate('Test message' & StringReplace(@ScriptName, '.au3', '()')) Local $Register, $RegisterOld GUIRegisterMsg($WM_HOTKEY, 'WM_HOTKEY') While 1 If WinActive("[CLASS:Notepad]") Then $Register = 1 Else $Register = 0 EndIf If $Register <> $RegisterOld Then $RegisterOld = $Register _RegisterHotKey($Register) EndIf Sleep(500) WEnd Func _RegisterHotKey($Swich = 0) #cs ; https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes Local $VK_S = 0x53 ; Virtual-key code for S key Local $VK_O = 0x4F ; Virtual-key code for O key Local $VK_ESCAPE = 0x1B ; Virtual-key code for Esc key <APIConstants.au3> or <APISysConstants.au3> $MOD_ALT = 0x0001 $MOD_CONTROL = 0x0002 $MOD_NOREPEAT = 0x4000 $MOD_SHIFT = 0x0004 $MOD_WIN = 0x0008 #ce If $Swich = 1 Then _WinAPI_RegisterHotKey($hWnd, 1, $MOD_CONTROL, $VK_S) ; Ctrl+S _WinAPI_RegisterHotKey($hWnd, 2, BitOR($MOD_CONTROL, $MOD_SHIFT), $VK_S) ; Ctrl+Shift+S _WinAPI_RegisterHotKey($hWnd, 3, $MOD_CONTROL, $VK_O) ; Ctrl+O _WinAPI_RegisterHotKey($hWnd, 4, BitOR($MOD_SHIFT, $MOD_ALT), $VK_S) ; Shift-Alt-S _WinAPI_RegisterHotKey($hWnd, 0, 0, $VK_ESCAPE) ; ESC ConsoleWrite("--> RegisterHotKey" & @CRLF) Else _WinAPI_UnregisterHotKey($hWnd, 1) _WinAPI_UnregisterHotKey($hWnd, 2) _WinAPI_UnregisterHotKey($hWnd, 3) _WinAPI_UnregisterHotKey($hWnd, 4) _WinAPI_UnregisterHotKey($hWnd, 0) ConsoleWrite("RegisterHotKey <--" & @CRLF) EndIf EndFunc ;==>_RegisterHotKey Func WM_HOTKEY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Switch $wParam Case 1 MsgBox($MB_SYSTEMMODAL, 'WM_HOTKEY Function', 'You pressed Ctrl+S') Case 2 MsgBox($MB_SYSTEMMODAL, 'WM_HOTKEY Function', 'You pressed Ctrl+Shift+S') Case 3 MsgBox($MB_SYSTEMMODAL, 'WM_HOTKEY Function', 'You pressed Ctrl+O') Case 4 MsgBox($MB_SYSTEMMODAL, 'WM_HOTKEY Function', 'You pressed Shift-Alt-S') Case 0 MsgBox($MB_SYSTEMMODAL, '', 'You pressed ESC') Exit EndSwitch EndFunc ;==>WM_HOTKEY Func OnAutoItExit() _RegisterHotKey(0) EndFunc ;==>OnAutoItExit1 point
-
OpenCV v4 UDF
DoVinhTrung reacted to smbape for a topic
Update opencv to 4.7.0 COM Registration is no longer required1 point -
1 Hotkey for 2 keys in pulse one-after-one
SevenScript reacted to mistersquirrle for a topic
Here's a way for you to do sequential actions through a single hotkey, expandable to more than just 2 options: HotKeySet('\', 'fc') ; Keep in mind that Send can trigger hotkeys, so using '1' is a bad idea if you're Sending a 1 in your function While True Sleep(10) WEnd Func fc() Local Static $iCount = 0 Local Const $iCountMax = 5 Switch $iCount Case 0 ; Keep in mind if you're starting at 0 or 1, and what you reset it to Send('Pulse 1') Case 1 Send('Pulse 2') Case 2 Send('Pulse 3') Case 3 Send('Pulse 4') Case 4 Send('Pulse 5') Case Else ConsoleWrite('Unregistered count/action: ' & $iCount & @CRLF) EndSwitch $iCount += 1 If $iCount >= $iCountMax Then ; You can reset your count when you've reached your specified max $iCount = 0 EndIf Return $iCount EndFunc1 point -
Step 1. Install Python Step 2. Open CMD, run "pip install pywin32" Step 3. Go to your_python_directory\Lib\site-packages\win32com\servers Step 4. Register python COM server by running script "interp.py" Example 1: $py = ObjCreate("Python.Interpreter") $py.exec("import sys") $py_version = $py.eval("sys.version") MsgBox(64, "Hello World!", "Hello World from Python " & $py_version) Example 2: $py = ObjCreate("Python.Interpreter") $py.exec("import customtkinter") $py.exec("import sys") $py.exec("gui = customtkinter.CTk()") $py.exec("GUI_WIDTH = 640") $py.exec("GUI_HEIGHT = 115") $py.exec("GUI_HORIZONTAL = int((gui.winfo_screenwidth() - GUI_WIDTH) / 2)") $py.exec("GUI_VERTICAL = int((gui.winfo_screenheight() - GUI_HEIGHT) / 2)") $py.exec("gui.geometry(f'{GUI_WIDTH}x{GUI_HEIGHT}+{GUI_HORIZONTAL}+{GUI_VERTICAL}')") $py.exec("gui.resizable(False, False)") $py.exec("gui.title('Hello World!')") $py.exec("customtkinter.CTkLabel(gui, text=f'Hello World from Python {sys.version}').pack(expand=1)") $py.exec("gui.mainloop()")1 point
-
GuiBuilderPlus [updated March 24, 2024]
TJHart85_2 reacted to kurtykurtyboy for a topic
A small but mighty update found in the first post. I spent a lot of time on the selection handles AKA grippies. Now when you select multiple controls either by drag-selecting or Ctrl+select, each selected control will show a set of grippies. Conversely, holding Ctrl and clicking on a control that is already selected will DEselect that control. There are a few things I'd like to iron out, such as scaling the controls proportionally when dragging to resize multiple controls, but overall I am quite happy with where it is at now. Selecting and interacting with controls is much more stable now as well. Other than some miscellaneous bug fixes and maintenance items, you can now add menu items to the main menus. It is a little quirky and requires using the object explorer to add and delete items. But that was the best solution I could come up with without adding a ton more work. FIXED: Array subscript error when closing tool windows. FIXED: Multiple selection while holding Ctrl key now works properly. FIXED: Save/load GUI height with menus ADDED: Show grippies on each selected control! Each control object now has a built-in grippy object ADDED: Menu items can now be added and removed from the object explorer only REMOVED: Prompt to save to au3 file. User can always use File menu to save/export UPDATED: modified the About dialog text for a more detailed description and naming history MAINT: cleaned up more global variables MAINT: made control selection much more robust and consistent Also added a link to the Github repo per the suggestion of @mLipok1 point -
Alright, after sleeping on it.... I finally managed to figure this out. Here is the working solution: #include <GuiMenu.au3> #include <WinAPIError.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> GUIRegisterMsg($WM_CONTEXTMENU, "_WM_CONTEXTMENU") GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") Global $idMenuItem = 10000, $counter = 0 Global $hGUI = GUICreate("Menu test", 400, 300) Global $idListview = GUICtrlCreateListView("", 2, 2, 396, 200) Global $hListview = GUICtrlGetHandle($idListview) GUISetState(@SW_SHOW) Global $hMenuContext = _GUICtrlMenu_CreatePopup($MNS_MODELESS) _GUICtrlMenu_AddMenuItem($hMenuContext, "Menu item", $idMenuItem) Global $hTimer = TimerInit() Do If TimerDiff($hTimer)>200 Then $counter += 1 ConsoleWrite($counter & " " ) $hTimer = TimerInit() EndIf Until GUIGetMsg() = $GUI_EVENT_CLOSE Exit Func _WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Switch $hWnd Case $hGUI Switch $wParam Case $hListview _GUICtrlMenu_TrackPopupMenu($hMenuContext, $hWnd) EndSwitch EndSwitch EndFunc Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Switch $wParam Case $idMenuItem ConsoleWrite( @CRLF & "_GUICtrlMenu_TrackPopupMenu menu item clicked = " & $idMenuItem & @CRLF) EndSwitch Return $GUI_RUNDEFMSG EndFunc No keyboards were smashed in the making of this script.1 point