meisandy Posted November 29, 2009 Share Posted November 29, 2009 Hi I am making a control pannel for a program. The control pannel has comboboxes with things like "alt|ctrl|win" to set user defined hotkeys! I can get it to read the combobox with GUICtrlRead and either get "alt", "win" or "ctrl" but abously thats no good for auto it to set a hotkey. And Ctrl needs to be turned into "^", Alt needs to be turned into "!", and Win needs to be turned into "#". So in theory: If I set the script to capture Ctrl and turn it into "^" etc... I can put Hotkeyset([varible of combobox/es], "userhotkey") So what I'm really asking is how can I turn something like Ctrl into the correct symbol if selected? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 29, 2009 Moderators Share Posted November 29, 2009 (edited) DjATUit, You need to read the combo and then change a variable according to the value chosen in the combo: expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIComboBox.au3> $sCurr_Combo = "" $sSend_Mod = "" $hGUI = GUICreate("Test", 500, 500) $hCombo = GUICtrlCreateCombo("", 10, 10, 100, 20) GUICtrlSetData(-1, "alt|ctrl|win") $hLabel = GUICtrlCreateLabel("", 10, 100, 400, 100) GUICtrlSetFont(-1, 16) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; Read combo $sCombo_Read = GUICtrlRead($hCombo) ; See if the combo is closed and the selection has changed to avoid flickering If $sCombo_Read <> $sCurr_Combo And _GUICtrlComboBox_GetDroppedState($hCombo) = False Then $sCurr_Combo = $sCombo_Read ; Change the variable depending on the combo selection Switch $sCombo_Read Case "alt" $sSend_Mod = "!" Case "ctrl" $sSend_Mod = "^" Case "win" $sSend_Mod = "#" EndSwitch ; Show that we have changed the variable GUICtrlSetData($hLabel, "You selected " & $sCombo_Read & @CRLF & "I changed it to " & $sSend_Mod & @CRLF) EndIf WEnd Once you have the variable you can use concatenation to create a string to send: ; Get the $sSend_String = $sSend_Mod & "{TAB}" Send ($sSend_String) I hope this helps. Ask if anything is unclear. M23 Edit: Got the concatenation part wrong. Edited November 29, 2009 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
meisandy Posted November 29, 2009 Author Share Posted November 29, 2009 So this makes it so i can put HotKeySet($sCombo_Read, "UserHotkey") does it? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 29, 2009 Moderators Share Posted November 29, 2009 DjATUit,This shows how to create the HotKeys. It will unset the current HotKey for the UserHotKey function and then set a new one:expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIComboBox.au3> $sCurr_Combo = "" $sHK_Mod = "" $sHK_String = "" $hGUI = GUICreate("Test", 500, 500) $hCombo = GUICtrlCreateCombo("", 10, 10, 100, 20) GUICtrlSetData(-1, "alt|ctrl|win") $hLabel = GUICtrlCreateLabel("", 10, 100, 400, 100) GUICtrlSetFont(-1, 16) $hButton = GUICtrlCreateButton("Set HotKey", 200, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton ConsoleWrite($sHK_String & @CRLF) HotKeySet($sHK_String) $sHK_String = $sHK_Mod & "q" ConsoleWrite($sHK_String & @CRLF) HotKeySet($sHK_String, "UserHotKey") EndSwitch ; Read combo $sCombo_Read = GUICtrlRead($hCombo) ; See if the combo is closed and the selection has changed to avoid flickering If $sCombo_Read <> $sCurr_Combo And _GUICtrlComboBox_GetDroppedState($hCombo) = False Then $sCurr_Combo = $sCombo_Read ; Change the variable depending on the combo selection Switch $sCombo_Read Case "alt" $sHK_Mod = "!" Case "ctrl" $sHK_Mod = "^" Case "win" $sHK_Mod = "#" EndSwitch ; Show that we have changed the variable GUICtrlSetData($hLabel, "The HotKey will be set to " & $sCombo_Read & "-Q") EndIf WEnd Func UserHotKey() MsgBox(0, "HotKey", "You got here by pressing" & @CRLF & $sCombo_Read & "-Q" ) EndFuncDoes that do what you want? M23P.S. Ignore what I said about the single/double quotes above - I realised I was completely wrong. I have already amended the post. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
meisandy Posted November 29, 2009 Author Share Posted November 29, 2009 Yeah exactly Thanks So Much!!!! P.S. LOL Link to comment Share on other sites More sharing options...
meisandy Posted December 1, 2009 Author Share Posted December 1, 2009 Hi, Thats worked pefectly so far! But I'm now onto setting another user defined hotkey! But when I put the bit of the script in another time to suit the next hotkey, but now it only set the second hot key instead of both? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 1, 2009 Moderators Share Posted December 1, 2009 DjATUit, Please post what you have done so far - it is much easier if I can see what you are trying to do. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
meisandy Posted December 1, 2009 Author Share Posted December 1, 2009 Okay here you go, its a bit long but the main focus is around lines 140 - 200: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=T:\icons\icandy Icons\iCandy Junior\The Icons\Home 2.ico #AutoIt3Wrapper_Res_Comment=This program speeds up the process of typing "Learning Objective" and "To be able to". By using Windows key and Alt followed by l or t #AutoIt3Wrapper_Res_Description=Speeding up typing at school! #AutoIt3Wrapper_Res_Fileversion=1.0 Beta #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <GUIComboBox.au3> #include <ButtonConstants.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> Global $KeyboardShortcuts, $ButtonOKCP, $rd1frst, $rd1scd, $rd1lttr, $althotkey, $controlhotkey, $winhotkey, $rd1hkout, $ES_TABSTOP, $rd2frst, $rd2scnd, $rd2lttr, $rd2hkout Opt("TrayMenuMode",1) $SetKeyBoardShortcutsTray = TrayCreateItem("Set Keyboard Shortcuts") $EscScript = TrayCreateItem ("Exit") HotKeySet ("{ESCAPE}", "stoptxt") GUICtrlSetOnEvent ($ButtonOKCP, "ButtonOKCP") Func ButtonOKCP () Exit EndFunc Func stoptxt () Exit 0 EndFunc HotKeySet ("#!l", "TypeLO") HotKeySet ( "#!t" , "TYPEtbat" ) While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $SetKeyBoardShortcutsTray #Region ### START Koda GUI section ### Form=c:\users\dj drew\desktop\control pannel for schoolboard designed with kfd.kxf $sCurr_Combo = "" $HK1_String = "" $HK2_String = "" $turninhots1_1 = "" $turninhots1_2 = "" $turninhots1_3 = "" $turninhots2_1 = "" $turninhots2_2 = "" $Form2 = GUICreate("Control Pannel for SchoolBoard", 482, 330, 302, 218) GUISetIcon("D:\005.ico") $PageControl1 = GUICtrlCreateTab(8, 8, 436, 256) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("Keyboard Shortcuts") $Combofirstset1 = GUICtrlCreateCombo("Win", 24, 80, 49, 25) GUICtrlSetData(-1, "Alt|Ctrl") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label1 = GUICtrlCreateLabel("First Key", 24, 56, 47, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label2 = GUICtrlCreateLabel("+", 80, 80, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") $Label3 = GUICtrlCreateLabel("Second Key", 104, 56, 63, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Combofirstset2 = GUICtrlCreateCombo("Alt", 105, 79, 49, 25) GUICtrlSetData(-1, "Ctrl|Win") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label4 = GUICtrlCreateLabel("+", 170, 80, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") $Label5 = GUICtrlCreateLabel("Letter", 191, 56, 32, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Combofirstsetletter = GUICtrlCreateCombo("a", 193, 79, 49, 25) GUICtrlSetData(-1, "b|c|d|e|f|g|h|i|j|k|m|n|o|p|q|r|s|u|v|w|x|y|z") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label6 = GUICtrlCreateLabel("=", 249, 79, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") $Inputfirsthk = GUICtrlCreateInput("Type your sentance here", 264, 80, 169, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label7 = GUICtrlCreateLabel("Phrase/ Setence", 260, 54, 84, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label8 = GUICtrlCreateLabel("First Key", 24, 117, 47, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label9 = GUICtrlCreateLabel("Second Key", 104, 114, 63, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label10 = GUICtrlCreateLabel("Letter", 191, 110, 32, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label11 = GUICtrlCreateLabel("Phrase/ Setence", 260, 115, 84, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Comboscndset1 = GUICtrlCreateCombo("Win", 25, 138, 49, 25) GUICtrlSetData(-1, "Alt|Ctrl") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label12 = GUICtrlCreateLabel("+", 81, 140, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") $Comboscndset2 = GUICtrlCreateCombo("Alt", 105, 137, 49, 25) GUICtrlSetData(-1, "Ctrl|Win") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label13 = GUICtrlCreateLabel("+", 170, 135, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") $Comboscndsetletter = GUICtrlCreateCombo("a", 193, 133, 49, 25) GUICtrlSetData(-1, "b|c|d|e|f|g|h|i|j|k|m|n|o|p|q|r|s|u|v|w|x|y|z") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label14 = GUICtrlCreateLabel("=", 249, 136, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") $Inputscndhk = GUICtrlCreateInput("Type your sentance here", 263, 135, 169, 22, $ES_TABSTOP) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label15 = GUICtrlCreateLabel("First Key", 24, 176, 47, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label16 = GUICtrlCreateLabel("Second Key", 104, 173, 63, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label17 = GUICtrlCreateLabel("Letter", 191, 173, 32, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label18 = GUICtrlCreateLabel("Phrase/ Setence", 260, 171, 84, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Combo7 = GUICtrlCreateCombo("Win", 25, 197, 49, 25) GUICtrlSetData(-1, "Alt|Ctrl") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label19 = GUICtrlCreateLabel("+", 81, 194, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") $Combo8 = GUICtrlCreateCombo("Alt", 103, 195, 49, 25) GUICtrlSetData(-1, "Ctrl|Win") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label20 = GUICtrlCreateLabel("+", 169, 194, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") $Combo9 = GUICtrlCreateCombo("A", 193, 197, 49, 25) GUICtrlSetData(-1, "B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Label21 = GUICtrlCreateLabel("=", 249, 197, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") $Input3 = GUICtrlCreateInput("Type your sentance here", 266, 195, 169, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateTabItem("") $ButtonOKCP = GUICtrlCreateButton("&OK", 166, 272, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("&Cancel", 246, 272, 75, 25, $WS_GROUP) $Button3 = GUICtrlCreateButton("&Help", 328, 272, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonOKCP HotKeySet($HK1_String) $HK_String1 = $turninhots1_1 & $turninhots1_2 & $rd1lttr HotKeySet($HK1_String, "UserHotKey1") HotKeySet($HK2_String) $HK2_String = $turninhots2_1 & $turninhots2_2 & $rd2lttr HotKeySet($HK2_String, "UserHotkey2") EndSwitch $rd1frst = GUICtrlRead ($Combofirstset1) If $rd1frst <> $sCurr_Combo And _GUICtrlComboBox_GetDroppedState($Combofirstset1) = False Then $sCurr_Combo = $rd1frst Switch $rd1frst Case "Alt" $turninhots1_1 = "!" Case "Win" $turninhots1_1 = "#" Case "Ctrl" $turninhots1_1 = "^" EndSwitch EndIf $rd1scd = GUICtrlRead ($Combofirstset2) If $rd1scd <> $sCurr_Combo And _GUICtrlComboBox_GetDroppedState($Combofirstset2) = False Then $sCurr_Combo = $rd1scd Switch $rd1scd Case "Alt" $turninhots1_2 = "!" Case "Ctrl" $turninhots1_2 = "^" Case "Win" $turninhots1_2 = "#" EndSwitch EndIf $rd2frst = GUICtrlRead($Comboscndset1) If $rd2frst <> $sCurr_Combo And _GUICtrlComboBox_GetDroppedState($Comboscndset1) = False Then $sCurr_Combo = $rd2frst Switch $rd2frst Case "Alt" $turninhots2_1 = "!" Case "Ctrl" $turninhots2_1 = "^" Case "Win" $turninhots2_1 = "#" EndSwitch EndIf $rd2scnd = GUICtrlRead($Comboscndset2) If $rd2scnd <> $sCurr_Combo And _GUICtrlComboBox_GetDroppedState($Comboscndset2) = False Then $sCurr_Combo = $rd2scnd Switch $rd2scnd Case "Alt" $turninhots2_2 = "!" Case "Ctrl" $turninhots2_2 = "^" Case "Win" $turninhots2_2 = "#" EndSwitch EndIf $rd1lttr = GUICtrlRead($Combofirstsetletter) $rd1hkout = GUICtrlRead($Inputfirsthk) $rd2lttr = GUICtrlRead($Comboscndsetletter) $rd2hkout = GUICtrlRead($Inputscndhk) WEnd Case $msg = $EscScript Exit While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $KeyboardShortcuts EndSwitch WEnd ContinueLoop EndSelect Sleep (100) WEnd Func UserHotkey2 () MsgBox(0, "Success", "Your new hot key is:" & $rd2hkout) EndFunc Func UserHotKey1 () MsgBox (0, "Succes", "Your Message Is:" & $rd1hkout) EndFunc Func TypeLO () Send ( "Learning Objective" ) EndFunc Func TYPEtbat () Send ( "To be able to" ) EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 1, 2009 Moderators Share Posted December 1, 2009 DjATUit,Here is an amended version of your script. I have hacked it about quite a lot , but I have added lots of comments to explain why:expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=T:\icons\icandy Icons\iCandy Junior\The Icons\Home 2.ico #AutoIt3Wrapper_Res_Comment=This program speeds up the process of typing "Learning Objective" and "To be able to". By using Windows key and Alt followed by l or t #AutoIt3Wrapper_Res_Description=Speeding up typing at school! #AutoIt3Wrapper_Res_Fileversion=1.0 Beta #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> ; <<<<<<<<<<<<<<<<<<< Not as many now!!! Global $HK1_String = "", $HK2_String = "", $HK1_Check, $HK2_Check, $rd1hkout, $rd2hkout ; <<<<< And not so many here either! Opt("TrayMenuMode", 3) ; <<<<<<<< Added 2 = Do not tick when selected Global $SetKeyBoardShortcutsTray = TrayCreateItem("Set Keyboard Shortcuts") Global $EscScript = TrayCreateItem("Exit") HotKeySet("{ESCAPE}", "stoptxt") HotKeySet("#!l", "TypeLO") HotKeySet("#!t", "TYPEtbat") ;GUICtrlSetOnEvent($ButtonOKCP, "ButtonOKCP") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Not in OnEvent mode ;$sCurr_Combo = "" ; no longer needed ;$turninhots1_1 = "" ; <<<<<<<<<<<<<< no longer needed ;$turninhots1_2 = "" ;$turninhots1_3 = "" ;$turninhots2_1 = "" ;$turninhots2_2 = "" ; Create GUI Global $Form2 = GUICreate("Control Panel for SchoolBoard", 482, 330, 302, 218) GUISetIcon("D:\005.ico") Global $PageControl1 = GUICtrlCreateTab(8, 8, 436, 256) ;GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) ; <<<<<<<<<<<<<<<<<< Not needed, you do not have a resizeable GUI Global $TabSheet1 = GUICtrlCreateTabItem("Keyboard Shortcuts") ; These are reordered to make it a bit easier to work out what is going on!! GUICtrlCreateLabel("First Key", 24, 56, 47, 18) ; <<<<<< You only need to use variables for the ControlID if you are going to use it later GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("Second Key", 104, 56, 63, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("Letter", 191, 56, 32, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("Phrase/ Sentence", 260, 54, 84, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") Global $Combofirstset1 = GUICtrlCreateCombo("Win", 24, 80, 49, 25) ; <<<< You need this one for example GUICtrlSetData(-1, "Alt|Ctrl") GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("+", 80, 80, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") Global $Combofirstset2 = GUICtrlCreateCombo("Alt", 105, 79, 49, 25) GUICtrlSetData(-1, "Ctrl|Win") GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("+", 170, 80, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") Global $Combofirstsetletter = GUICtrlCreateCombo("a", 193, 79, 49, 25) GUICtrlSetData(-1, "b|c|d|e|f|g|h|i|j|k|m|n|o|p|q|r|s|u|v|w|x|y|z") GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("=", 249, 79, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") Global $Inputfirsthk = GUICtrlCreateInput("Type your sentence here", 264, 80, 169, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("First Key", 24, 117, 47, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("Second Key", 104, 114, 63, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("Letter", 191, 110, 32, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("Phrase/ Sentence", 260, 115, 84, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") Global $Comboscndset1 = GUICtrlCreateCombo("Win", 25, 138, 49, 25) GUICtrlSetData(-1, "Alt|Ctrl") GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("+", 81, 140, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") Global $Comboscndset2 = GUICtrlCreateCombo("Alt", 105, 137, 49, 25) GUICtrlSetData(-1, "Ctrl|Win") GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("+", 170, 135, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") Global $Comboscndsetletter = GUICtrlCreateCombo("a", 193, 133, 49, 25) GUICtrlSetData(-1, "b|c|d|e|f|g|h|i|j|k|m|n|o|p|q|r|s|u|v|w|x|y|z") GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("=", 249, 136, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") Global $Inputscndhk = GUICtrlCreateInput("Type your sentence here", 263, 135, 169, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("First Key", 24, 176, 47, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("Second Key", 104, 173, 63, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("Letter", 191, 173, 32, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("Phrase/ Sentence", 260, 171, 84, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") Global $Combothrdset1 = GUICtrlCreateCombo("Win", 25, 197, 49, 25) GUICtrlSetData(-1, "Alt|Ctrl") GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("+", 81, 194, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") Global $Combothrdset2 = GUICtrlCreateCombo("Alt", 103, 195, 49, 25) GUICtrlSetData(-1, "Ctrl|Win") GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("+", 169, 194, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") Global $Combothrdsetletter = GUICtrlCreateCombo("A", 193, 197, 49, 25) GUICtrlSetData(-1, "B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z") GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateLabel("=", 249, 197, 13, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") Global $Inputthrdhk = GUICtrlCreateInput("Type your sentence here", 266, 195, 169, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateTabItem("") Global $ButtonOKCP = GUICtrlCreateButton("&OK", 166, 272, 75, 25) ; Not needed here >> , $WS_GROUP) Global $Button2 = GUICtrlCreateButton("&Cancel", 246, 272, 75, 25) ;, $WS_GROUP) Global $Button3 = GUICtrlCreateButton("&Help", 328, 272, 75, 25) ;, $WS_GROUP) GUISetState(@SW_HIDE) ; <<<<<<<<<<<<<<<<<<<<<<< Hide GUI until needed While 1 ; Look for tray events Switch TrayGetMsg() Case $EscScript ; Exit script completely Exit Case $SetKeyBoardShortcutsTray ; Show the GUI so we can set HotKeys GUISetState(@SW_SHOW, $Form2) EndSwitch ; Look for GUI events Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $Button2 ; Hide GUI again without changing HotKeys GUISetState(@SW_HIDE, $Form2) Case $ButtonOKCP ; Change HotKeys and then hide GUI again Change_HotKeys() GUISetState(@SW_HIDE, $Form2) Case $Button3 ; Show some Help - I hope! EndSwitch ;Sleep(100) ; <<<<<<<<<<<<<<<<<<<<<<< Only needed if you are in OnEvent mode WEnd ;Func ButtonOKCP() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Not needed, we are not in OnEvent mode ; Exit ;EndFunc ;==>ButtonOKCP Func Change_HotKeys() ; Reset first HotKey ; Unset current key HotKeySet($HK1_String) ; Now set HotKey string to blank $HK1_String = "" ; Get character for first combo selection and add to string $HK1_String &= Get_Char($Combofirstset1) ; Get character for second combo selection and add to string $HK1_String &= Get_Char($Combofirstset2) ; Add key character to string $HK1_String &= GUICtrlRead($Combofirstsetletter) ; Set required phrase $rd1hkout = GUICtrlRead($Inputfirsthk) ; Set check string $HK1_Check = GUICtrlRead($Combofirstset1) & " - " & GUICtrlRead($Combofirstset2) & " - " & GUICtrlRead($Combofirstsetletter) ; Set the new key HotKeySet($HK1_String, "UserHotKey1") ; Reset second HotKey ; Unset current key HotKeySet($HK2_String) ; Now set HotKey string to blank $HK2_String = "" ; Get character for first combo selection and add to string $HK2_String &= Get_Char($Comboscndset1) ; Get character for second combo selection and add to string $HK2_String &= Get_Char($Comboscndset2) ; Add key character to string $HK2_String &= GUICtrlRead($Comboscndsetletter) ; Set required phrase $rd2hkout = GUICtrlRead($Inputscndhk) ; Set check string $HK2_Check = GUICtrlRead($Comboscndset1) & " - " & GUICtrlRead($Comboscndset2) & " - " & GUICtrlRead($Comboscndsetletter) ; Set the new key HotKeySet($HK2_String, "UserHotKey2") EndFunc Func Get_Char($Combo) Local $sRet ; Set value according to combo value Switch GUICtrlRead($Combo) Case "Alt" $sRet = "!" Case "Win" $sRet = "#" Case "Ctrl" $sRet = "^" EndSwitch ; Return value Return $sRet EndFunc Func stoptxt() Exit 0 EndFunc ;==>stoptxt Func UserHotkey2() MsgBox(0, "Success", "Your new hot key 1 is: " & $HK2_Check & @CRLF & "Your Message Is: " & $rd2hkout) EndFunc ;==>UserHotkey2 Func UserHotKey1() MsgBox(0, "Success", "Your new hot key 1 is: " & $HK1_Check & @CRLF & "Your Message Is: " & $rd1hkout) ; Send($rd1hkout) ; <<<<<<<<<<<<<<<< what you will need! EndFunc ;==>UserHotKey1 Func TypeLO() Send("Learning Objective") EndFunc ;==>TypeLO Func TYPEtbat() Send("To be able to") EndFunc ;==>TYPEtbatRead through it carefully to see where and what I have changed. If you have any questions, please ask. I could not help but notice the rather "confused" nature of the original code you posted. Are you quite happy about the 2 GUI modes - OnEvent and MessageLoop? I ask because you had a mixture in your code and the two are mutually exclusive. If not, do read the "GUI Reference" page in the Help file carefully and ask if you are still unsure. Awaiting incoming...... M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
meisandy Posted December 1, 2009 Author Share Posted December 1, 2009 ah yeah thanks. alot eaiser to look at and understand! Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now