Jump to content

Key combination for new .au3 file


Recommended Posts

A free area on the desktop or in Explorer must be in focus.

 

APPSKEY --> N --> A

 

Appskey is a small icon depicting a pointer hovering above a menu, and it is typically found on the right side of the keyboard between the right Windows Logo Key and the right Control Key (or between the right Alt Key and the right Control Key).

 

Edited by Exit

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

Exit thanks for the answer, your recommendation was to create a shortcut and what I wanted to assign would not be that, the idea would be to create a combination to create .au3 in the same way that Ctrl+Shift+N does.

 

Link to comment
Share on other sites

As @Exit said, it will create a new file, but the problem is that the key sequence changes from one language to another.  Also on some circumstances, you could have 2 shortcut keys in the popup menu.  But you are lucky, I made some times ago this script, maybe you will like it :

#NoTrayIcon
#include <Constants.au3>
#include <WinAPISysWin.au3>
#include <File.au3>
#include <WinAPIFiles.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

HotKeySet ("^+{END}", _Exit)
HotKeySet ("^+a", _NewAu3)

While True
  Sleep (100)
WEnd

Func _NewAu3 ()
  Local $hWnd = WinGetHandle ("[ACTIVE]")
  Local $sClass = _WinAPI_GetClassName ($hWnd)
  Local $sCurrentDir, $sFileName
  Switch $sClass
    Case "Progman"
      $sCurrentDir = @DesktopDir
    Case "CabinetWClass"
      If Not ControlCommand ($hWnd, "", "Edit1", "IsVisible", "") Then
        ControlClick ($hWnd, "", "ToolbarWindow322", "left", 1, 10, 20)
        Sleep (800)
      EndIf
      $sCurrentDir = ControlGetText($hWnd, "", "Edit1")
      ConsoleWrite ($sCurrentDir & @CRLF)
      If Not FileExists($sCurrentDir) Then Return MsgBox ($MB_SYSTEMMODAL,"Error","Select one folder only")
    Case Else
      Return
  EndSwitch
  $sFileName = ShowGUI ()
  If @error Then Return
  $sFileName = MakeUniqueFileName ($sCurrentDir & "\" & $sFileName)
  ConsoleWrite ($sFileName & @CRLF)
  If FileExists (@WindowsDir & "\ShellNew\Template.au3") Then
    ConsoleWrite ("Template exists" & @CRLF)
    FileCopy (@WindowsDir & "\ShellNew\Template.au3", $sFileName)
  Else
    _FileCreate ($sFileName)
  EndIf

EndFunc

Func _Exit ()
  Exit
EndFunc

Func MakeUniqueFileName ($sFile)
  Local $sDrive, $sDir, $sFileName, $sExtension, $iCount = 1
  _PathSplit ($sFile, $sDrive, $sDir, $sFileName, $sExtension)
  $sFile = $sFileName
  While FileExists ($sDrive & $sDir & $sFileName & $sExtension)
    $iCount += 1
    $sFileName = $sFile & " (" & $iCount & ")"
  WEnd
  Return $sDrive & $sDir & $sFileName & $sExtension
EndFunc

Func ShowGUI ()
  Local Const $NEW_AU3_NAME = ".au3"
  Local $hGUI = GUICreate("", 300, 65, -1, -1, $WS_BORDER+$WS_POPUP)
  GUISetBkColor (0xFF0000)
  Local $Label = GUICtrlCreateLabel("FileName", 18, 24, 60, 17)
  GUICtrlSetColor (-1, 0xFFFFFF)
  GUICtrlSetFont (-1, 10)
  Local $Input = GUICtrlCreateInput("", 85, 22, 193, 21)
  GUISetState(@SW_SHOW)
  ControlSetText($hGUI, "", $Input, $NEW_AU3_NAME)
  Local $sFile

  While True
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
        GUIDelete ()
        Return SetError (1)
      Case $Input
        $sFile = GUICtrlRead ($Input)
        If StringLeft ($sFile, 1) = "." Then ContinueLoop
        GUIDelete ()
        Return $sFile
    EndSwitch
  WEnd
EndFunc

 

Link to comment
Share on other sites

Exit my language is Brazilian Portuguese so here the keys have changed, in my case it would be "Appskey> V> A" .. Nine I will use your script for now and research if I can directly assign the combination .. thanks for now

Link to comment
Share on other sites

1 hour ago, mutleey said:

and research if I can directly assign the combination

Don't loose your time. Do not search for Windows to do it, as you will not find anything.  My solution is probably the best you can find.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...