Jump to content

Search the Community

Showing results for tags 'accelerator'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 4 results

  1. I have a script that traps ^A and ^C accelerator keys via the GUISetAccelerators() function, and in the key handlers, I check to see if the focus is on the control that I want the keys to operate on. However, when I see that I'm not on that control, I want to pass the ^C and ^A back to the system so I can copy and past data on other controls. Here is my test script. I have it applying ^A and ^C only to the ListView control. When I put focus on the Input control, I want to be able to copy and paste normally. Opt("GUICloseOnESC", 1) ; ESC does not close the GUI Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Opt('MustDeclareVars', 1) OnAutoItExitRegister("ExitStageLeft") #include <Array.au3> #include <GuiListBox.au3> #include <GUIConstantsEx.au3> #include <ListBoxConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Global $hGUI, $iInput, $iList, $hInput, $hList _Main() Func _Main() Local $str, $parts $hGUI = GUICreate("", 250, 500) $iInput = GUICtrlCreateInput("2", 90, 5, 50, 20) $hInput = GUICtrlGetHandle($iInput) $iList = GUICtrlCreateListView("First Column ", 5, 30, 240, 470, $LBS_EXTENDEDSEL) $hList = GUICtrlGetHandle($iList) For $ndx = 1 To 100 $str = StringFormat("%s ABC", $ndx) Local $ret = _GUICtrlListView_AddItem($hList, $str) Next setupSpecialKeysHandlers() GUISetOnEvent($GUI_EVENT_CLOSE, "ExitStageLeft") GUISetState(@SW_SHOW) While (1) Sleep(250) WEnd EndFunc ;==>_Main Func ExitStageLeft() Exit (1) EndFunc ;==>ExitStageLeft Func setupSpecialKeysHandlers() Local $aAccelKeys[1][2] Local $ar, $parts, $key, $handler, $id ; Create a table of Special keys and their handlers $ar = StringSplit("", "") _ArrayAdd($ar, "{ENTER} - handle_ENTER_key ") _ArrayAdd($ar, "^a - handle_CTRL_A_key ") _ArrayAdd($ar, "^c - handle_CTRL_C_key ") ReDim $aAccelKeys[UBound($ar) - 1][2] ; Now, create $aAccelKeys array with the table data. ; For each entry, create a Dummy GUI and associate its ; ID with the special key. For $ndx = 1 To UBound($ar) - 1 $parts = StringSplit($ar[$ndx], "-", 2) $key = StringStripWS($parts[0], 8) $handler = StringStripWS($parts[1], 8) $id = GUICtrlCreateDummy() $aAccelKeys[$ndx - 1][0] = $key $aAccelKeys[$ndx - 1][1] = $id GUICtrlSetOnEvent($id, $handler) Next ; Dump the contents of the $aAccelKeys array For $ndx = 0 To UBound($aAccelKeys) - 1 logMsg("$aAccelKeys" _ & " [" & $ndx & "][0] = " & StringFormat("%-8s", $aAccelKeys[$ndx][0]) _ & " [" & $ndx & "][1] = " & $aAccelKeys[$ndx][1]) Next GUISetAccelerators($aAccelKeys) ; Setup the Special keys hooks EndFunc ;==>setupSpecialKeysHandlers Func logMsg($msg, $lnum = @ScriptLineNumber) ConsoleWrite("+++:" & $lnum & ": " & $msg & @CRLF) EndFunc ;==>logMsg Func handle_ENTER_key() logMsg("+++: handle_ENTER_key() entered") EndFunc ;==>handle_ENTER_key Func handle_CTRL_A_key() logMsg("+++: handle_CTRL_A_key() entered") If (Not isCtrlFocused($hList)) Then Return selectAllGLVItems() EndFunc ;==>handle_CTRL_A_key Func handle_CTRL_C_key() logMsg("+++: handle_CTRL_C_key() entered") If (isCtrlFocused($hList)) Then extractSelListViewGamesToClip() Else EndIf EndFunc ;==>handle_CTRL_C_key Func isCtrlFocused($hWnd) Local $hCtrl $hCtrl = ControlGetHandle($hGUI, "", ControlGetFocus($hGUI)) Return ($hWnd = $hCtrl) ? True : False EndFunc ;==>isCtrlFocused Func selectAllGLVItems() Local $hWnd = $hList, $iIndex For $iIndex = 0 To _GUICtrlListView_GetItemCount($hWnd) _GUICtrlListView_SetItemSelected($hWnd, $iIndex) Next EndFunc ;==>selectAllGLVItems Func extractSelListViewGamesToClip() Local $hWnd = $hList Local $iIndex, $item, $str, $sep = "" $str = "" For $iIndex = 0 To _GUICtrlListView_GetItemCount($hWnd) If (_GUICtrlListView_GetItemSelected($hWnd, $iIndex)) Then $item = _GUICtrlListView_GetItemText($hWnd, $iIndex) $str &= $sep & $item $sep = @CRLF EndIf Next ClipPut($str) logMsg("Copied " & StringLen($str) & " bytes to the Clipboard:" & @CRLF & $str) EndFunc ;==>extractSelListViewGamesToClip
  2. Hello everyone, I am trying to setup a GUI accelerator to close the utility as soon as esc is pressed. It works fine with hotkey but I want to make sure that the utility only exits if its window was active when esc was pressed. My utility has 2 buttons, Backup and Restore. The exit function checks if the button clicked was Backup or Restore and then displays an error message accordingly. If pressed backup, $button = 1 if pressed restore, $button = 2 the value of $button is set inside backup() or restore() functions Opt("GUIOnEventMode", 1) Opt("GUICoordMode", 1) $Form1 = GUICreate("Form1", 419, 124, 238, 194, $WS_DLGFRAME) $B_backup = GUICtrlCreateButton("Backup", 48, 40, 145, 41) $B_restore = GUICtrlCreateButton("Restore", 224, 40, 145, 41) ;================ > HotKeySet('{ESC}', "terminate") GUICtrlSetOnEvent($B_backup, "Backup") GUICtrlSetOnEvent($B_restore, "Restore") GUISetState(@SW_SHOW) Dim $accelKey[1][2] = [["{ESC}", terminate()]] GUISetAccelerators($accelKey) While 1     Switch GUIGetMsg()         Case $GUI_EVENT_CLOSE             Exit     EndSwitch WEnd Exit function: func terminate() Do     $msg = GUIGetMsg() Until $msg <> 0 While 1         If $button = 1 Then             ProcessClose("robocopy.exe")             MsgBox(16, "Abort!", "Backup Aborted!")             exit         ElseIf $button = 2 Then             ProcessClose("robocopy.exe")             MsgBox(16, "Abort!", "Restore Aborted!")             exit         Else             While 1                 For $i = 3 To 1 Step -1                     SplashTextOn("Closing Utility...", $i, 130, 54, -1, -1, 0, "Calibri", "", 900)                     Sleep(1000)                 Next                 ExitLoop             WEnd             SplashOff()             Exit Endif WEnd What am I doing wrong here? The utility closes as soon as it launches with Splash text.
  3. Hello! Is anybody know easy way to assign accelerator for checkbox? It is easy to work with buttons, but with checkbox button it doesn't work in my case. Thank you for any assistance.
  4. I'm a bit confused about accelerator keys and checkboxes. 1) See my code below: Is this the correct way how I put them in the script? (First: reading the ini file to see if the checkbox is enabled then setting the checkbox state before "GUISetState(@SW_SHOW" Second: After having created the GUI, if the status of the checkbox changes disable or enable the accelerator keys (Case $CB3) Third: when the GUI is closed, write checkbox status in ini) 2) I've read in a reply of Melba in another topic that in order to disable the accelerator keys (in my case {enter}) It is needed to Send a CR to the control "ControlSend($hGUI, "", $hFocus, @CR)" I don't know why this is, I haven't understand it very well and I don't know where to put it in my case. (but it seems to work fine in my code without it) 3) In my code below I have inserted only 2 buttons (search and images) In reality I have a lot more buttons. The code between ";Focus and Accelerator key" and ";END Focus and Accelerator key" is almost the same in all Cases. The only thing different is the value of $focus. The value of $focus is the Case name. Is there a way to put this code in an external function to avoid multiplying the code many times? (I noted in the help file that there is not a GUI ID in GUICtrlSetState and GUISetAccelerators) #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <String.au3> #include <GuiButton.au3> #include <Constants.au3> #include <EditConstants.au3> HotKeySet("^4", "SearchMenu") While 1 Sleep(10000) WEnd Func SearchMenu() ;========GUI============= $MyFile = "d:\temp\RW-autoit.ini" Global $url $Form5= GUICreate("Search Menu", 345, 140, @DesktopWidth*0.65, @DesktopHeight*0.21) $RWSearch = GuiCtrlCreateEdit("", 16, 10, 270, 50) $textGoogle = GUICtrlCreateLabel("Google:", 20, 90, 100, 20) $bsearch = GUICtrlCreateButton("Search", 110, 90, 60, 20) $bimages = GUICtrlCreateButton("Images", 175, 90, 60, 20) $CB3 = GUICtrlCreateCheckbox("Enter=Send (^Enter=Enter)", 110, 120, 145, 20) If FileExists($MyFile) Then $State = IniRead($MyFile,"CheckBox","CB3",0) If $State == 1 Then GUICtrlSetState(($CB3), BitOr($GUI_ENABLE, $GUI_CHECKED)) Else GUICtrlSetState(($CB3), BitOr($GUI_ENABLE, $GUI_UNCHECKED)) EndIf $Focus = IniRead($MyFile,"Focus","Button",0) Else GUICtrlSetState(($CB3, BitOr($GUI_ENABLE, $GUI_CHECKED)) $Focus = "bsearch" EndIf GUISetState(@SW_SHOW) ;========END GUI========== Local $aAccelKeys[1][2] = [["{ENTER}", eval($focus)]] If _GUICtrlButton_GetCheck($CB3) Then GUISetAccelerators($aAccelKeys) Global $EnterSubmit = true Else GUISetAccelerators(0) Global $EnterSubmit = false EndIf ; Set the Default Key GUICtrlSetState(eval($focus), $GUI_DEFBUTTON) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ; write status checkboxes in ini If FileExists($MyFile) Then If _GUICtrlButton_GetCheck($CB3) Then IniWrite($MyFile, "CheckBox", "CB3", 1) Else IniWrite($MyFile, "CheckBox", "CB3", 0) EndIf EndIf ; write focus in ini IniWrite($MyFile, "Focus", "Button", $Focus) GuiDelete($Form5) ExitLoop Case $CB3 If _GUICtrlButton_GetCheck($CB3) Then GUISetAccelerators($aAccelKeys) Global $EnterSubmit = true Else GUISetAccelerators(0) Global $EnterSubmit = false EndIf Case $bsearch $RWSearch1 = GUICtrlRead($RWSearch) $RWSearch2 = StringRegExpReplace($RWSearch1, "(\s+)", "+") ;Focus and Accelerator key $focus = "bsearch" GUICtrlSetState(eval($focus), $GUI_DEFBUTTON) If $EnterSubmit then GUISetAccelerators($aAccelKeys) Else GUISetAccelerators(0) Endif ;End Focus and Accelerator key $url = "https://www.google.com/search?q=" & $RWSearch2 SearchMenuExec() Case $bimages $RWSearch1 = GUICtrlRead($RWSearch) $RWSearch2 = StringRegExpReplace($RWSearch1, "(\s+)", "+") ;Focus and Accelerator key $focus = "bsearch" GUICtrlSetState(eval($focus), $GUI_DEFBUTTON) If $EnterSubmit then GUISetAccelerators($aAccelKeys) Else GUISetAccelerators(0) Endif ;End Focus and Accelerator key $url = "http://images.google.com/images?hl=en&q=" & $RWSearch2 SearchMenuExec() EndSwitch WEnd EndFunc ;==>SearchMenu Func SearchMenuExec() ClipPut($url) ShellExecute($url) EndFunc ;==>SearchMenuExec
×
×
  • Create New...