lpm Posted May 30, 2013 Share Posted May 30, 2013 Firstly - I'm relatively novice to AI and I have peiced this script together by different means. It is a learning process to me. I am doing a script that gathers data to a GUI and since paste the data to a database form. It is the program JobTabs I use as database. The intention was to avoid a huge amount of cut and paste. It is a lot more fun to get a script to do that. I have enclosed my script (it is in a crude form). I have a issue I can't figure out. In the child GUI - see pic - the input field will show whatever I highlight. I simply can't figure out why. Firstly it was not intended, and secondly it might be a neat feature to use in another app. Her I have added the code I think is involved. First I add a HotKey - Here Ctrl 1. Local $HotKeyAddr1 = HotKeySet("^2") I then use it in a Switch loop. While 1 $nMsg2 = GUIGetMsg() Switch $nMsg2 Case $GUI_EVENT_CLOSE; ReSE Return Case $ButtonCancelEmp GUIDelete("JobTab new Company") Return Case $ButtonNextEmp GUISetState(@SW_HIDE) Return ; Return to Main Window Case $HotKeyAddr1 Send("^c") $Address1 = ClipGet() GUICtrlSetData($Input2, $Address1) The rest og the HotKeys do not Work - I assumed it was due to the issue at hand. The complete script is uploaded in this post. /Lars JobTabsStaticWindowv5.au3 /Lars Denmark www.lpmathiasen.com Automation and simplification is my game! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 30, 2013 Moderators Share Posted May 30, 2013 LPMathiasen,The problem is simple to solve - you are not setting your HotKeys correctly. What exactly do you expect to happen in the ;HotKey set area? Because at the moment you are doing absolutely nothing other than set all those variables to 0. Which is why you fire the Case $HotKeyAddr1 in the loop on each pass as it is the first available 0 and the return from GUIGetMsg when there are no events is 0. When the case fires, it copies whatever is highlighted (in this case the content of the first input) and sets variable $Address1 to this value before placing it in the second input. So we come back to the question of what you want those HotKeys to do - if you can explain what you thought they were doing, we can get the script to actually do it. 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...
lpm Posted June 2, 2013 Author Share Posted June 2, 2013 Okay. The idea was when activating a hotkey it would perform a Ctrl V on highlighted text and then send it to the inputform. In the attached file it seems to work, but when I tried to remove the functions that do the job and in stead have them in the "While" loop I could not get it to work. So mu goal was to make a small GUI that would load pasted text into variables i since would use to load into a database form. Something like this: When hotkey Ctrl 1 is pressed perform: Ctrl C in text Send from clipboard to variable $PastedText Post it in input1 Is this clear enough? :-) The reason i tried to remove all the functions was i found the code too complex too fast and it seem I can't do nested functions like: Func1 code code code NestedFunc1 code code EndNestedFunc1 code EndFunc1 /Lars JabTabNewCompanyFormv2.au3 /Lars Denmark www.lpmathiasen.com Automation and simplification is my game! Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted June 2, 2013 Moderators Solution Share Posted June 2, 2013 LPMathiasen, I understand. Set up the HotKeys like this: ;HotKey set area HotKeySet("^1", "_HotKeyCompany") HotKeySet("^2", "_HotKeyAddr1") HotKeySet("^3", "_HotKeyAddr2") HotKeySet("^4", "_HotKeyCity") HotKeySet("^7", "_HotKeyWeb") Then take the useless Cases out of the loop and declare the required HotKey functions. You can see that they look very much like the Cases you removed - and that they are declared after the main function. You cannot declare functions within other functions. expandcollapse popupWhile 1 $nMsg2 = GUIGetMsg() Switch $nMsg2 Case $GUI_EVENT_CLOSE; ReSE Return Case $ButtonCancelEmp GUIDelete("JobTab new Company") Return Case $ButtonNextEmp GUISetState(@SW_HIDE) Return ; Return to Main Window EndSwitch WEnd EndFunc ;==>EmployerInput Func _HotKeyCompany() Send("^c") GUICtrlSetData($Input1, ClipGet()) EndFunc Func _HotKeyAddr1() Send("^c") GUICtrlSetData($Input2, ClipGet()) EndFunc Func _HotKeyAddr2() Send("^c") GUICtrlSetData($Input3, ClipGet()) EndFunc Func _HotKeyCity() Send("^c") GUICtrlSetData($Input4, ClipGet()) EndFunc Func _HotKeyWeb() Send("^c") GUICtrlSetData($Input5, ClipGet()) EndFunc You will also need to declare the various $Input# controls as Global at the top of your script: Global $Input1, $Input2, $Input3, $Input4, $Input5 Now I can use those HotKeys in the script to do what you wanted. Please ask if you have any further questions. 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...
lpm Posted June 3, 2013 Author Share Posted June 3, 2013 Thanks a lot. It works now. /Lars /Lars Denmark www.lpmathiasen.com Automation and simplification is my game! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 3, 2013 Moderators Share Posted June 3, 2013 LPMathiasen,Glad I could help. 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...
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