Custom KeyStroke With Drop Down List Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Thenatan
Posts: 38
Joined: 01 Sep 2018, 16:28

Custom KeyStroke With Drop Down List

10 Sep 2018, 03:09

Hey Folks
As The Title Says , I Try To Make A 4 Drop Down List To Make A Custom Keystroke.
The Idea Is To Build Keystrokes With DDL And Run The Program In List 4 With Key Stroke That Selected in 3 DDLs.
Know It Could Be Easy If Some Of You Guys Shows Some Lights
Thanks Mates
Here Is An Image Example
Image
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 04:14

Try this:
  • attempt to customize keystrokes with hotkeys
  • to cancel hotkeys, reload the script with F5
  • DDL3 (letters) is not functional

Code: Select all

#NoEnv
#SingleInstance, Force

    List := ["", "^", "+", "!"]
    Gui, Add, DropDownList, xm  w50 vDDL1 AltSubmit, None||Ctrl|Shift|Alt
    Gui, Add, DropDownList, x+0 w50 vDDL2, 0||1|2|3|4|5|6|7
    Gui, Add, DropDownList, x+0 w50 vDDL3, Aa||Bb|Cc|Dd|Ee|Ff|Gg|Hh
    Gui, Add, DropDownList, x+0 w50 vDDL4, One||Two|Three|Four|Five|Six|Seven|Eight
    Gui, Add, Button, xm w200, Submit this hotkey
    Gui, Show

Return ; end of auto-execute section

GuiClose:
GuiEscape:
ExitApp

F5:: Reload



;-------------------------------------------------------------------------------
ButtonSubmitThisHotkey:
;-------------------------------------------------------------------------------
    Gui, Submit, NoHide
    KeyName := List[DDL1] DDL2
    Hotkey, %KeyName%, %DDL4%

Return



One:
Two:
Three:
Four:
Five:
Six:
Seven:
Eight:
    MsgBox, %A_ThisLabel%
Return
I hope that helps.
User avatar
Thenatan
Posts: 38
Joined: 01 Sep 2018, 16:28

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 04:31

wolf_II wrote:Try this:
  • attempt to customize keystrokes with hotkeys
  • to cancel hotkeys, reload the script with F5
  • DDL3 (letters) is not functional

Code: Select all

#NoEnv
#SingleInstance, Force

    List := ["", "^", "+", "!"]
    Gui, Add, DropDownList, xm  w50 vDDL1 AltSubmit, None||Ctrl|Shift|Alt
    Gui, Add, DropDownList, x+0 w50 vDDL2, 0||1|2|3|4|5|6|7
    Gui, Add, DropDownList, x+0 w50 vDDL3, Aa||Bb|Cc|Dd|Ee|Ff|Gg|Hh
    Gui, Add, DropDownList, x+0 w50 vDDL4, One||Two|Three|Four|Five|Six|Seven|Eight
    Gui, Add, Button, xm w200, Submit this hotkey
    Gui, Show

Return ; end of auto-execute section

GuiClose:
GuiEscape:
ExitApp

F5:: Reload



;-------------------------------------------------------------------------------
ButtonSubmitThisHotkey:
;-------------------------------------------------------------------------------
    Gui, Submit, NoHide
    KeyName := List[DDL1] DDL2
    Hotkey, %KeyName%, %DDL4%

Return



One:
Two:
Three:
Four:
Five:
Six:
Seven:
Eight:
    MsgBox, %A_ThisLabel%
Return
I hope that helps.

Thanks You Wolf_II , Works Perfectly
So Is There Any Commands To Associate The DDL Number 3 , And One Thing Is There Any Chance To Save In An Text File So Gui Always Call That When I Launceh The Script?
Thanks In Advance
User avatar
Thenatan
Posts: 38
Joined: 01 Sep 2018, 16:28

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 04:35

And One Thing , For Example , Where I Should Put The "Run" Command In Script Like One : Run, WinRAR.exe ,C:\Program Files\WinRAR\,
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 04:51

regarding DDL3: I have not yet worked much with hotkey combinations (done with &). This looks promising, but might be severely flawed.

Try this and hope for the best:

Code: Select all

#NoEnv
#SingleInstance, Force

    List := ["", "^", "+", "!"]
    Gui, Add, DropDownList, xm  w50 vDDL1 AltSubmit, None||Ctrl|Shift|Alt
    Gui, Add, DropDownList, x+0 w50 vDDL2, 0||1|2|3|4|5|6|7
    Gui, Add, DropDownList, x+0 w50 vDDL3, Aa||Bb|Cc|Dd|Ee|Ff|Gg|Hh
    Gui, Add, DropDownList, x+0 w50 vDDL4, One||Two|Three|Four|Five|Six|Seven|Eight
    Gui, Add, Button, xm w200, Submit this hotkey
    Gui, Show

Return ; end of auto-execute section

GuiClose:
GuiEscape:
ExitApp

F5:: Reload



;-------------------------------------------------------------------------------
ButtonSubmitThisHotkey:
;-------------------------------------------------------------------------------
    Gui, Submit, NoHide
    KeyName := List[DDL1] DDL2 " & " SubStr(DDL3, 2)
    Hotkey, %KeyName%, %DDL4%

Return



One:
Two:
Three:
Four:
Five:
Six:
Seven:
Eight:
    MsgBox, %A_ThisLabel%
Return
I hope that helps.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 04:54

regarding WinRar: Try this:

Code: Select all


One:
    Run, WinRAR.exe, C:\Program Files\WinRAR\
Return

Two:
Three:
Four:
Five:
Six:
Seven:
Eight:
    MsgBox, %A_ThisLabel%
Return
I hope that helps. untested.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 04:56

regarding Writing to a text file:
I recommend using IniWrite and IniRead.

I will prepare something for your needs and post again.
Last edited by wolf_II on 10 Sep 2018, 04:59, edited 1 time in total.
User avatar
Thenatan
Posts: 38
Joined: 01 Sep 2018, 16:28

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 04:57

Excellent , Works Flawlessly Thanks A Ton :bravo:
User avatar
Thenatan
Posts: 38
Joined: 01 Sep 2018, 16:28

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 04:59

wolf_II wrote:regarding Writing to a text file:
I recommend using IniWrite and IniRead.
Thanks MAan , I've Some Examples To Store The Inputs In An INI File
User avatar
Thenatan
Posts: 38
Joined: 01 Sep 2018, 16:28

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 05:00

wolf_II wrote:regarding Writing to a text file:
I recommend using IniWrite and IniRead.

I will prepare something for your needs and post again.
Wow That Sounds Awesome , Much Appreciated Wolf :thumbup:
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 05:12

I need more info: how do you want to handle GuiClose? Should it exit the script? Currently it does, but with the fancy new Ini-stuff, it might be better not to do so.
Also: F5 to reload is a workaround, Do you want to keep it?


Progress so far: IniWrite included

Code: Select all

#NoEnv
#SingleInstance, Force

    IniFile := A_ScriptDir "\config.ini"

    List := ["", "^", "+", "!"]
    Gui, Add, DropDownList, xm  w50 vDDL1 AltSubmit, None||Ctrl|Shift|Alt
    Gui, Add, DropDownList, x+0 w50 vDDL2, 0||1|2|3|4|5|6|7
    Gui, Add, DropDownList, x+0 w50 vDDL3, Aa||Bb|Cc|Dd|Ee|Ff|Gg|Hh
    Gui, Add, DropDownList, x+0 w50 vDDL4, One||Two|Three|Four|Five|Six|Seven|Eight
    Gui, Add, Button, xm w200, Submit this hotkey
    Gui, Show

Return ; end of auto-execute section

GuiClose:
ExitApp



;-------------------------------------------------------------------------------
ButtonSubmitThisHotkey:
;-------------------------------------------------------------------------------
    Gui, Submit, NoHide
    KeyName := List[DDL1] DDL2 " & " SubStr(DDL3, 2)
    Hotkey, %KeyName%, %DDL4%
    IniWrite, %DDL4%, %IniFile%, Hotkeys, %KeyName%

Return
User avatar
Thenatan
Posts: 38
Joined: 01 Sep 2018, 16:28

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 05:17

I Find A Script Which Stores All Edit Box Contents In A Text File , When I Press Close , And Call It When I Open it Again.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 05:26

Thenatan wrote:I Find A Script Which Stores All Edit Box Contents In A Text File , When I Press Close , And Call It When I Open it Again.
I don't understand the meaning of this sentence. Is this related to the current topic "Custom KeyStroke With Drop Down List" :?:
User avatar
Thenatan
Posts: 38
Joined: 01 Sep 2018, 16:28

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 05:35

wolf_II wrote:
Thenatan wrote:I Find A Script Which Stores All Edit Box Contents In A Text File , When I Press Close , And Call It When I Open it Again.
I don't understand the meaning of this sentence. Is this related to the current topic "Custom KeyStroke With Drop Down List" :?:
how do you want to handle GuiClose? Should it exit the script? Currently it does, but with the fancy new Ini-stuff, it might be better not to do so
I Tried To Answer , Your Question , Sorry Mate , I Think I Mislead You .
I Tried To Say , I Find An Example Which Calls Those Stored Commands In A INI File , And Call Them Back.
It Stores Files Right When I Press GuiClose , And No Need To Do The Commands Again , Would BE Great If We Get ASame Script With This One.

For Example In DDl Boxes Last Time Show , Ctrl,0,1,One , When I Close The Gui It Still Show Same Thing
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Custom KeyStroke With Drop Down List  Topic is solved

10 Sep 2018, 07:28

Try this:
  • GuiClose saves current choices
  • Script reads from INI at startup
  • I had to start ignoring DDL3 again
  • I need to study hotkey combinations with & first
  • Sorry
  • may contain more bugs

Code: Select all

#NoEnv
#SingleInstance, Force

    ; CONSTANT vars
    IniFile := A_ScriptDir "\config.ini"
    List_1  := {None: "", Ctrl: "^", Shift: "+", Alt: "!"}
    Labels  := {One:  1, Two: 2, Three: 3, Four:  4
              , Five: 5, Six: 6, Seven: 7, Eight: 8}

    ; retrieve previous GUI content
    IniRead, prev_Modifier, %IniFile%, GUI, Modifier, 1
    IniRead, prev_Number,   %IniFile%, GUI, Number,   1
    IniRead, prev_Letter,   %IniFile%, GUI, Letter,   1
    IniRead, prev_Label,    %IniFile%, GUI, Label,    1

    ; convert to numbers, needed for choosing myDDL
    myModifier := {None: 1, Ctrl: 2, Shift: 3, Alt: 4} [prev_Modifier]
    myNumber   := prev_Number + 1
    myLetter   := Asc(SubStr(prev_Letter, 2)) - 96
    myLabel    := Labels[prev_Label]

    ; DDLs
    Modifiers := "None|Ctrl|Shift|Alt"
    Numbers   := "0|1|2|3|4|5|6|7"
    Letters   := "Aa|Bb|Cc|Dd|Ee|Ff|Gg|Hh"
    Labels    := "One|Two|Three|Four|Five|Six|Seven|Eight"

    ; GUI
    Gui, Add, DropDownList, xm  w50 vDDL1 Choose%myModifier%, %Modifiers%
    Gui, Add, DropDownList, x+0 w50 vDDL2 Choose%myNumber%,   %Numbers%
    Gui, Add, DropDownList, x+0 w50 vDDL3 Choose%myLetter%,   %Letters%
    Gui, Add, DropDownList, x+0 w50 vDDL4 Choose%myLabel%,    %Labels%
    Gui, Add, Button, xm w200, Submit this hotkey
    Gui, Show

Return ; end of auto-execute section



;-------------------------------------------------------------------------------
GuiClose:
;-------------------------------------------------------------------------------
    Gui, Submit

    ; store current choices for DDLs
    IniWrite, %DDL1%, %IniFile%, GUI, Modifier
    IniWrite, %DDL2%, %IniFile%, GUI, Number
    IniWrite, %DDL3%, %IniFile%, GUI, Letter
    IniWrite, %DDL4%, %IniFile%, GUI, Label

ExitApp



;-------------------------------------------------------------------------------
ButtonSubmitThisHotkey:
;-------------------------------------------------------------------------------
    Gui, Submit, NoHide
    KeyName := List_1[DDL1] DDL2 ;" & " SubStr(DDL3, 2)
    Hotkey, %KeyName%, %DDL4%
    IniWrite, %DDL4%, %IniFile%, Hotkeys, %KeyName%

Return



One:
    Run, WinRAR.exe, C:\Program Files\WinRAR\
Return

Two:
Three:
Four:
Five:
Six:
Seven:
Eight:
    MsgBox, %A_ThisLabel%
Return
Maybe you can use it anyway.
Last edited by wolf_II on 10 Sep 2018, 07:34, edited 1 time in total.
User avatar
Thenatan
Posts: 38
Joined: 01 Sep 2018, 16:28

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 07:34

Wolf_II Man i Really Appreciated :clap: Youre Rock
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 07:38

BugFix: first start needs different defaults. (no config.ini yet)

Code: Select all

    ; retrieve previous GUI content
    IniRead, prev_Modifier, %IniFile%, GUI, Modifier, None
    IniRead, prev_Number,   %IniFile%, GUI, Number,   0
    IniRead, prev_Letter,   %IniFile%, GUI, Letter,   Aa
    IniRead, prev_Label,    %IniFile%, GUI, Label,    One
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 08:39

Custom Combinations wrote:
Modifiers: Unlike a normal hotkey, custom combinations act as though they have the wildcard (*) modifier by default. For example, 1 & 2:: will activate even if Ctrl or Alt is held down when 1 and 2 are pressed, whereas ^1:: would be activated only by Ctrl+1 and not Ctrl+Alt+1.
It looks to me like the combinations you want to set up are not possible.
It previously seemed to work only because I tested with None as the modifier.
User avatar
Thenatan
Posts: 38
Joined: 01 Sep 2018, 16:28

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 08:47

Yes Man , It Seems We Can't Use 3 Keystrokes In This Case , I'm Already Happy With The 2 Of Them :)

I Can't Say It Is A Real Bug , But After Reload The Script With Commands That Stored In Config File , Had to Press Submit Button To Activate The Hotkey That Made With Script Before , Should Be Awesome If We Pass The Press Button Again In Second Gui Launch
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Custom KeyStroke With Drop Down List

10 Sep 2018, 09:05

regarding hotkeys not active on script reload:
I will implement that after we settle which one of three keys you want to abandon.

You can choose Modifier+Number or Modifier+Letter => easy change.
You also can choose Number+Letter => also easy change, but combinations might still come back to bite us.
I just can't tell yet, should be OK. And you have a greater variety of hotkeys to choose from.

You're the boss, I'm all for Number+Letter using combinations.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: masterkomp, OrangeCat, ruespe, Spawnova, yuu453 and 391 guests