Sign in to follow this  
Followers 0
DickWms

Handle Key Presses in Input Control

9 posts in this topic

I'm trying to catch non printing characters (like Delete, F5, Shifte F5, etc) when a user is typing into an Input Control. The sample code below doesn't work (the Input MsgBox only appears when the enter key is pressed and the Key Pressed MsgBox never appears). It appears to me this is because the Input Control doesn't send a GUI message every time a key stroke is received.

So my question is how can I capture individual key presses, including non printing ones, to an Input Control? Or should I be using a different control?

Thank you - Dick williams

#include
#include

$window = GUICreate("Test", 200, 100)
$inputBox = GUICtrlCreateInput ( "Input Box", 50, 50 , 100, 20)
GUISetState()
While 1
$msg = GUIGetMsg()
Select

Case $msg = $inputBox
MsgBox(0, "Input Box", "Case Executed")
If _IsPressed(75) Then
MsgBox(0, "Key Pressed", "F5")
EndIf

Case $msg = $GUI_EVENT_CLOSE
Exit

EndSelect
WEnd

Share this post


Link to post
Share on other sites



DickWms,

how can I capture individual key presses, including non printing ones, to an Input Control?

Surely an input control is for inputting text - so why do you want to capture other keypresses as well? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

The program will send Function Keys to another application's window and I want to use the Delete key as a short cut to erase all text in the Input Control.

If there is a better control I'd be happy to use it.

Dick Williams

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

DickWms,

If all you are looking for are those few keys then why not use _IsPressed in your idle loop? :)

M23

Edit:

Here is how you could look for the "Delete" key to empty the input:

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <Misc.au3>

Local $hDLL = DllOpen("user32.dll")

$hGUI = GUICreate("Test", 500, 500)

$cInput = GUICtrlCreateInput("", 10, 10, 200, 20)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            DllClose($hDLL)
            Exit
    EndSwitch

    If _WinAPI_GetFocus() = GUICtrlGetHandle($cInput) And _IsPressed("2E", $hDLL) Then
        GUICtrlSetData($cInput, "")
    EndIf

WEnd

Any help? :)

Edited by Melba23
1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Thank you - that looks promising. I will give it a try.

Dick Williams

Share this post


Link to post
Share on other sites

Yes - that is a great help and seems to be working fine.

One more question - the application I'm writing uses a tab control and the input control is on tab0. I just wanted the Delete Key shortcut to work when tab0 is active. So I added a clause to your If statement and made it look like this:

If _WinAPI_GetFocus() = GUICtrlGetHandle($cInput) And _IsPressed("2E", $hDLL) And GUICtrlRead($tab) = 0

This doesn't work as I expected. If I put text in the input control, click on another tab, hit the Delete key, and then return to tab0, the input contol will be blank.

Dick Williams

Share this post


Link to post
Share on other sites

DickWms,

A peculiarity of Windows is causing this. When you switch to another tab the whole content of the input is selected while the input also retains the keyboard focus - so pressing "Delete" still affects the input and replaces all content. You can see that quite clearly in this short script - just put some text into the input and then swap tabs. Whan you return to Tab 0 you will see that all the text in the input is highlighted (highlit?): :(

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)
$cTab = GUICtrlCreateTab(10, 10, 480, 380)
$cTab_0 = GUICtrlCreateTabItem("Tab 0")
$cInput = GUICtrlCreateInput("", 50, 50, 200, 20)
$cTab_1 = GUICtrlCreateTabItem("Tab 1")
GUICtrlCreateTabItem("")

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

The trick is to reset the focus to another control when you change tabs - like this: ;)

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <Misc.au3>

Local $hDLL = DllOpen("user32.dll")

$hGUI = GUICreate("Test", 500, 500)

$cTab = GUICtrlCreateTab(10, 10, 480, 380)
$cTab_0 = GUICtrlCreateTabItem("Tab 0")
$cInput = GUICtrlCreateInput("", 50, 50, 200, 20)
$cTab_1 = GUICtrlCreateTabItem("Tab 1")
GUICtrlCreateTabItem("")

$cButton = GUICtrlCreateButton("Test", 10, 450, 80, 30) ; <<<<< Just for the demo - you could use any control

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            DllClose($hDLL)
            Exit
        Case $cTab ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< When tab is actioned
            GUICtrlSetState($cButton, $GUI_FOCUS) ; <<<<<<<<<<<<<< Change the focus
    EndSwitch

    If _WinAPI_GetFocus() = GUICtrlGetHandle($cInput) And _IsPressed("2E", $hDLL) And GUICtrlRead($cTab) = 0 Then
        GUICtrlSetData($cInput, "")
        While _IsPressed("2E", $hDLL) ; <<<<<<<<<<<<<<<<<<<<<<<<<<< Not really necessary, but just wait until the key is released
            Sleep(10)
        WEnd
    EndIf

WEnd

All clear? :)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Yes - it's all clear now.

Thank you again - Dick Williams

Share this post


Link to post
Share on other sites

DickWms,

Glad I could be of help. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • kcvinu
      By kcvinu
      Hi all,
      I am using GuiGetMsg(). Assume that i have a combo box in my gui. And when i use this code - 
      While 1     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE             Exit         Case $CMB_NamesList ; Handle of my Combo box             CellSelect()          EndSwitch WEnd This code will call my "CellSelect()" function only when the selection change event occurred. But assume that i need to call this function right after the user clicks on the combo box. So do i need to use GuiRegisterMsg function for that ? Or can i simply do the task with GUIGetMsg() ? If the second option is possible, then i wonder how to do it. 
    • jimollerhead
      By jimollerhead
      Hello Folks,

      I'm not an AutoIt noob but I am new to the GuiRegisterMsg command.

      What I am trying to do is to pop up a "long string edit" window when user double-clicks. Ideally I wanted it to be a duouble-click in the Input box itself but I couldn't get this to work so I was going to settle for a double-click *near* the input box.

      Here's a severely curtailed version of my almost 1300-line script. From the msgbox "tell-tale" it appears that the GuiRegisterMsg definition interferes with the GuiGetMsg function and it 'remembers' the last GuiGetMsg return value -- is there some way to 'flush' the holding area? Note that there are bits in there from experiments -- if I comment out the While-Wend and replace it with the sleep line you can better see what I am trying to acheive. The list box is just to give a different kind of control than an input field to have the focus, it's contents are not relevant to the snippet, only to the full app.

      All help gratefully acknowledged! Here's the code snippet:


      #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <GuiConstantsEx.au3> #include <EditConstants.au3> #include <ListBoxConstants.au3> Dim $InputFileId Dim $OutputFileId Dim $winMain Dim $GUIMsg GUIRegisterMsg($WM_LBUTTONDBLCLK, "EditText") $winMain = GUICreate ("Test for Editing Long Strings", 800, 560, -1, -1) GUICtrlCreateLabel("File to Process", 22,30) GUICtrlCreateLabel("Output File", 40,60) $InputFileId = GUICtrlCreateInput ( "", 100, 25, 400, 20) $OutputFileId = GUICtrlCreateInput ( "", 100, 55, 400, 20) $btnInputFile = GUICtrlCreateButton ( "Browse for File", 520, 22, 110, 25) $btnOPFolder = GUICtrlCreateButton ( "Browse for Location", 520, 53, 110, 25) ; Create the list of actions $ActionList = GUICtrlCreateList( "", 25, 260, 70, 200) GUICtrlSetData($ActionList, "Delete|Exclude|Include|Insert|Kill Blanks|Move|Remove|Replace|Switch", "Delete") GUISetState(@SW_SHOW, $winMain) While 1 $GUIMsg = GUIGetMsg() Switch $GUIMsg Case $GUI_EVENT_CLOSE ExitLoop Case $btnInputFile MsgBox(0, "Info", "Input Button pressed") Case $btnOPFolder MsgBox(0, "Info", "Output Button pressed") EndSwitch WEnd Func EditText($Window, $Caller, $p1, $p2) Dim $winEdit Dim $CtrlName Dim $edtString Dim $btnAccept Dim $btnReject Dim $Response Dim $RetString Dim $CtrlId Dim $ActCode Dim $HasFocus $CtrlName = ControlGetFocus("Test for Editing Long Strings") msgbox(0,"DOUBLE-CLICK!","Control: " & $CtrlId & @CRLF & "Action: " & $ActCode & @CRLF & "CtrlName: " & $CtrlName) If StringInStr($CtrlName,"Edit") > 0 Then $winEdit = GUICreate("Long String Editor", 790, 100, -1, -1, $WS_BORDER) $edtString = GUICtrlCreateEdit("This is a potentially long string", 5, 5, 780, 20, $ES_AUTOHSCROLL) $btnAccept = GUICtrlCreateButton( "Accept String", 240, 33, 100, 30) $btnReject = GUICtrlCreateButton( "Reject String", 440, 33, 100, 30) GUISetState(@SW_SHOW, $winEdit) GUICtrlSetState($edtString, $GUI_FOCUS) ; sleep(5000) ;#cs While 1 $Response = GUIGetMsg() if $Response = $btnAccept Then ExitLoop EndIf Select Case $Response = $btnReject ExitLoop Case $Response = $btnAccept ; GUICtrlSetData($CtrlName, $RetString) ExitLoop Case Else $RetString = GUICtrlRead($edtString) EndSelect WEnd ;#ce Else Return $GUI_RUNDEFMSG EndIf GUICtrlSetData($CtrlName, $RetString) GUIDelete($winEdit) Return $GUI_RUNDEFMSG EndFunc
    • Artisan
      By Artisan
      I've been working on a fancy ListView for user input. When a cell is clicked, a temporary Combo or Input control is created. The user does their part, then the temporary control's data is transferred to the ListView and the temporary control is deleted. I'm quite pleased with how it's turned out, except for one puzzling "feature".

      If I use "Switch GUIGetMsg()" in the main loop, then the first time a user clicks on the form causes a temp control to be both created and processed. That only occurs on the first click and not on any subsequent clicks. If I use "$msg = GUIGetMsg(1)" with a Switch command, it works properly on every click. See code below. I have no idea why this is. Does anyone else? I'll use GUIGetMsg(1) if I must, but I prefer my code to be as simple as possible.


      #include #include #include #include #include Global Const $_INCL = 1, $_REGEX = 2, $_FILTER = 3 Global $h_TempCtrl, $TempCtrlStatus[3] = [False, -1, -1], $_ListViewY = 1 Switch @OSVersion Case "WIN_2000", "WIN_XP", "WIN_XPe", "WIN_2003" $_ListViewY = 0 EndSwitch $h_GUI = GUICreate("Form1", 594, 329) $h_ListView = GUICtrlCreateListView("#|Include or Not|Filter Type|Contents ", 24, 24, 545, 279, $LVS_SINGLESEL) $hG_LVitem1 = GUICtrlCreateListViewItem("1.|Include|StringRegExp|", $h_ListView) $hG_LVitem2 = GUICtrlCreateListViewItem("2.|Include|StringRegExp|", $h_ListView) $hG_LVitem3 = GUICtrlCreateListViewItem("3.|Include|StringRegExp|", $h_ListView) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() ;~ $msg = GUIGetMsg(1) ;~ Switch $msg[0] Case $GUI_EVENT_CLOSE Exit Case $h_TempCtrl If $h_TempCtrl <> 0 Then _GUICtrlTemp_Apply("$h_TempCtrl") EndIf EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; Catch ListView messages Local $hWndFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") If $hWndFrom == GUICtrlGetHandle($h_ListView) And $iCode == $NM_CLICK Then _GUICtrlTemp_Create() Return $GUI_RUNDEFMSG EndFunc Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg ; Catch user input Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) $iCode = BitShift($iwParam, 16) If $TempCtrlStatus[0] Then If $hWndFrom == GUICtrlGetHandle($h_TempCtrl) Then Switch $iCode Case $CBN_SELENDOK _GUICtrlTemp_Apply("$CBN_SELENDOK") Case $CBN_SELENDCANCEL _GUICtrlTemp_Delete("$CBN_SELENDCANCEL") Case $EN_KILLFOCUS _GUICtrlTemp_Apply("$EN_KILLFOCUS") EndSwitch EndIf EndIf Return $GUI_RUNDEFMSG EndFunc Func _GUICtrlTemp_Create() ; Create a temporary control for user input Local $tempPos, $HitTest $HitTest = _GUICtrlListView_SubItemHitTest(GUICtrlGetHandle($h_ListView)) If $HitTest[0] <> -1 Then $TempCtrlStatus[0] = True $TempCtrlStatus[1] = $HitTest[0] $TempCtrlStatus[2] = $HitTest[1] Switch $HitTest[1] ; Global Const $_INCL = 1, $_REGEX = 2, $_FILTER = 3, $_FREQ = 4 Case $_INCL $tempPos = _GUICtrlListView_GetSubItemRect($h_ListView, $HitTest[0], $_INCL) $h_TempCtrl = GUICtrlCreateCombo("", $tempPos[0] + 24, $tempPos[1] + 24 + $_ListViewY, $tempPos[2] - $tempPos[0], $tempPos[3] - $tempPos[1], $CBS_DROPDOWNLIST) GUICtrlSetData($h_TempCtrl, "Include|Don't Include") GUICtrlSetState($h_TempCtrl, BitOR($GUI_FOCUS, $GUI_ONTOP)) _GUICtrlComboBox_ShowDropDown($h_TempCtrl, True) Case $_REGEX $tempPos = _GUICtrlListView_GetSubItemRect($h_ListView, $HitTest[0], $_REGEX) $h_TempCtrl = GUICtrlCreateCombo("", $tempPos[0] + 24, $tempPos[1] + 24 + $_ListViewY, $tempPos[2] - $tempPos[0], $tempPos[3] - $tempPos[1], $CBS_DROPDOWNLIST) GUICtrlSetData($h_TempCtrl, "String|StringRegExp") GUICtrlSetState($h_TempCtrl, BitOR($GUI_FOCUS, $GUI_ONTOP)) _GUICtrlComboBox_ShowDropDown($h_TempCtrl, True) Case $_FILTER $tempPos = _GUICtrlListView_GetSubItemRect($h_ListView, $HitTest[0], $_FILTER) Local $hRegion = _WinAPI_CreateRectRgn($tempPos[0] + 24, $tempPos[1] + 24 + $_ListViewY, $tempPos[2], $tempPos[3]) $h_TempCtrl = GUICtrlCreateInput(_GUICtrlListView_GetItemText($h_ListView, $HitTest[0], 3), $tempPos[0] + 24, $tempPos[1] + 24 + $_ListViewY, $tempPos[2] - $tempPos[0], $tempPos[3] - $tempPos[1]) GUICtrlSetState($h_TempCtrl, BitOR($GUI_FOCUS, $GUI_ONTOP, $GUI_SHOW)) _GUICtrlEdit_SetSel($h_TempCtrl, 0, -1) _WinAPI_RedrawWindow($h_GUI, 0, $hRegion, $RDW_UPDATENOW) ; It won't draw the control until mouse-out *** (WHY??) EndSwitch EndIf EndFunc Func _GUICtrlTemp_Apply( $caller ) ; Apply the temporary control's text to the ListView If $TempCtrlStatus[0] Then $TempCtrlStatus[0] = False _GUICtrlListView_SetItemText($h_ListView, $TempCtrlStatus[1], GUICtrlRead($h_TempCtrl), $TempCtrlStatus[2]) $TempCtrlStatus[1] = -1 $TempCtrlStatus[2] = -1 _GUICtrlTemp_Delete($caller & " -> Apply") EndIf EndFunc Func _GUICtrlTemp_Delete( $caller ) ConsoleWrite("Delete called by: " & $caller & @LF & "$h_TempCtrl: " & $h_TempCtrl & @LF & @SEC & ':' & @MSEC & @LF & @LF) ; Get rid of the temporary control GUICtrlDelete($h_TempCtrl) EndFunc
    • LordBoling
      By LordBoling
      Hello everyone! Hope you are having great days.
      I unfortunately am in need of assistance.

      I am in the process of creating a program that will allow me to search 2 systems that my company uses that store customer info.
      At this time if a customer places an order it could be in our online only system, our in-store system, or both at the same time. So instead of searching one manually, then the other, I decided to code a script that would look in both at the same time until it find the order. It has a few issues though.

      Issue #1 (Solved, Thank you BrewManNH!): I have two GUIs that I created, but apparently created wrong as the first one never closes until the script ends completely or if they press the red X, but is supposed to close when the user presses okay, but not end the script. This GUI is called in my code by a function called RefGui().
      Issue #2 (Solved): This same GUI is supposed to return a reference id entered by the user in an input field and what type of reference number it is by selecting a radio button. However, when used like it was intended it only returns the data from the input field. If nothing is put in the input field then it will return both the data in the input field and which radio selection is made.

      I have other issues but will probably deal with them once I have those figured out. If someone could take a look at my code and give me some ideas I would appreciate it.


      #include "CSV.au3" #include "Array.au3" #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> Opt("WinWaitDelay",100) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) Opt("SendCapslockMode",1) $objErr = ObjEvent("AutoIt.Error","MyErrFunc") ;Open Connection to OsCommerce database $oConn = ObjCreate("ADODB.Connection") $oConn.Open(;Connection string to my first database) ;Open Connection to Mas90 database $conn = ObjCreate("ADODB.Connection") $DSN = ;Connection string for my second database $conn.Open($DSN) ;Define var for reference type as global w/ initial value/Moved per BrewManNH's suggestion Global $refType="Internet" ;Loop until user closes first GUI w/ close button While 1 ;~ ;Define var for reference type as global w/ initial value ;~ Global $refType="Internet" ;Ask for order number or invoice number: (This opens first gui) $refNum=RefGui() ;Start text var to display message. $OrderMsg=$refNum & @CRLF & $refType ;If user selected internet search OsCommerce. Otherwise this won't be necessarily. If $refType="Internet" Then ;Query status and comments $rs = $oConn.Execute("SELECT orders.orders_status,orders_status_history.comments FROM orders,orders_status_history WHERE orders.orders_id='"& $refNum &"' AND orders_status_history.orders_status_id=orders.orders_status AND orders_status_history.orders_id=orders.orders_id") ;Make sure a result was returned then get results If IsObj($rs) And $rs.EOF=False Then $osStatus = $rs.GetRows() $rs = $oConn.Execute("SELECT orders_status_name FROM orders_status WHERE orders_status_id ='"& $osStatus[UBound($osStatus)-1][0] &"'") $temp=$rs.GetRows() $osStatus[UBound($osStatus)-1][0]=$temp[0][0] $OrderMsg+="OsCommerce:" & @CRLF $OrderMsg+=@TAB & "Status:" & $osStatus[UBound($osStatus)-1][0] & @CRLF $OrderMsg+=@TAB & "Comments:" & $osStatus[UBound($osStatus)-1][1] & @CRLF Else $osStatus = 0 EndIf EndIf ;If internet or sales were chosen then check if it has been put in Mas90 yet. If $refType="Internet" Or $refType="Sales" Then $rs = $conn.Execute("SELECT OrderType FROM SO_SalesOrderHeader WHERE (SalesOrderNo='"& $refNum &"')") If IsObj($rs) And $rs.EOF=False Then $SOStatus = $rs.GetRows() $OrderMsg+="Sales Order:" & @CRLF $OrderMsg+=@TAB & "Status:" & $SOStatus[0][0] & @CRLF $rs = $conn.Execute("SELECT ItemCode,ItemCodeDesc,QuantityOrdered,QuantityBackordered FROM SO_SalesOrderDetail WHERE (SalesOrderNo='"& $refNum &"' AND ItemType='1')") If IsObj($rs) And $rs.EOF=False Then $SOItems = $rs.GetRows() $OrderMsg+=@TAB & "Items:" & @CRLF $i=0 While $i<UBound($SOItems)-1 $OrderMsg+=@TAB & @TAB & "(" & $SOItems[$i][0] & ") " & $SOItems[$i][1] & @CRLF $rs = $conn.Execute("SELECT TotalQuantityOnHand FROM CI_Item WHERE (ItemCode='"& $SOItems[$i][0] &"')") If IsObj($rs) And $rs.EOF=False Then $item = $rs.GetRows() $OrderMsg+=@TAB & @TAB & "Ordered/Available: " & $SOItems[$i][2] & "/" & $item[0][0] & @TAB & "Backordered: " & $SOItems[$i][3] & @CRLF EndIf $i+=1 WEnd Else $SOItems = 0 EndIf Else $SOStatus = 0 EndIf $rs = $conn.Execute("SELECT InvoiceNo, SalesOrderNo FROM SO_InvoiceHeader WHERE (SalesOrderNo='"& $refNum &"')") If IsObj($rs) And $rs.EOF=False Then $InvStatus = $rs.GetRows() $rs = $conn.Execute("SELECT InvoiceNo,ItemCode,ItemCodeDesc,QuantityOrdered,QuantityBackordered FROM SO_InvoiceDetail WHERE (InvoiceNo='"& $InvStatus[0][0] &"' AND ItemType=1)") If IsObj($rs) And $rs.EOF=False Then $InvItems = $rs.GetRows() Else $InvItems = 0 EndIf Else $InvStatus = 0 EndIf $rs = $conn.Execute("SELECT InvoiceNo, SalesOrderNo FROM AR_InvoiceHistoryHeader WHERE (SalesOrderNo='"& $refNum &"')") If IsObj($rs) And $rs.EOF=False Then $InvHst = $rs.GetRows() $rs = $conn.Execute("SELECT InvoiceNo,ItemCode,ItemCodeDesc,QuantityOrdered,QuantityBackordered FROM AR_InvoiceHistoryDetail WHERE (InvoiceNo='"& $InvHst[0][0] &"' AND ItemType=1)") If IsObj($rs) And $rs.EOF=False Then $InvItems = $rs.GetRows() Else $InvItems = 0 EndIf Else $InvHst = 0 EndIf ElseIf $refType="Invoice" Then $rs = $conn.Execute("SELECT InvoiceNo, SalesOrderNo FROM AR_InvoiceHistoryHeader WHERE (InvoiceNo='"& $refNum &"')") If IsObj($rs) And $rs.EOF=False Then $InvHst = $rs.GetRows() $rs = $conn.Execute("SELECT InvoiceNo,ItemCode,ItemCodeDesc,QuantityOrdered,QuantityBackordered FROM AR_InvoiceHistoryDetail WHERE (InvoiceNo='"& $refNum &"' AND ItemType=1)") If IsObj($rs) And $rs.EOF=False Then $InvItems = $rs.GetRows() Else $InvItems = 0 EndIf Else $InvHst = 0 EndIf EndIf Gui($OrderMsg) WEnd ;This is the second GUI that displays the results Func Gui($txt) Local $myedit, $msg $hGUI=GUICreate("Details:", 500, 300, Default, Default,$WS_OVERLAPPEDWINDOW) ; will create a dialog box that when displayed is centered $GUISize=WinGetClientSize($hGUI) $myedit = GUICtrlCreateEdit($txt,-1, -1, $GUISize[0], $GUISize[1],$ES_READONLY) GUICtrlSetResizing ( $myedit, $GUI_DOCKBORDERS ) GUISetState() DllCall("user32.dll","int","HideCaret","int",0) Send("{END}") ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete($hGUI) EndFunc ;This is the first GUI. It asks for the information required to look up the order Func RefGui() $RefGui = GUICreate("Reference#", 261, 156, -1, -1) GUISetFont(10, 400, 0, "Verdana") GUICtrlCreateLabel("Enter Reference:", 15, 12, 116, 20) $RefNum = GUICtrlCreateInput("REFERENCE #", 136, 8, 110, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_UPPERCASE)) $OK = GUICtrlCreateButton("OK", 176, 120, 75, 25, BitOR($BS_DEFPUSHBUTTON,$BS_NOTIFY)) GUICtrlCreateGroup("Select Ref Type:", 16, 40, 145, 105, BitOR($GUI_SS_DEFAULT_GROUP,$WS_CLIPSIBLINGS)) $Internet = GUICtrlCreateRadio("Internet Order", 24, 64, 113, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Sales = GUICtrlCreateRadio("Sales Order", 24, 88, 113, 17) $Invoice = GUICtrlCreateRadio("Invoice", 24, 112, 113, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_CLOSE Then Exit If $nMsg = $OK Then ExitLoop EndIf WEnd If GUICtrlRead($Internet) = 1 Then $refType="Internet" ElseIf GUICtrlRead($Sales) = 1 Then $refType="Sales" ElseIf GUICtrlRead($Invoice) = 1 Then $refType="Invoice" EndIf $temp=GUICtrlRead($RefNum) GUIDelete($RefGui) Return $temp EndFunc Func MyErrFunc() $hexnum=hex($objErr.number,8) Msgbox(0,"","We intercepted a COM Error!!" & @CRLF & @CRLF & _ "err.description is: " & $objErr.description & @CRLF & _ "err.windescription is: " & $objErr.windescription & @CRLF & _ "err.lastdllerror is: " & $objErr.lastdllerror & @CRLF & _ "err.scriptline is: " & $objErr.scriptline & @CRLF & _ "err.number is: " & $hexnum & @CRLF & _ "err.source is: " & $objErr.source & @CRLF & _ "err.helpfile is: " & $objErr.helpfile & @CRLF & _ "err.helpcontext is: " & $objErr.helpcontext _ ) exit EndFunc
      Here is just the code for the first GUI so you don't have to look through all that:

      Func RefGui() $RefGui = GUICreate("Reference#", 261, 156, -1, -1) GUISetFont(10, 400, 0, "Verdana") GUICtrlCreateLabel("Enter Reference:", 15, 12, 116, 20) $RefNum = GUICtrlCreateInput("REFERENCE #", 136, 8, 110, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_UPPERCASE)) $OK = GUICtrlCreateButton("OK", 176, 120, 75, 25, BitOR($BS_DEFPUSHBUTTON,$BS_NOTIFY)) GUICtrlCreateGroup("Select Ref Type:", 16, 40, 145, 105, BitOR($GUI_SS_DEFAULT_GROUP,$WS_CLIPSIBLINGS)) $Internet = GUICtrlCreateRadio("Internet Order", 24, 64, 113, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Sales = GUICtrlCreateRadio("Sales Order", 24, 88, 113, 17) $Invoice = GUICtrlCreateRadio("Invoice", 24, 112, 113, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_CLOSE Then Exit If $nMsg = $OK Then ExitLoop EndIf WEnd If GUICtrlRead($Internet) = 1 Then $refType="Internet" ElseIf GUICtrlRead($Sales) = 1 Then $refType="Sales" ElseIf GUICtrlRead($Invoice) = 1 Then $refType="Invoice" EndIf $temp=GUICtrlRead($RefNum) GUIDelete($RefGui) Return $temp EndFunc