Jump to content

Problem with HotKeySet and GUI


lpm
 Share

Go to solution Solved by Melba23,

Recommended Posts

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.

 

05.30.2013-12.39.png

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

  • Moderators
  • Solution

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. ;)

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

        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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

LPMathiasen,

Glad I could help. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...