Nareshm

How to setup button in message box

3 posts in this topic

#1 ·  Posted

I create message box but i dont know how to add button action when i click it.

Help for : Add script for Button : Left, Right, Right Finger
example when i press Left finger button do Case $idNotepad
                $iPID = WinActivate ( " :PS :: Version - 2.8.0.0  - [eFS Bill]")
                        ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:btnReset]", "{esc}")
                        ControlClick ( " :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]")
                        ControlSend(" :DS  - eF:: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "^v")
                        ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "{enter}")
How to add like above ?
              
                                                          sorry for my bad english

Quote

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 425, 200)

    ; Create a button control.
    Local $idlf = GUICtrlCreateButton("Left Finger", 0, 170, 85, 25)
    Local $idleft = GUICtrlCreateButton("Left", 100, 170, 85, 25)
    Local $idr = GUICtrlCreateButton("Right", 240, 170, 85, 25)
    Local $iderf = GUICtrlCreateButton("Right Finger", 340, 170, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    Local $iPID = 0

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
           Case $GUI_EVENT_CLOSE
                ExitLoop


            Case $idlf
                ; Run Notepad with the window maximized.
                $iPID = WinActivate ( " :PS :: Version - 2.8.0.0  - [eFS Bill]")
                        ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:btnReset]", "{esc}")
                        ControlClick ( " :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]")
                        ControlSend(" :DS  - eF:: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "^v")
                        ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "{enter}")

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)

    ; Close the Notepad process using the PID returned by Run.
    If $iPID Then ProcessClose($iPID)
EndFunc   ;==>Example

 

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

see GUI Event:

While 1
        Switch GUIGetMsg()
           Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idlf
                MsgBox(64,"Oh", "You press button Left Finger")
                ; Add your code here: Do somethink when click on button "Left Finger"
            Case $idleft 
                MsgBox(64,"Oh", "You press button Left")
                ; Add your code here: Do somethink when click on button "Left"
            Case $idr
                MsgBox(64,"Oh", "You press button Right")
                ; Add your code here: Do somethink when click on button "Right"
            Case $iderf 
                MsgBox(64,"Oh", "You press button Right Finger")
                ; Add your code here: Do somethink when click on button "Right Finger"
        EndSwitch
    WEnd

 


Regards,
 

Share this post


Link to post
Share on other sites

#3 ·  Posted

11 hours ago, VIP said:

see GUI Event:

While 1
        Switch GUIGetMsg()
           Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idlf
                MsgBox(64,"Oh", "You press button Left Finger")
                ; Add your code here: Do somethink when click on button "Left Finger"
            Case $idleft 
                MsgBox(64,"Oh", "You press button Left")
                ; Add your code here: Do somethink when click on button "Left"
            Case $idr
                MsgBox(64,"Oh", "You press button Right")
                ; Add your code here: Do somethink when click on button "Right"
            Case $iderf 
                MsgBox(64,"Oh", "You press button Right Finger")
                ; Add your code here: Do somethink when click on button "Right Finger"
        EndSwitch
    WEnd

 

Thanks VIP

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

  • Similar Content

    • sree161
      By sree161
      Hi,
      i have a code which generates two numeric outputs.i have to save them in excel.
      Is there any way to export them to specific cells in excel???
    • tremolux66
      By tremolux66
      I use a monospace font for editing AutoIt scripts in SciTE (currently, CourierNew 9pt). Regardless of what font size I set in the configuration, when I start SciTE to resume editing the script text is one size smaller than I specified. When I type Ctrl+<numpad-slash> the text changes to the desired size. The same is true of the output pane, and I have to reset the size for both areas every time I start SciTE.
      IIRC, I've made few other changes to the configuration (e.g., changed the search highlight color and disabled Tidy), so this behavior seems odd. About SciTE says it's version 3.6.0 (Aug. 4, 2015).
      Any idea how to fix this?
    • user4157124
      By user4157124
      As they're opinion-based to some degree; how are AutoIt's best practices decided and do suggestions get considered?
      Some suggestions :
      For...To...Step...Next -loop variable-naming like $iN ($i1, $i2, etc.) : conforms to recommended naming convention, identifies level (albeit inverted to ExitLoop and ContinueLoop's convention) and enables SciTE selection-highlighting (requires minimum of 3 characters). Minimize logic in global scope, separate data & settings from logic, use of vertical space, project organization (folder structure, resource- and include file management). Example (loop variable-naming, minimizing logic in global scope and separation of settings from logic) :
      #include <Array.au3> Global Enum $RANDOM_RETURNFLOAT, _ $RANDOM_RETURNINTEGER Global Enum $EXITCODE_NONE Global Const $g_sChar0 = '-' Global Const $g_sChar1 = '+' Global Const $g_iAmountX = 10 Global Const $g_iAmountY = $g_iAmountX Main() Func Main() Local $aArray[$g_iAmountY][$g_iAmountX] For $i1 = 0 To $g_iAmountY - 1 For $i2 = 0 To $g_iAmountX - 1 $aArray[$i1][$i2] = Random(0, 1, $RANDOM_RETURNINTEGER) ? $g_sChar1 : $g_sChar0 Next Next _ArrayDisplay($aArray) Exit $EXITCODE_NONE EndFunc Example (project organization) :
      + project_folder + bak [backup files] + bin [distributed binaries and dependencies] + inc [non-standard include files] + res [resource files (icons, file+install files, etc.)] + usr [configuration files, databases, etc.] - script.au3 - script.exe Example (use of vertical space) :
      Func _DigitalRoot($iNum) Local $sNum = '' Local $aNum While $iNum > 9 $sNum = String($iNum) $aNum = StringSplit($sNum, '') $iNum = 0 For $i1 = 1 To $aNum[0] $iNum += Int($aNum[$i1]) Next WEnd Return $iNum EndFunc
    • wimhek
      By wimhek
      LS
      Is it possible to open file(s) in scite in read only mode ?
      If so, How ?
       
      Thnx
       
    • TotalAuto
      By TotalAuto
      Howdy All
      I've gone around and around in circles wasting hours trying to fix this problem to no avail so I thought I would try posting for help given there are some real smart people in this forum.
      Background
      I have 5 separate .au3 scripts that all do different basic tasks. For example:
      1.au3 = opens Chrome browser to obtain information from a specific website then closes
      2.au3 = opens an Excel workbook to run a macro then saves and closes
      3.au3 = Open two seperate workbooks and transfers data from one to the other then saves and closes
      4.au3 = .......etc
      5.au3 = .......etc
      These 5 separate scripts, doing completely different tasks, need to each run once per day at 5 different designated times within a day and then close. For example:
      1.au3 = 10am
      2.au3 = 12pm
      3.au3 = 2pm
      4.au3 = 4pm
      5.au3 = 5pm
      Problem
      I can not get these different scripts to reliably run at their designated times. When I manually run these scripts individually by using 'Go F5' they work perfectly. If I convert these scripts to an .exe and manually run each one they work about 98% of time.
      How can I schedule these different .au3 files or associated .exe files to reliably run each day at different times?
      Attempts To Fix The Issue
      1. I have tried converting each .au3 script into their own .exe file and use Window's Task Scheduler to run these .exe files at their designated time but the success rate  of running each .exe in full, to completion, without error is very low at about 30%. Things that commonly go wrong include a browser not opening but movement still continues on the desk top. Other times things just do not happen at all.
      2. I have Windows 7 64 bit and have tried creating and running both (x86) and (x64) .exe files but again reliability problems exist;
      3. I have also tried moving each .exe file to the My Documents folder as I read someone that keeping your files on your desktop ties your files to individual Windows user profiles which can cause AutoIt operating errors. Not sure if this is correct but thought I would try it anyway. It did not fix my issue.
      4. I installed a program called AlwaysUp which supposedly always reliably runs in the background and will reliably execute your AutoIt script or .exe files. Still have significant reliability issues.
      Therefore, can someone please provide advice on how I can get my 5 different .au3 files to run at 5 designated times through the day, every day, without fail? Overtime I will be creating more and more different .au3 files to run certain tasks throughout the day and do not want to create one large AutoIt file that continually runs and attempts to do all the different tasks itself.
      Any help is very appreciated.
      Thanks
      Dan