AlbatrosXL > 2019-10-02 14:53
Jean Lalonde > 2019-10-02 15:17
(2019-10-02 14:53)AlbatrosXL Wrote: Is there a possibility to define a HotKey which opens immediately a QAP-Window to add a hotstring ?
(2019-10-02 14:53)AlbatrosXL Wrote: P.S: I thought about writing an AHK-skript which is called if the Hotkey is pressed and then starts the following sequence
AlbatrosXL > 2019-10-03 13:03
AlbatrosXL > 2019-10-03 17:02
Jean Lalonde > 2019-10-03 17:07
AlbatrosXL > 2019-10-04 13:12
; **************************
; * Quick access for Hotstrings for QAP 9.x
; * Adaptions for QAP 10.x maybe in rows.marked with !QAP!
; *
; * The script opens a Autohotkey input window which
; * ask for hotstring trigger (mandatory entry)
; * ask for a shortname (not mandatory: if empty, then = Hottrigger
; * ask for the hotstring text (mandatory)
; If clipboard content exist - then the clipboard content is taken
;
; * pressing okay starts the transfer to QAP
; * pressing cancel - stops the procedure
; *
; * Additional informations
; * Script needs in QAP a subfolder called Hotstrings
; * the subfolder is below the Main-folder (Main > Hotstrings)
; * !! Take Care of the writing !!
; * Subfolder can have a different name, then change the value
; * below at SubMenuHotstring
; -------------------------------
; * Global variables
; V01: initial version
; V02: improvement on speed - replacement of sleeps..
SubMenuHotstring = Main > Hotstrings ;String for selection of Favorite parent menu
;where the hotstrings are stored
PrgError = 0 ;prg-variable Error = 0 -> no error detected
HotTrigger := ""
ShortName := ""
HotString := ""
ErrorSection = "Main"
; -------------------------------
;press Ctrl+C to copy marked text into clipboard
Send, {Ctrl Down}c{Ctrl up}
ShowGui:
; -------------------------------
; ** GUI for Enter of Hotstring-Trigger & Hotstring
Gui, Add, Text, x10 y20 ,TxtShortCut (mandatory) ;Text
Gui, Add, Text, x250 y20 ,Short name
Gui, Add, Edit, vHotTrigger x10 y40 w200 r1 ;Inputfield for HotStringTrigger
Gui, Add, Edit, vShortName x250 y40 w200 r1
Gui, Add, Text, x10 y80, Txtstring (mandatory)
Gui, Add, Edit, vHotString x10 y100 w450 r10, %Clipboard% ;Example text; later replac. by clipb.
Gui, Add, Button, w100 x10 y250 Default, Ok
Gui, Add, Button, w100 x350 y250 ,Cancel
Gui, Show, AutoSize, Quick-Hotkey-Inserten for QAP
return
;
; -------------------------------
; PROGRAMM-FLOW STARTS HERE FOR OKAY-SELECTION------
ButtonOK: ;Button okay pressed
; -------------------------------
Gui, Submit ;store values of edit fields in variables
gosub, CheckEntryValues ;do a plausability check on entry fields
if PrgError = 1
goto ShowGui
gosub, Call_QAP_SettingWindow ;open QAP and select SubMenu for Hotstrings
gosub, Enter_HotStringValues_Into_QAP ;put values into QAP
Gui, Destroy ;release RAM
ExitApp
; ---- PRG - END -----------------
; #########################################
; SubRoutines
; -------------------------------
GuiClose: ;Close or Cancel button pressed
; -------------------------------
Gui, Destroy ;close window
ExitApp ;exit
; -------------------------------
ButtonCancel:
; -------------------------------
Gui, Destroy
ExitApp
; -------------------------------
ErrorOccured:
; -------------------------------
MsgBox, 48, Error, An Error occured in section %ErrorSection%
Gui, Destroy
ExitApp
; -------------------------------
CheckEntryValues:
; -------------------------------
; Do a Plausability check, no empty fields are allowed
PrgError = 0
If (HotTrigger = "" ) ;HotTrigger value exist ?
PrgError = 1 ;no -> Error & Exit
If (HotString = "" ) ;HotString exist ?
PrgError = 1 ;no -> Error & Exit
If (ShortName = "") ;if no ShortName is entered, then
ShortName := HotTrigger ;use the value of the HotTrigger
If PrgError = 1
{
MsgBox, 16, Warning, No empty fields allowed`nPlease try again
}
Gui, Destroy
return
; -------------------------------
Call_QAP_SettingWindow:
; -------------------------------
; *** Open QAP-Setting window by Shift+Ctr+S
; *** select the submenu where the Hotstrings are stored
; *** press then the ADD-Button to open the Add Fav. window
; *** select within the Add Fav-window: Snippet & press Continue
; *** -> Hotstring entry window is open
; *** end
ErrorSection := "Call_QAP_SettingWindow - Main"
Send, {Shift Down}{Ctrl Down}S{Shift up}{Ctrl up} ;!QAP! opening QAP-Setting window
; *** press the Add-Button and select Snippet and continue
WinWaitActive, ahk_class JeanLalonde.ca,,2 ;!QAP!
If ErrorLevel = 0 ;if Win exist
{
winactivate ;activates the SettingWindow
Control, ChooseString, %SubMenuHotstring%, ComboBox1 ;!QAP! select the menu where to store the hotstring
ControlClick, static2 ;!QAP! click on the ADD-Button
}
else
goto, ErrorOccured
WinWaitActive, Add Favorite Type - Quick Access Popup,,2 ;!QAP! - if title changed
If ErrorLevel = 0
{
WinActivate
ControlClick, Button8 ;!QAP! select the snippet-radiobutton
ControlClick, Button14 ;!QAP! press Continue
}
else ;Window not appeared - so inform user and close the script
{
ErrorSection := "Call_QAP_SettingWindow - Add Favorite"
goto, ErrorOccured
}
return
; -------------------------------
Enter_HotStringValues_Into_QAP:
; -------------------------------
; *** Snippet-Window is open and add the values to the entry-fields
ErrorSection := "Enter_HotStringValues_Into_QAP: Add Favorite"
WinWaitActive, Add Favorite: Snippet,,2 ;!QAP! check if Snippet entry window exist
If ErrorLevel = 0
{
ControlSetText, Edit1, %ShortName% ;!QAP! enter ShortName for Hotstring
ControlSetText, Edit2, %Hotstring% ;!QAP! enter HotString
ControlFocus, SysTabControl321, Add Favorite: Snippet ;!QAP! init TAB-Change to Menu options
ControlSend, SysTabControl321, {Ctrl Down}{Tab}{Ctrl Up},
ControlClick, Button6 ;!QAP! Press Change button for Hotstring-Trigger
}
else
goto, ErrorOccured
ErrorSection := "Enter_HotStringValues_Into_QAP: Change Hotstring"
WinWaitActive, Change hotstring - Quick,,2 ;!QAP! check if HotTrigger-Window is open
If ErrorLevel = 0
{
ControlSetText,Edit1, %HotTrigger% ;!QAP! enter Hottrigger string
ControlClick, Button5 ;!QAP! press okay button
}
else
goto, ErrorOccured
return
Jean Lalonde > 2019-10-04 13:33
Jean Lalonde > 2019-10-04 13:48
AlbatrosXL > 2019-10-04 13:53
(2019-10-04 13:48)Jean Lalonde Wrote: I looked at your script. Well done. But as it is, it could not run on v10. I did not make it run yet but I saw that at least these changes would be required for v10:
Line 130: In QAP v10, the default shortcut for Customize window (aka Settings) for new installations is now Shift+Ctrl+C. (it remains Shift+Ctrl+S if you upgraded from a previous version). And users could change it afterward, of course.
Lines 146/147/180: button control numbers changed in the new Customize window.
I don't say you need to do it but other users who would like to use it would have to change these lines.
Jean Lalonde > 2019-10-04 13:58