Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/23/2019 in all areas

  1. water

    Help with simple script

    $x = InputBox("Title", "Please enter a number") If @error Then Exit ; Cancelled by user or other error $x = Number($x) For $i = 1 to $x ; ... Your code Next
    2 points
  2. So there was a topic on the General Help and Support board where the poster mentioned it was not easy to check if the system was installed with UEFI or legacy mode and it got me looking down a rabbit hole. Apparently you can't just whip up a simple WMI query to find that out. But I did find that you can read the output of bcdedit.exe to check if the system is using winload.efi or winload.exe, so then I got stuck because bcdedit doesn't play nice with StdoutRead. Finally I discovered that toggling Wow64DisableWow64FsRedirection would make it all work together. I hope this helps someone. Maybe it can be simplified, I'm no expert. 🤨 DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1) $aArray = StringSplit(_getDOSOutput("bcdedit.exe"), @CRLF) DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 0) For $i = 1 To UBound($aArray) - 1 Select Case StringInStr($aArray[$i], 'Windows Boot Loader') And StringInStr($aArray[$i + 3], 'device partition=C:') And StringInStr($aArray[$i + 4], 'winload.efi') ConsoleWrite("UEFI mode" & @CRLF) Case StringInStr($aArray[$i], 'Windows Boot Loader') And StringInStr($aArray[$i + 3], 'device partition=C:') And StringInStr($aArray[$i + 4], 'winload.exe') ConsoleWrite("Legacy BIOS" & @CRLF) EndSelect Next Func _getDOSOutput($command, $wd = '') ; https://www.autoitscript.com/forum/topic/190249-get-result-of-shellexecute/ Local $text = '', $Pid = Run('"' & @ComSpec & '" /c ' & $command, $wd, @SW_HIDE, 2 + 4) While 1 $text &= StdoutRead($Pid, False, False) If @error Then ExitLoop Sleep(10) WEnd Return StringStripWS($text, 7) EndFunc ;==>_getDOSOutput
    1 point
  3. matwachich

    Advanced Input Box

    DEPRECATED: see this new UDF
    1 point
  4. Nine

    Question

    You are welcome Good luck to you.
    1 point
  5. Needed this for copying specific colors without the need for color lookup. Just figured it might be useful to someone. tracks your mouse and gives color feedback in realtime; in hex, dec, and rgb, as well as mouse coordinates F1 to toggle pause. up/down/left/right to move 1 pixel at a time. #include <GUIConstants.au3> #include <Color.au3> #include <WindowsConstants.au3> #include <Misc.au3> HotKeySet("{F1}", "Toggle") Global $Mpos_x Global $Mpos_y Global $ColorVar Global $iColor Global $Red, $Green, $Blue Global $ToggleState $GUI = GUICreate("Coords", 125, 195, 0, 0, $WS_POPUP) $bar = GUICtrlCreateLabel("", -5, -5, 135, 20) GUICtrlCreateInput("",-1,-1, 1, 1) GUICtrlSetBkColor($bar, 0x898989) GUICtrlSetState($bar, $GUI_DISABLE) $close = GUICtrlCreateLabel("", 110, -1, 15, 20) GUICtrlSetBkColor($close, 0xD9403B) GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") $xylabel = GUICtrlCreateLabel("X=" & @CRLF & "Y=", 1, 20, 15, 30) $Label_x_value = GUICtrlCreateLabel("", 17, 20, 50, 11) $Label_y_value = GUICtrlCreateLabel("", 17, 35, 50, 11) GUICtrlCreateLabel("R,G,B", 65, 25, 35, 11) $RGB = GUICtrlCreateLabel("", 60, 40, 60, 11) $copyrgb = GUICtrlCreateButton("+", 97, 23, 25, 15) GUICtrlSetTip($copyrgb, "Copy RGB to clipboard") GUICtrlCreateLabel("Hex Color", 1, 55, 50, 11) $hextext = GUICtrlCreateLabel("", 1, 70, 55, 11) $copyhex = GUICtrlCreateButton("+", 55, 55, 15, 25) GUICtrlSetTip($copyhex, "Copy HEX to clipboard") GUICtrlCreateLabel("Dec Color", 1, 85, 55, 11) $dectext = GUICtrlCreateLabel("", 1, 100, 50, 11) $copydec = GUICtrlCreateButton("+", 55, 85, 15, 25) GUICtrlSetTip($copydec, "Copy DEC to clipboard") $buttoncolor = GUICtrlCreateButton("", 73, 55, 50, 57) $colorset1 = GUICtrlCreateButton("", 1, 115, 35, 35) $set1 = GUICtrlCreateButton("-", 1, 115, 15, 15) GUICtrlSetState($colorset1, $GUI_DISABLE) $colorset2 = GUICtrlCreateButton("", 43, 115, 35, 35) $set2 = GUICtrlCreateButton("-", 43, 115, 15, 15) GUICtrlSetState($colorset2, $GUI_DISABLE) $colorset3 = GUICtrlCreateButton("", 85, 115, 35, 35) $set3 = GUICtrlCreateButton("-", 85, 115, 15, 15) GUICtrlSetState($colorset3, $GUI_DISABLE) $colorset4 = GUICtrlCreateButton("", 1, 155, 35, 35) $set4 = GUICtrlCreateButton("-", 1, 155, 15, 15) GUICtrlSetState($colorset4, $GUI_DISABLE) $colorset5 = GUICtrlCreateButton("", 43, 155, 35, 35) $set5 = GUICtrlCreateButton("-", 43, 155, 15, 15) GUICtrlSetState($colorset5, $GUI_DISABLE) $colorset6 = GUICtrlCreateButton("", 85, 155, 35, 35) $set6 = GUICtrlCreateButton("-", 85, 155, 15, 15) GUICtrlSetState($colorset6, $GUI_DISABLE) GUISetState(@SW_SHOW) Toggle() While 1 Sleep(10) SwitchCheck() WEnd Func Toggle() $ToggleState = Not $ToggleState While $ToggleState Sleep(10) Get_Mouse_Pos() SwitchCheck() IfPressed() If Not $ToggleState Then Sleep(10) EndIf WEnd EndFunc Func SwitchCheck() $nMsg = GUIGetMsg() Switch $nMsg Case $close Exit Case $copyhex ClipPut($ColorVar) Case $copydec ClipPut($iColor) Case $copyrgb ClipPut($Red&","&$Green&","&$Blue) Case $set1 GUICtrlSetBkColor($colorset1, $ColorVar) Case $set2 GUICtrlSetBkColor($colorset2, $ColorVar) Case $set3 GUICtrlSetBkColor($colorset3, $ColorVar) Case $set4 GUICtrlSetBkColor($colorset4, $ColorVar) Case $set5 GUICtrlSetBkColor($colorset5, $ColorVar) Case $set6 GUICtrlSetBkColor($colorset6, $ColorVar) EndSwitch EndFunc Func Get_Mouse_Pos() GUISetState(@SW_SHOW) $Mpos = MouseGetPos() $Mpos_x = $Mpos[0] $Mpos_y = $Mpos[1] GUICtrlSetData($Label_x_value, $Mpos_x) GUICtrlSetData($Label_y_value, $Mpos_y) $iColor = PixelGetColor($Mpos[0], $Mpos[1]) $ColorVar = "0x" & Hex($iColor, 6) GUICtrlSetBkColor($buttoncolor, $ColorVar) GUICtrlSetData($hextext, $ColorVar) GUICtrlSetData($dectext, $iColor) $Red = _ColorGetRed($iColor) $Green = _ColorGetGreen($iColor) $Blue = _ColorGetBlue($iColor) GUICtrlSetData($RGB, $Red&","&$Green&","&$Blue) EndFunc Func IfPressed() If _IsPressed(26) Then Sleep(100) MouseMove(($Mpos_x + 0) , ($Mpos_y - 1), 0) EndIf If _IsPressed(28) Then Sleep(100) MouseMove(($Mpos_x + 0) , ($Mpos_y + 1), 0) EndIf If _IsPressed(25) Then Sleep(100) MouseMove(($Mpos_x - 1) , ($Mpos_y + 0), 0) EndIf If _IsPressed(27) Then Sleep(100) MouseMove(($Mpos_x + 1) , ($Mpos_y + 0), 0) EndIf EndFunc Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If $hWnd = $gui And $iMsg = $WM_NCHITTEST Then Return $HTCAPTION EndFunc
    1 point
  6. @AnRios If you see in the example provided by the Help file about HotKeySet(), you'll see that the fuction is set before all the functions (in most cases), so, put it before the For...Next loop in your script
    1 point
  7. jchd

    ColorFinder, Hex,Dec,RGB

    I've registered (and paid for a lifetime) for Capture and when I checked it out today I updated to the latest 9.2. The two other mentionned utilities are freeware. BTW even the 5.3 version should please you, albeit not offering the latest additions. I never pretended that today's Capture was free: worth trying but not free.
    1 point
  8. Yes, absolutely correct! But we can fix it with EnvGet (and of course, this requires admin). #RequireAdmin $systemdrive = EnvGet('systemdrive') DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1) $aArray = StringSplit(_getDOSOutput("bcdedit.exe"), @CRLF) DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 0) For $i = 1 To UBound($aArray) - 1 Select Case StringInStr($aArray[$i], 'Windows Boot Loader') And StringInStr($aArray[$i + 3], 'device partition=' & $systemdrive) And StringInStr($aArray[$i + 4], 'winload.efi') ConsoleWrite("UEFI mode" & @CRLF) Case StringInStr($aArray[$i], 'Windows Boot Loader') And StringInStr($aArray[$i + 3], 'device partition=' & $systemdrive) And StringInStr($aArray[$i + 4], 'winload.exe') ConsoleWrite("Legacy BIOS" & @CRLF) EndSelect Next Func _getDOSOutput($command, $wd = '') ; https://www.autoitscript.com/forum/topic/190249-get-result-of-shellexecute/ Local $text = '', $Pid = Run('"' & @ComSpec & '" /c ' & $command, $wd, @SW_HIDE, 2 + 4) While 1 $text &= StdoutRead($Pid, False, False) If @error Then ExitLoop Sleep(10) WEnd Return StringStripWS($text, 7) EndFunc ;==>_getDOSOutput
    1 point
  9. maybe this will do the trick https://www.autoitscript.com/forum/topic/180322-_isuefiboot%E2%80%94%E2%80%94detemine-the-current-os-is-boot-in-uefi-mode-or-not/
    1 point
  10. I use alias wrappers all the time in my matrix environment (EIgen4AutoIt, link in sig). Your code would fail if your $vReturnValue is declared anywhere else as a global (in your code, or in anyone else's code that includes yours, i.e., you cannot prevent this from happening). You have to declare it as a local inside the alias wrapper: Func F_Alias($p1, ByRef $p2, ByRef $p3, $p4 = Default) Local $vReturnValue = F_Original($p1, $p2, $p3, $p4) Return SetError(@error, @extended, $vReturnValue) EndFunc ;==>F_Alias To clarify, it fails in the sense that it overwrites the user's own contents of $vReturnvalue, if that exists. The alias func itself would work of course.
    1 point
  11. When running C# code through AutoIt, there are probably some restrictions over what you can do in pure C# code. In the examples with DotNet_LoadCScode(), only assemblies registered in the GAC are used. In contrast, assemblies not registered in the GAC are loaded with DotNet_LoadAssembly(). In a very short test, I also couldn't make your code work. But I've made this code work: using System; namespace SelectUser { public class Greetings { public static string Hello(string name) { return "Greetings " + name; } } } namespace CustomerDetails { class User { public string getCMDB(string cmp) { return SelectUser.Greetings.Hello(cmp); } } } #include "DotNetAll.au3" DotNet_LoadCScode( FileRead( "tst02.cs" ), "System.dll", 0, "tst02.dll" ) #include "DotNetAll.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() Local $oComErrFunc = ObjEvent( "AutoIt.Error", "ComErrFunc" ) Local $oNetCode = DotNet_LoadAssembly( "tst02.dll" ) Local $oUserDetails = DotNet_CreateObject( $oNetCode, "CustomerDetails.User" ) Local $sVariants = $oUserDetails.getCMDB('23680') ConsoleWrite( $sVariants ) EndFunc In Visual Studio, if you create a single assembly dll and load it with DotNet_LoadAssembly(), it might be the easiest. Run the AutoIt code in SciTE with F5 so you can see error messages in the console. In the code above I've added a COM error handler.
    1 point
  12. Subz

    Detect soft Installed

    Remember to use HKLM and HKLM64 when compiling as 32-bit otherwise you're only returning 32-bit hive, this should display all items that show up in Programs and Features: #include <Array.au3> Global $g_aSoftware[1][6] = [["Registry Hive", "DisplayName", "DisplayVersion", "Publisher", "UninstallString"]] ;~ Current User Hive _ProgramsAndFeaturesList("HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") ;~ 32-Bit HKEY_LOCAL_MACHINE Hive _ProgramsAndFeaturesList("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") ;~ 64-Bit HKEY_LOCAL_MACHINE Hive _ProgramsAndFeaturesList("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") _ArrayDisplay($g_aSoftware) Func _ProgramsAndFeaturesList($_sRegHive) Local $sRegEnumKey, $i = 1 While 1 $sRegEnumKey = RegEnumKey($_sRegHive, $i) If @error Then ExitLoop If Not RegRead($_sRegHive & "\" & $sRegEnumKey, "DisplayName") = "" Then $x = UBound($g_aSoftware) + 1 ReDim $g_aSoftware[$x][5] $x = UBound($g_aSoftware) - 1 $g_aSoftware[$x][0] = $_sRegHive & "\" & $sRegEnumKey $g_aSoftware[$x][1] = RegRead($g_aSoftware[$x][0], "DisplayName") $g_aSoftware[$x][2] = RegRead($g_aSoftware[$x][0], "DisplayVersion") $g_aSoftware[$x][3] = RegRead($g_aSoftware[$x][0], "Publisher") $g_aSoftware[$x][4] = RegRead($g_aSoftware[$x][0], "UninstallString") EndIf $i += 1 WEnd EndFunc
    1 point
  13. LarsJ, many thanks for going into detail and your new/updated examples. I will give it a try as soon as I have more leisure time.
    1 point
  14. Hi All, A co-worker complained that the side keys on his mouse (back and forward) were getting in the way. This script allows you to disable/re-purpose those buttons. Have only tested with a Delux M618 mouse. Haven't tested under Windows 10. This is the standalone version of the script so it will look ugly. The (cleaner) version we're using has a bunch of server calls and auto-update checks. Please report any problems here; even if you fix them yourself. Learning curve etc. #include <Misc.au3> #include <WinAPI.au3> #include <GuiComboBoxEx.au3> #include <ComboConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $gLastHotKeyPressed = ""; Last Hot key pressed Global $gLastHotKeyType = "" ; Last Hot key pressed type Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" Global Const $MOUSETRAPEVENT_DUMMY = "_MouseTrapEvent_Dummy" Global $currentEvent[2] Global $currentDownEvent[2] Global $lastEvent = "" Global $iLBUTTONDOWN = 0 Global $iRBUTTONDOWN = 0 Global $iMBUTTONDOWN = 0 Global $iXBUTTONDOWNNumber = 0 ; 1 or 2 xtra buttons Global $LRClickStatus = 0 Global $RLClickStatus = 0 Global $LRDrag = 0 Global $RLDrag = 0 Global $LMDrag = 0 Global $RMDrag = 0 Global $doubleClickTime = 400 Global $gLastMouseEventPressed = "" ; Added for HotKeySetEx UDF ;Global $gLastHotKeyPressed = ""; Last Hot key pressed Added for HotKeySetEx UDF ;Global $gLastHotKeyType = "" ; Last Hot key pressed type Added for HotKeySetEx UDF ; Mouse On event variables Global $a__MSOE_Events[1][1] Global $a__MSOE_DblClk_Data = __MouseTrapEvent_GetDoubleClickData() $doubleClickTime = $a__MSOE_DblClk_Data[0] + 50 Global $hKey_Proc Global $hM_Module Global $hM_Hook If _Singleton("MouseKeyModifier.exe", 1) = 0 Then MsgBox(0, "Warning", "Mouse Key Modifier is already running.") Exit EndIf TrayTip("MKM", "MouseKeyModifier is running. Click here for options", 30) Global $sHotKeyBack = "" Global $sHotKeyForward = "" Opt("TrayMenuMode", 1) Main() Func Main() HotKeySetEx("{XClick12}", "_FuncDummy", 1) Local $tMsg Local Static $aArray = _MouseKeyModifierTrayCreate() Local Static $cTraySettings = $aArray[1] Local Static $cTrayBehaviour = $aArray[2] Local Static $cTrayBehaviourStandard = $aArray[3] Local Static $cTrayBehaviourCustom = $aArray[4] Local Static $cTrayBehaviourStartup = $aArray[5] Local Static $cTrayQuickDisable = $aArray[6] Local Static $cTrayExit = $aArray[7] Local Static $sCurrentBehaviour = IniRead(@ScriptDir & "\config.ini", "DefaultBehaviour", "Hotkey", "Standard") If $sCurrentBehaviour = "Standard" Then TrayItemSetState($cTrayBehaviourStandard, 1) ElseIf $sCurrentBehaviour = "Custom" Then TrayItemSetState($cTrayBehaviourCustom, 1) _HotKeysSet() ElseIf $sCurrentBehaviour = "Disable" Then TrayItemSetState($cTrayQuickDisable, 1) _HotKeysQuickDisable(True) EndIf While 1 $tMsg = TrayGetMsg() Switch $tMsg Case $cTraySettings TraySetState(2) TrayItemSetState($cTraySettings, 4) _HotKeysUpdateSettingsGuiLoop($sCurrentBehaviour) TraySetState(1) Case $cTrayBehaviourStandard _HotKeysQuickDisable(False) TrayItemSetState($cTrayQuickDisable, 4) TrayItemSetState($cTrayBehaviourStandard, 1) TrayItemSetState($cTrayBehaviourCustom, 4) $sCurrentBehaviour = "Standard" Case $cTrayBehaviourCustom _HotKeysQuickDisable(False) TrayItemSetState($cTrayQuickDisable, 4) TrayItemSetState($cTrayBehaviourStandard, 4) TrayItemSetState($cTrayBehaviourCustom, 1) $sCurrentBehaviour = "Custom" _HotKeysSet() Case $cTrayQuickDisable If BitAND(TrayItemGetState($cTrayQuickDisable), 1) = 1 Then _HotKeysQuickDisable(True) TrayItemSetState($cTrayQuickDisable, 1) TrayItemSetState($cTrayBehaviourStandard, 4) TrayItemSetState($cTrayBehaviourCustom, 4) ElseIf BitAND(TrayItemGetState($cTrayQuickDisable), 4) = 4 Then _HotKeysQuickDisable(False) TrayItemSetState($cTrayQuickDisable, 4) If $sCurrentBehaviour = "Standard" Then TrayItemSetState($cTrayBehaviourStandard, 1) TrayItemSetState($cTrayBehaviourCustom, 4) ElseIf $sCurrentBehaviour = "Custom" Then TrayItemSetState($cTrayBehaviourStandard, 4) TrayItemSetState($cTrayBehaviourCustom, 1) _HotKeysSet() ElseIf $sCurrentBehaviour = "Disable" Then $sCurrentBehaviour = "Standard" TrayItemSetState($cTrayBehaviourStandard, 1) TrayItemSetState($cTrayBehaviourCustom, 4) EndIf EndIf Case $cTrayBehaviourStartup TraySetState(2) If BitAND(TrayItemGetState($cTrayBehaviourStandard), 1) = 1 Then IniWrite(@ScriptDir & "\config.ini", "DefaultBehaviour", "Hotkey", "Standard") MsgBox(0, "Success", "'Standard' set as default at startup.") ElseIf BitAND(TrayItemGetState($cTrayBehaviourCustom), 1) = 1 Then IniWrite(@ScriptDir & "\config.ini", "DefaultBehaviour", "Hotkey", "Custom") MsgBox(0, "Success", "'Custom' set as default at startup.") ElseIf BitAND(TrayItemGetState($cTrayQuickDisable), 1) = 1 Then IniWrite(@ScriptDir & "\config.ini", "DefaultBehaviour", "Hotkey", "Disable") MsgBox(0, "Success", "'Disabled' set as default at startup.") EndIf TraySetState(1) TrayItemSetState($cTrayBehaviourStartup, 4) Case $cTrayExit Exit EndSwitch WEnd EndFunc ;==>Main Func _CheckDeselect($cFrom, $cTo) Local $i For $i = $cFrom To $cTo GUICtrlSetState($i, 4) Next Return (1) EndFunc ;==>_CheckDeselect Func _CheckToString($cCheckWin, $cCheckCtrl, $cCheckAlt, $cCheckShift) Local $sReturn = "" Local $i If GUICtrlRead($cCheckWin) = 1 Then $sReturn &= "#" If GUICtrlRead($cCheckCtrl) = 1 Then $sReturn &= "^" If GUICtrlRead($cCheckAlt) = 1 Then $sReturn &= "!" If GUICtrlRead($cCheckShift) = 1 Then $sReturn &= "+" Return ($sReturn) EndFunc ;==>_CheckToString Func _ComboDeselect($hWnd, $cControl) ControlCommand($hWnd, "", $cControl, "SetCurrentSelection", "-1") Return (1) EndFunc ;==>_ComboDeselect Func _ControlDisable($cFrom, $cTo, $bDisable = True) Local $i For $i = $cFrom To $cTo If $bDisable = True Then GUICtrlSetState($i, 4 + 128) Else GUICtrlSetState($i, 4 + 64) EndIf Next Return (1) EndFunc ;==>_ControlDisable Func _FuncDummy() Return (1) EndFunc ;==>_FuncDummy Func _FuncHotKeyBack() Send($sHotKeyBack) Return (1) EndFunc ;==>_FuncHotKeyBack Func _FuncHotKeyForward() Send($sHotKeyForward) Return (1) EndFunc ;==>_FuncHotKeyForward Func _HotKeysAssign($sMouseButton, $sString) If $sMouseButton = "Back" Then HotKeySetEx("{XClick1}", "_FuncHotKeyBack", 1) HotKeySetEx("{XDClick1}", "_FuncHotKeyBack", 1) ElseIf $sMouseButton = "Forward" Then HotKeySetEx("{XClick2}", "_FuncHotKeyForward", 1) HotKeySetEx("{XDClick2}", "_FuncHotKeyForward", 1) EndIf Return (1) EndFunc ;==>_HotKeysAssign Func _HotKeysUpdateSettingsGuiLoop($sCurrentBehaviour) Local Static $aArray = _MouseKeyModifierSettingsGuiCreate() Local Static $cGui = $aArray[1] Local Static $cComboButton = $aArray[2] Local Static $cCheckWin = $aArray[3] Local Static $cCheckCtrl = $aArray[4] Local Static $cCheckAlt = $aArray[5] Local Static $cCheckShift = $aArray[6] Local Static $cComboCharacter = $aArray[7] Local Static $cCheckDisable = $aArray[8] Local Static $cButtonSave = $aArray[9] Local Static $cButtonCancel = $aArray[10] GUICtrlSetState($cCheckWin, 4) GUICtrlSetState($cCheckCtrl, 4) GUICtrlSetState($cCheckAlt, 4) GUICtrlSetState($cCheckShift, 4) _ComboDeselect($cGui, $cComboButton) _ComboDeselect($cGui, $cComboCharacter) Local $sStringToSave = "", $sButtonToSave = "" Local $iIndex GUISetState(@SW_SHOW, $cGui) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3, $cButtonCancel GUISetState(@SW_HIDE, $cGui) Return Case $cComboButton ConsoleWrite(GUICtrlRead($cComboButton) & @CRLF) _ComboDeselect($cGui, $cComboCharacter) _HotKeysUpdateSettingsGuiControls(GUICtrlRead($cComboButton), $cCheckWin, $cCheckCtrl, $cCheckAlt, $cCheckShift, $cComboCharacter) Case $cCheckDisable ConsoleWrite(GUICtrlRead($cCheckDisable) & @CRLF) If GUICtrlRead($cCheckDisable) = 1 Then _ControlDisable($cCheckWin, $cComboCharacter, True) _ComboDeselect($cGui, $cComboCharacter) ElseIf GUICtrlRead($cCheckDisable) = 4 Then _ControlDisable($cCheckWin, $cComboCharacter, False) EndIf Case $cButtonSave $sButtonToSave = GUICtrlRead($cComboButton) If $sButtonToSave = "" Then MsgBox(0, "Error", "You must select a button to modify.", 0, $cGui) ContinueLoop EndIf If GUICtrlRead($cCheckDisable) = 1 Then _HotKeysSaveToFile($sButtonToSave, "{EMPTY}") Else $sStringToSave = _CheckToString($cCheckWin, $cCheckCtrl, $cCheckAlt, $cCheckShift) $iIndex = _GUICtrlComboBox_GetCurSel($cComboCharacter) If $iIndex <> -1 Then $sStringToSave &= GUICtrlRead($cComboCharacter) If $sStringToSave = "" Then $sStringToSave = "{EMPTY}" _HotKeysSaveToFile($sButtonToSave, $sStringToSave) EndIf _CheckDeselect($cCheckWin, $cCheckShift) _CheckDeselect($cCheckDisable, $cCheckDisable) _ComboDeselect($cGui, $cComboButton) _ComboDeselect($cGui, $cComboCharacter) If $sCurrentBehaviour = "Custom" Then _HotKeysSet() EndSwitch WEnd EndFunc ;==>_HotKeysUpdateSettingsGuiLoop Func _HotKeysUpdateSettingsGuiControls($sButton, $cCheckWin, $cCheckCtrl, $cCheckAlt, $cCheckShift, $cComboCharacter) Local $sHotKey = _HotKeysGet($sButton) GUICtrlSetState($cCheckWin, 4) GUICtrlSetState($cCheckCtrl, 4) GUICtrlSetState($cCheckAlt, 4) GUICtrlSetState($cCheckShift, 4) If StringInStr($sHotKey, "#") <> 0 Then GUICtrlSetState($cCheckWin, 1) If StringInStr($sHotKey, "^") <> 0 Then GUICtrlSetState($cCheckCtrl, 1) If StringInStr($sHotKey, "!") <> 0 Then GUICtrlSetState($cCheckAlt, 1) If StringInStr($sHotKey, "+") <> 0 Then GUICtrlSetState($cCheckShift, 1) $sHotKey = StringReplace($sHotKey, "#", "") $sHotKey = StringReplace($sHotKey, "^", "") $sHotKey = StringReplace($sHotKey, "!", "") $sHotKey = StringReplace($sHotKey, "+", "") $sHotKey = StringLower($sHotKey) If $sHotKey <> "" Then If StringLen($sHotKey) > 1 Then Return (SetError(-1, 0, "")) ConsoleWrite($sHotKey & @CRLF) If Asc($sHotKey) < 97 Or Asc($sHotKey) > 122 Then Return (SetError(-2, 0, "")) EndIf Local $iIndex = _GUICtrlComboBox_SelectString($cComboCharacter, $sHotKey) Return (1) EndFunc ;==>_HotKeysUpdateSettingsGuiControls Func _HotKeysGet($sButton) Local $sHotKey = IniRead(@ScriptDir & "\config.ini", $sButton, "Hotkey", "*") If @error Or $sHotKey = "*" Then Return (SetError(-1, 0, "{EMPTY}")) Return ($sHotKey) EndFunc ;==>_HotKeysGet Func _HotKeysQuickDisable($bDisable = True) If $bDisable = True Then HotKeySetEx("{XClick1}", "_FuncDummy", 1) HotKeySetEx("{XClick2}", "_FuncDummy", 1) HotKeySetEx("{XDClick1}", "_FuncDummy", 1) HotKeySetEx("{XDClick2}", "_FuncDummy", 1) Else HotKeySetEx("{XClick1}", "") HotKeySetEx("{XClick2}", "") HotKeySetEx("{XDClick1}", "") HotKeySetEx("{XDClick2}", "") EndIf EndFunc ;==>_HotKeysQuickDisable Func _HotKeysSaveToFile($sMouseButton, $sString) IniWrite(@ScriptDir & "\config.ini", $sMouseButton, "Hotkey", $sString) Return (1) EndFunc ;==>_HotKeysSaveToFile Func _HotKeysSet() Local $sHotKey = _HotKeysGet("Back") If $sHotKey <> "{EMPTY}" Then _HotKeysAssign("Back", $sHotKey) $sHotKeyBack = $sHotKey $sHotKey = _HotKeysGet("Forward") If $sHotKey <> "{EMPTY}" Then _HotKeysAssign("Forward", $sHotKey) $sHotKeyForward = $sHotKey Return (1) EndFunc ;==>_HotKeysSet Func _MouseKeyModifierTrayCreate() Local $aArray[8] = [7] $aArray[1] = TrayCreateItem("Settings") $aArray[2] = TrayCreateMenu("Behaviour") $aArray[3] = TrayCreateItem("Standard", $aArray[2]) $aArray[4] = TrayCreateItem("Custom", $aArray[2]) TrayCreateItem("", $aArray[2]) $aArray[5] = TrayCreateItem("Set at Startup", $aArray[2]) $aArray[6] = TrayCreateItem("Quick disable") $aArray[7] = TrayCreateItem("Exit") Return ($aArray) EndFunc ;==>_MouseKeyModifierTrayCreate Func _MouseKeyModifierSettingsGuiCreate() Local $aArray[11] = [10] $aArray[1] = GUICreate("Settings", 276, 171) $aArray[2] = GUICtrlCreateCombo("", 20, 19, 236, 21, BitOR(0x0003, 0x00200000)) GUICtrlSetData(-1, "Back|Forward") $aArray[3] = GUICtrlCreateCheckbox("Win", 20, 54, 38, 20) $aArray[4] = GUICtrlCreateCheckbox("Ctrl", 65, 54, 38, 20) $aArray[5] = GUICtrlCreateCheckbox("Alt", 110, 54, 38, 20) $aArray[6] = GUICtrlCreateCheckbox("Shift", 155, 54, 41, 20) GUICtrlCreateLabel("", 20, 87, 237, 1, 0x10, -1) GUICtrlSetBkColor(-1, "-2") $aArray[7] = GUICtrlCreateCombo("", 207, 53, 50, 21, BitOR(0x0003, 0x00200000)) GUICtrlSetData(-1, _AlphabetGenerate()) $aArray[8] = GUICtrlCreateCheckbox("Disable button", 96, 100, 86, 20) $aArray[9] = GUICtrlCreateButton("Save", 20, 134, 76, 25) $aArray[10] = GUICtrlCreateButton("Cancel", 181, 134, 76, 25) Return ($aArray) EndFunc ;==>_MouseKeyModifierSettingsGuiCreate Func _AlphabetGenerate($sSeparator = "|") Local $sReturn = "" Local $i For $i = 97 To 122 $sReturn &= Chr($i) If $i <> 122 Then $sReturn &= $sSeparator Next ConsoleWrite($sReturn & @CRLF) Return ($sReturn) EndFunc ;==>_AlphabetGenerate Func HotKeySetEx($hotkey, $fun, $block = 1) ; default 1 block 0 intercept allow normal behavour and only for mouse events ; if the the hot key name contains the word CLICK then its a mouse button. If StringInStr(StringUpper($hotkey), "CLICK") > 0 Then ; Mouse hot key Dim $mouseHotKey ; local $mouseHotKey = $hotkey $mouseHotKey = StringReplace($mouseHotKey, "{", "") ; remove { } for mousetrap interface $mouseHotKey = StringReplace($mouseHotKey, "}", "") If $fun = "" Then _MouseTrapEvent($mouseHotKey) ; deregister Else _MouseTrapEvent($mouseHotKey, $fun, $block) ; 1 = block action and redirect to $fun EndIf Else HotKeySet($hotkey, $fun) ; normal AutoIt EndIf EndFunc ;==>HotKeySetEx Func getLastHotKey() ; call this in your function. Equivalent to @HotKeyPressed see example script setLastHotKey() Return $gLastHotKeyPressed ; EndFunc ;==>getLastHotKey Func getLastHotKeyType() ; call this in your function. Optional if you want type KEYBOARD or MOUSE setLastHotKey() Return $gLastHotKeyType ; EndFunc ;==>getLastHotKeyType Func setLastHotKey() ; Dim $sLastMouseEventPressed $sLastMouseEventPressed = __MouseTrapEvent_getLastMouseEventPressed() If $sLastMouseEventPressed <> "" Then $gLastHotKeyPressed = "{" & $sLastMouseEventPressed & "}" $gLastHotKeyType = "Mouse" Else $gLastHotKeyPressed = @HotKeyPressed $gLastHotKeyType = "Keyboard" EndIf Return $gLastHotKeyPressed ; EndFunc ;==>setLastHotKey ; #FUNCTION# ==================================================================================================== ; Name...........: _MouseTrapEvent ; Description....: Set an events handler (a hook) for Mouse device based on MouseSetEvent.udf. ; Syntax.........: _MouseTrapEvent($iEvent, $sFuncName = "", $hTargetWnd = 0, $iBlockDefProc = -1, $vParam = "") ; Parameters.....: $sEvent - The event to set, here is the list of ; supported event stings:- Case InSensitive! ; ; single clicks ; LClick - left button click (Primary) ; MClick - middle button click (Wheel click) ; RClick - right button click (Secondary) ; XClick1 - Xtra button 1 click (usually 'back navigaton') ; XClick2 - Xtra button 2 click (usually 'forward navigaton') ; double clicks ; LDClick - left button (Primary) ; MDClick - middle button (Wheel click) ; RDClick - right button (Secondary) ; XDClick1 - Xtra button 1 (usually 'back navigaton') ; XDClick2 - Xtra button 2 (usually 'forward navigaton') ; psuedo double clicks ('chords') - ; XClick12 - Xtra button 1&2 pressed at the same time. ; ; OTHER EVENTS you'll have to work out yourself eg mouse wheel scroll - see code. ; $sFuncName - [Optional] Function name to call when the event is triggered. ; If this parameter is empty string ("") or omited, the function will *unset* the $iEvent. ; ; $iBlockDefProc - [Optional] Defines if the up event should be blocked (actualy block the mouse action). ; If this parameter = ; -1 (default), user defined event function defines whether to block or not ; 1 (call function and block) ; 0 (call function and continue normal mouse behaviour). ; Note for all click and double click events the down event is always blocked to prevent hanging. ; ; ; $vParam - [Optional] Parameter to pass to the event function ($sFuncName). ; ; Return values..: Success - If the event is set in the first time, or when the event is unset properly, the return is 1, ; if it's set on existing event, the return is 2. ; Failure - Returns 0 on UnSet event mode when there is no set events yet. ; Author.........: credits G.Sandler (Mr)CreatoR ; Remarks........: ; 2) Blocking of $sFuncName function by window messages with commands ; such as "Msgbox()" can lead to unexpected behavior, the return to the system should be as fast as possible! ; Related........: MouseSetEvent.udf ; Link...........: ; Example........: Yes. ; =============================================================================================================== Func _MouseTrapEvent($iEvent, $sFuncName = "", $iBlockDefProc = -1, $vParam = "") Local $i Local $iUserEventCount = 0 Local $hTargetWnd = 0 ; not used $iEvent = StringReplace(StringUpper($iEvent), "CLICK", "Click") ; make case insensitive, to do Drag and Wheel and Up Down If $sFuncName = "" Then ;Unset Event If $a__MSOE_Events[0][0] < 1 Then Return 0 EndIf Local $aTmp_Mouse_Events[1][1] = [[0]] For $i = 1 To $a__MSOE_Events[0][0] ; keep events that don't match or internal dummy events used for double clicks. If $a__MSOE_Events[$i][0] <> $iEvent Or $a__MSOE_Events[$i][1] = $MOUSETRAPEVENT_DUMMY Then $aTmp_Mouse_Events[0][0] += 1 ReDim $aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0] + 1][5] $aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][0] = $a__MSOE_Events[$i][0] $aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][1] = $a__MSOE_Events[$i][1] $aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][2] = $a__MSOE_Events[$i][2] $aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][3] = $a__MSOE_Events[$i][3] $aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]][4] = $a__MSOE_Events[$i][4] If $a__MSOE_Events[$i][1] <> $MOUSETRAPEVENT_DUMMY Then $iUserEventCount += 1 EndIf EndIf Next $a__MSOE_Events = $aTmp_Mouse_Events If $iUserEventCount < 1 Then __MouseTrapEvent_Close() EndIf Return 1 EndIf ;First event If $a__MSOE_Events[0][0] < 1 Then ;Register callback $hKey_Proc = DllCallbackRegister("_MouseTrapEvent_MouseProc", "int", "int;ptr;ptr") $hM_Module = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0) $hM_Hook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE_LL, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hM_Module[0], "dword", 0) EndIf ;Search thru events, and if the event already set, we just (re)set the new function and other parameters For $i = 1 To $a__MSOE_Events[0][0] If $a__MSOE_Events[$i][0] = $iEvent Then If $sFuncName = $MOUSETRAPEVENT_DUMMY Then ; event already handled by user - no need for dummy event Return 1 EndIf $a__MSOE_Events[$i][0] = $iEvent $a__MSOE_Events[$i][1] = $sFuncName $a__MSOE_Events[$i][2] = $hTargetWnd $a__MSOE_Events[$i][3] = $iBlockDefProc $a__MSOE_Events[$i][4] = $vParam Return 2 EndIf Next $a__MSOE_Events[0][0] += 1 ReDim $a__MSOE_Events[$a__MSOE_Events[0][0] + 1][5] $a__MSOE_Events[$a__MSOE_Events[0][0]][0] = $iEvent $a__MSOE_Events[$a__MSOE_Events[0][0]][1] = $sFuncName $a__MSOE_Events[$a__MSOE_Events[0][0]][2] = $hTargetWnd $a__MSOE_Events[$a__MSOE_Events[0][0]][3] = $iBlockDefProc $a__MSOE_Events[$a__MSOE_Events[0][0]][4] = $vParam ; if double click event - attempt to register a dummmy event for single click if one dosen't exist- to prevent hanging If StringInStr($iEvent, "DClick") > 0 Then _MouseTrapEvent(StringReplace($iEvent, "DClick", "Click"), $MOUSETRAPEVENT_DUMMY, 0, 0) EndIf ; if multi button click event - attempt to register a dummmy single click event for each button - to prevent hanging If $iEvent = "XClick12" Then _MouseTrapEvent("XClick1", $MOUSETRAPEVENT_DUMMY, 0, 0) _MouseTrapEvent("XClick2", $MOUSETRAPEVENT_DUMMY, 0, 0) EndIf Return 1 EndFunc ;==>_MouseTrapEvent Func _MouseTrapEvent_Dummy() ; dummy function for unregistered click events of double clicks Return 0; EndFunc ;==>_MouseTrapEvent_Dummy Func _MouseTrapEvent_MouseProc($nCode, $wParam, $lParam) Local $info, $mouseData, $time, $timeDiff If $nCode < 0 Then $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndIf $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) $mouseData = DllStructGetData($info, 3) $time = DllStructGetData($info, 5) $timeDiff = $time - $currentEvent[1] Select Case $wParam = $WM_MOUSEMOVE ;Test for Drag in here If $currentEvent[0] <> "LDrag" Or $currentEvent[0] <> "LRDrag" Or $currentEvent[0] <> "LMDrag" Then If $iLBUTTONDOWN = 1 Then $currentEvent[0] = "LDrag" If $iRBUTTONDOWN = 1 Then $currentEvent[0] = "LRDrag" $LRDrag = 2 EndIf EndIf EndIf If $currentEvent[0] <> "RDrag" Or $currentEvent[0] <> "RMDrag" Or $currentEvent[0] <> "LRDrag" Then If $iRBUTTONDOWN = 1 Then $currentEvent[0] = "RDrag" EndIf EndIf If $currentEvent[0] <> "MDrag" Then If $iMBUTTONDOWN = 1 Then $currentEvent[0] = "MDrag" $currentEvent[1] = $time EndIf EndIf If $iRBUTTONDOWN = 1 And $iMBUTTONDOWN = 1 And $currentEvent[0] <> "RMDrag" Then $RMDrag = 2 $currentEvent[0] = "RMDrag" $currentEvent[1] = $time EndIf If $iLBUTTONDOWN = 1 And $iMBUTTONDOWN = 1 And $currentEvent[0] <> "LMDrag" Then $LMDrag = 2 $currentEvent[0] = "LMDrag" $currentEvent[1] = $time EndIf Case $wParam = $WM_MOUSEWHEEL If _WinAPI_HiWord($mouseData) > 0 Then ;Wheel Up $currentEvent[0] = "WheelUp" $currentEvent[1] = $time Else ;Wheel Down $currentEvent[0] = "WheelDown" $currentEvent[1] = $time EndIf Case $wParam = $WM_LBUTTONDOWN ;Register Button Down, check for Right/Left If $currentEvent[0] = "RClick" Then $LRClickStatus = 1 EndIf $iLBUTTONDOWN = 1 $currentDownEvent[0] = 'LClick' Case $wParam = $WM_LBUTTONUP ;Update $iLBUTTONDOWN $iLBUTTONDOWN = 0 $currentDownEvent[0] = '' ;Test for Right/Left Click If $RLClickStatus = 1 And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "RLClick" $currentEvent[1] = $time EndIf If $lastEvent = "LClick" And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "LDClick" $currentEvent[1] = $time EndIf ;Test for Drops If $currentEvent[0] = "LDrag" Then $currentEvent[0] = "LDrop" $currentEvent[1] = $time EndIf If $LRDrag = 2 And $iRBUTTONDOWN = 1 Then $LRDrag = 1 ; Denote $LRDrag as still having one button clicked, need to register the drop on RButton up EndIf If $LRDrag = 1 And $iRBUTTONDOWN = 0 Then $currentEvent[0] = "LRDrop" $currentEvent[1] = $time $LRDrag = 0 EndIf If $LMDrag = 2 And $iMBUTTONDOWN = 1 Then $LMDrag = 1 ; Denote $LMDrag as still having one button clicked, need to register the drop on MButton up EndIf If $LMDrag = 1 And $iMBUTTONDOWN = 0 Then $currentEvent[0] = "LMDrop" $currentEvent[1] = $time $LMDrag = 0 EndIf ;Set LClick if other events haven't fired If $currentEvent[1] <> $time Then $currentEvent[0] = "LClick" $currentEvent[1] = $time EndIf ;Negate $LRClickStatus $RLClickStatus = 0 Case $wParam = $WM_RBUTTONDOWN ;Register Button Down If $currentEvent[0] = "LClick" Then $RLClickStatus = 1 EndIf $iRBUTTONDOWN = 1 $currentDownEvent[0] = 'RClick' Case $wParam = $WM_RBUTTONUP ;Test for Left, Right, and Right Doubleclick here ;Update $iRBUTTONDOWN $iRBUTTONDOWN = 0 $currentDownEvent[0] = ''; ;Test for Right/Left Click If $LRClickStatus = 1 And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "LRClick" $currentEvent[1] = $time EndIf If $lastEvent = "RClick" And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "RDClick" $currentEvent[1] = $time EndIf ;Test for Drops If $currentEvent[0] = "RDrag" Then $currentEvent[0] = "RDrop" $currentEvent[1] = $time EndIf If $LRDrag = 2 And $iLBUTTONDOWN = 1 Then $LRDrag = 1 ; Denote $LRDrag as still having one button clicked, need to register the drop on RButton up EndIf If $LRDrag = 1 And $iLBUTTONDOWN = 0 Then $currentEvent[0] = "LRDrop" $currentEvent[1] = $time $LRDrag = 0 EndIf If $RMDrag = 2 And $iMBUTTONDOWN = 1 Then $RMDrag = 1 ; Denote $LMDrag as still having one button clicked, need to register the drop on MButton up EndIf If $RMDrag = 1 And $iMBUTTONDOWN = 0 Then $currentEvent[0] = "RMDrop" $currentEvent[1] = $time $RMDrag = 0 EndIf ;Set LClick if other events haven't fired If $currentEvent[1] <> $time Then $currentEvent[0] = "RClick" $currentEvent[1] = $time EndIf ;Negate $LRClickStatus $LRClickStatus = 0 Case $wParam = $WM_MBUTTONDOWN ;Register Button Down $iMBUTTONDOWN = 1 $currentDownEvent[0] = 'MClick' Case $wParam = $WM_MBUTTONUP ;Test for Middle Double Click here ;Update $iRBUTTONDOWN $iMBUTTONDOWN = 0 $currentDownEvent[0] = '' ;Test for Right/Left Click If $lastEvent = "MClick" And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "MDClick" $currentEvent[1] = $time EndIf ;Test for Drops If $currentEvent[0] = "MDrag" Then $currentEvent[0] = "MDrop" $currentEvent[1] = $time EndIf If $LMDrag = 2 And $iLBUTTONDOWN = 1 Then $LMDrag = 1 ; Denote $LRDrag as still having one button clicked, need to register the drop on RButton up EndIf If $LMDrag = 1 And $iLBUTTONDOWN = 0 Then $currentEvent[0] = "LMDrop" $currentEvent[1] = $time $LMDrag = 0 EndIf If $RMDrag = 2 And $iRBUTTONDOWN = 1 Then $RMDrag = 1 ; Denote $LMDrag as still having one button clicked, need to register the drop on MButton up EndIf If $RMDrag = 1 And $iRBUTTONDOWN = 0 Then $currentEvent[0] = "RMDrop" $currentEvent[1] = $time $RMDrag = 0 EndIf ;Set MClick if other events haven't fired If $currentEvent[1] <> $time Then $currentEvent[0] = "MClick" $currentEvent[1] = $time EndIf Case $wParam = $WM_XBUTTONDOWN $iXBUTTONDOWNNumber = _WinAPI_HiWord($mouseData) $currentDownEvent[0] = 'XClick' & $iXBUTTONDOWNNumber Case $wParam = $WM_XBUTTONUP Local $iXbuttonNumber = _WinAPI_HiWord($mouseData) If ($lastEvent = "XClick1" Or $lastEvent = "XClick2") And ($timeDiff) < $doubleClickTime Then If StringRight($lastEvent, 1) = $iXBUTTONDOWNNumber Then $currentEvent[0] = "XDClick" & $iXbuttonNumber $currentEvent[1] = $time Else $currentEvent[0] = "XClick12" ; both X buttons pressed simultaneously $currentEvent[1] = $time EndIf EndIf ;Set XClick if other events haven't fired If $currentEvent[1] <> $time Then If $iXbuttonNumber > 0 Then ;standard win 2000+ Xtra button pressed, append 1 or 2 to event name $currentEvent[0] = "XClick" & $iXbuttonNumber $currentEvent[1] = $time EndIf EndIf $iXBUTTONDOWNNumber = 0 ; reset $currentDownEvent[0] = '' EndSelect If $currentEvent[0] <> "" Then $lastEvent = $currentEvent[0] EndIf If __MouseTrapEvent_Remap($currentEvent[0]) = 1 Then Return 1; EndIf $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndFunc ;==>_MouseTrapEvent_MouseProc ; local function - not user callable Func __MouseTrapEvent_Remap($sEvent) ;search for event to block For $i = 1 To $a__MSOE_Events[0][0] ;Handle / block down events - done to prevent lock ups If $a__MSOE_Events[$i][0] = $currentDownEvent[0] Then Return 1; block handle event EndIf ; handle click - up events. If $a__MSOE_Events[$i][0] = $sEvent Then ;Handle events Local $iBlockDefProc_Ret = $a__MSOE_Events[$i][3] Local $sFuncName = $a__MSOE_Events[$i][1] $iRet = Call($sFuncName, $sEvent, $a__MSOE_Events[$i][4]) If @error Then $iRet = Call($sFuncName, $sEvent) If @error Then $iRet = Call($sFuncName) EndIf EndIf If $iBlockDefProc_Ret = -1 Then $iBlockDefProc_Ret = $iRet EndIf $currentEvent[0] = "" Return $iBlockDefProc_Ret ;Block default processing (or not :)) EndIf Next Return 0 ; don't bypass EndFunc ;==>__MouseTrapEvent_Remap ; call this from HotKeySetEx for mouse hotkeys. Func __MouseTrapEvent_getLastMouseEventPressed() For $i = 1 To $a__MSOE_Events[0][0] Local $sFuncName = $a__MSOE_Events[$i][1] ; If current event a registered hotkey then it will be the last pressed If $a__MSOE_Events[$i][0] = $currentEvent[0] And $sFuncName <> "" And $sFuncName <> $MOUSETRAPEVENT_DUMMY Then Return $currentEvent[0]; hot key found EndIf Next Return "" EndFunc ;==>__MouseTrapEvent_getLastMouseEventPressed ; called this to shut down without having to deregister all events. Func __MouseTrapEvent_Close() DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hM_Hook[0]) $hM_Hook[0] = 0 DllCallbackFree($hKey_Proc) $hKey_Proc = 0 ; clear all events Dim $a__MSOE_Events[1][1] EndFunc ;==>__MouseTrapEvent_Close Func __MouseTrapEvent_GetDoubleClickData() Local $aRet[3] = _ [ _ RegRead('HKEY_CURRENT_USER\Control Panel\Mouse', 'DoubleClickSpeed'), _ RegRead('HKEY_CURRENT_USER\Control Panel\Mouse', 'DoubleClickWidth'), _ RegRead('HKEY_CURRENT_USER\Control Panel\Mouse', 'DoubleClickHeight') _ ] Local $aGDCT = DllCall('User32.dll', 'uint', 'GetDoubleClickTime') If Not @error And $aGDCT[0] > 0 Then $aRet[0] = $aGDCT[0] EndIf Return $aRet EndFunc ;==>__MouseTrapEvent_GetDoubleClickData
    1 point
  15. Same here! I actually began some work on a UDF which is supposed to make creation of GUIs more easier, the plan was to make it layout based (just like GTK, but I did not know about it back then) so that I don't have to keep updating coordinates whenever I need to extend the GUI You can still find the work I started here: https://github.com/AutoIt4Life/GUIFrame/blob/master/GUIFrame.au3 It was called "Advanced Input Box", not extended! It is a very handy function that you have made, many scripters can make use of it. I see that you drew inspiration from IUP, I like IUP and use it a lot myself, it is one (and maybe only) of the sane libraries I have seen which can do cross-platform (native) GUIs in C I recall that @Xandy might have also made a similar UDF to get different kinds of paramateres/configurations via a GUI.
    1 point
  16. Totally true. ---- I also thought about making a GTK like layout system for AutoIt, but this is way TOO big work for my skills and my free time Anyway, I made something similar but very simpler (search the forum for my Extended InputBox UDF)
    1 point
  17. Yes, it can be done with JAVA object automation code.
    1 point
  18. HankHell

    Resizable Screenshot

    Opens up a semi-transparent resizable GUI window, then takes a screenshot of the size and location with PrintScreen #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <ScreenCapture.au3> HotKeySet("{PRINTSCREEN}", "Takepic") $gui = GUICreate("gui", 100, 100, @DesktopWidth /2, @DesktopHeight /2, BitOR($WS_POPUP, $WS_THICKFRAME), $WS_EX_TOPMOST) GUICtrlCreateLabel("", 0, 0, 100, 100, -1, $GUI_WS_EX_PARENTDRAG) WinSetTrans($gui, "", 150) GUISetState(@SW_SHOW) While 1 Sleep(100) $winsize = WinGetClientSize($gui) $winpos = WinGetPos($gui) WEnd Func Takepic() WinSetTrans($gui, "", 0) Local $randomness = Random(0, 999999) $randomnumber = Round($randomness) _ScreenCapture_Capture($randomnumber&".jpg", $winpos[0]+7, $winpos[1]+7, ($winsize[0]+$winpos[0]+6), ($winsize[1]+$winpos[1]+6)) Exit EndFunc
    1 point
  19. Luigi

    AutoUpdate

    Greetings... Yes... I know... Have a lot fo autoupdate's scripts... But I made one with two special options, not writed yet... self-update (ok) self install from any location (ok) run only in work folder (ok) check self version from repository (not ready) update all dependents files and check md5 file and/or version (not ready) work with remote drive (mount/unmount) (not ready) Tips... Create a folder: C:\Repository Save the scripts in folder C:\Repository Compile app.au3 Run from C:\Repository Close app.exe Copy to another folder... Run app.exe Recompile app.exe again... Re-run app.exe again... The script always run from C:\ProgramData\Luigi\app.exe... with the last version... AutoUpdate.au3 app.au3
    1 point
  20. Hi! I'm very frustrated that there is no GUI builder really easy et appreciable to use for AutoIt. I tried many of them : ISN is very slow and laggy Form Builder seemed excellent at first time, but also really buggy when you use it, and the code is SUPER MESSY (everything in one file, global variables everywhere...) and nearly impossible to enhance The only one that works well is Koda. But the problem is that when you modify something in your GUI, you must re-import and past it in your script. What one needs, is something like ISN (I mean seamless integration with your script), but with the ease of use of Koda. Or a bug-free Form Builder. All this to say that I have an idea, but I want to have your thoughts before starting work on this idea : What about creating an UDF that will parse a KXF (Koda) file and handles all the creation of the GUI. Something like Glade for GTK+ (GtkBuilder). Thanks
    1 point
  21. Jos

    random while??? - (Moved)

    @Garrik, Sad to see the zero effort approach. It won't get you far when you are unwilling to take direction and learn yourself, but that is your choice.
    1 point
  22. Array stuff: ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ArrayFindEmptyRows ; Description ...: Returns an array of indexes (similar to _ArrayFindAll) ready to feed straight into _ArrayDelete. ; Syntax ........: _ArrayFindEmptyRows(Const Byref $aArray[, $iStartRow = 1]) ; Parameters ....: $aArray - [in/out and const] The array to search for empty rows ; $iStartRow - [optional] an integer value. The index to start searching from ; Return values .: Success: - An array of indexes ; Failure - Empty string and @error flag as follows: ; 1 - $aArray is not an array ; 2 - $aArray contains one row ; 3 - $iStartRow is out of bounds ; 4 - No results (unable to find any blank rows) ; Author ........: Sam Coates ; =============================================================================================================================== Func _ArrayFindEmptyRows(ByRef Const $aArray, $iStartRow = 1) If Not IsArray($aArray) Then Return(SetError(-1, 0, "")) ;; Array isn't an array If UBound($aArray) < 2 Then Return(SetError(-2, 0, "")) ;; Array only contains one row Local $i, $ii Local $sResults = "" Local $aReturn Local $iArrayRows = UBound($aArray) - 1 ;; hold the number of rows If $iStartRow > $iArrayRows Then Return(SetError(-3, 0, "")) ;; Check if StartRow isn't out of bounds Local $iArrayColumns = UBound($aArray, 2) ;; hold the number of columns If @error = 2 Then $iArrayColumns = 1 ;; if error, then 1d array If $iArrayColumns = 1 Then ;; if 1d array For $i = $iStartRow To $iArrayRows ;; loop through rows If $aArray[$i] = "" Then $sResults &= $i & ";" ;; if its blank, save the index Next ElseIf $iArrayColumns > 1 Then ;; if 2d array For $i = $iStartRow To $iArrayRows ;; loop through rows For $ii = 0 To $iArrayColumns - 1 ;; loop through columns If $aArray[$i][$ii] <> "" Then ExitLoop ;; if a non-blank is found in any cell on a row, skip to next row If $ii = $iArrayColumns - 1 Then $sResults &= $i & ";" ;; if we reach the end of the columns and still havent found a non-blank, save the index Next Next EndIf If $sResults <> "" Then ;; if we made changes $sResults = StringTrimRight($sResults, 1) ;; strip the final semi-colon Else ;; if we made no changes Return(SetError(-4, 0, "")) ;; No results EndIf $aReturn = StringSplit($sResults, ";") ;; split the final string Return($aReturn) ;; return it EndFunc Example: $aArray = _GenRandomArray() $aArrayRemoveBlanks = _ArrayFindEmptyRows($aArray) _ArrayDelete($aArray, $aArrayRemoveBlanks) Func _GenRandomArray() Local $sFile = @TempDir & "\rnd.txt" Local $aArrayReturn[100000];[10] If FileExists($sFile) = 0 Then For $i = 1 To UBound($aArrayReturn) - 1 ;(Mod($i, 10) = 0) ? ($aArray[$i][0] = (_StringRandom(20, 4)) : ($aArray[$i][0] = "") ;; why won't this work lel If Mod($i, 10) <> 0 Then $aArrayReturn[$i] = _StringRandom(20, 4) Next _FileWriteFromArray($sFile, $aArrayReturn) Else _FileReadToArray($sFile, $aArrayReturn, 1, "|") EndIf Return ($aArrayReturn) EndFunc ;==>_GenRandomArray
    1 point
  23. This is a simple application I wrote that let's you modify the new file context menu. You can add and remove file types based on their extension. It shows a list of all the file types that are in the new menu based on their extension, and you can add and remove file types. ; Windows New File Context Menu Editor ; Author: gaxar77 #include "GuiConstants.au3" #include "GuiListBox.au3" Func _RegExistKey($sKeyname) RegEnumVal ($sKeyname, 1) Return (@error <= 0) EndFunc Func ShellNewKeyName($ext) Return "HKEY_CLASSES_ROOT\" & $ext & "\ShellNew" EndFunc Func MsgBoxCannotModifyRegistry() MsgBox(0, "Error", "Unable to modify registry.") EndFunc $gui = GUICreate("Windows New File Context Menu Editor", 465, 445) GuiSetState(@SW_SHOW, $gui) $fileTypesList = GUICtrlCreateList("", 10, 10, 400, 400) $newFileTypeTextBox = GuiCtrlCreateInput("", 10, 415, 350, 20) $newFileTypeButton = GuiCtrlCreateButton("Add", 365, 415, 45, 20) $removeFileTypeButton = GuiCtrlCreateButton("Remove", 415, 10, 45, 20) $keyIndex = 1 While True $keyName = RegEnumKey("HKEY_CLASSES_ROOT", $keyIndex) If @error <> 0 Then ExitLoop EndIf If StringLeft($keyName, 1) = "." Then If _RegExistKey(ShellNewKeyName($keyName)) Then _GuiCtrlListBox_AddString($fileTypesList, $keyName) EndIf EndIf $keyIndex += 1 WEnd While True $msg = GuiGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $newFileTypeButton $ext = GuiCtrlRead($newFileTypeTextBox) If StringLen($ext) < 2 or StringLeft($ext, 1) <> "." Then MsgBox(0, "Error", "Invalid Extension") Else $newKeyName = ShellNewKeyName($ext) RegWrite($newKeyName) RegWrite($newKeyName, "NullFile", "REG_SZ", "") If _RegExistKey($newKeyName) Then If _GuiCtrlListBox_FindString($fileTypesList, $ext) = -1 Then _GuiCtrlListBox_AddString($fileTypesList, $ext) EndIf Else MsgBoxCannotModifyRegistry() EndIf EndIf Case $removeFileTypeButton $ext = GuiCtrlRead($fileTypesList) If $ext <> "" Then $keyToRemove = ShellNewKeyName($ext) RegDelete($keyToRemove) If _RegExistKey($keyToRemove) Then MsgBoxCannotModifyRegistry() Else _GuiCtrlListBox_DeleteString($fileTypesList, _GuiCtrlListBox_FindString($fileTypesList, $ext)) EndIf Else MsgBox(0, "Error", "No Item Selected") EndIf EndSwitch WEnd
    1 point
  24. May it helps those who needed. #include <WinAPI.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _IsUEFIBoot ; Description ...: Detemine the Current OS is boot in UEFI mode or not ; Syntax ........: _IsUEFIBoot() ; Parameters ....: ; Return values .: True:OS is boot in UEFI ; False: OS is boot in Legacy BIOS ; Author ........: czyt ; Modified ......: ; Remarks .......: ; Related .......: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/DllCall~Information+Booted~UEFI~or~BIOS.txt ; Link ..........: ; Example .......: MsgBox(0,'(*^__^*) The OS is in UEFI Boot mode?',_IsUEFIBoot()) ; =============================================================================================================================== #include <WinAPI.au3> Func _IsUEFIBoot() Local Const $ERROR_INVALID_FUNCTION = 0x1 Local $hDLL = DllOpen("Kernel32.dll") If @OSBuild > 8000 Then Local $aCall = DllCall($hDLL, "int", "GetFirmwareType", "int*", 0) DllClose($hDLL) If Not @error And $aCall[0] Then Switch $aCall[1] ; 1 - bios 2- uefi 3-unknown Case 2 Return True Case Else Return False EndSwitch EndIf Return False Else DllCall($hDLL, "dword", "GetFirmwareEnvironmentVariableW", "wstr", "", "wstr", '{00000000-0000-0000-0000-000000000000}', "wstr", Null, "dword", 0) DllClose($hDLL) If _WinAPI_GetLastError() = $ERROR_INVALID_FUNCTION Then Return False Else Return True EndIf EndIf EndFunc ;==>IsUEFIBoot updated at 2021-08-13: fixed check err on windows 8 above OS
    1 point
×
×
  • Create New...