Jump to content
Siwa

Combobox down arrow execute another function

Recommended Posts

Hello autoit community, 

I want to execute a function when the combo box down arrow in clicked. I don't want it to show the dropdown list at all. I searched the forum, but I did not find any suitable source to work on.

I just want to show some text as the current date inside the combo box, and then when the dropdown arrow is pressed, I want it to show another GUI. I have created my own Data Picker calendar with JavaScript, and I want it to be displayed when the down arrow is clicked.

Is there a possibility perform this action ?

 

Share this post


Link to post
Share on other sites
53 minutes ago, Siwa said:

I don't want it to show the dropdown list at all

Isn't that an abnormal behavior for a Windows control ?  Why don't you simply use a Label box or something more appropriate ?  Just asking...

Share this post


Link to post
Share on other sites

I know it is odd for the controller, but I want to display it as an input box for a data picker GUI. Is there anyway other way you can think of ?

Share this post


Link to post
Share on other sites

Maybe show your script, it would be easier to have some code to test and understand your issue...

Share this post


Link to post
Share on other sites
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WinAPI.au3>
#Include <Misc.au3>
#include <Date.au3>

Global $Persian_JS_Date
Local $hDLL = DllOpen("user32.dll")
Local $AlphaKey = 1 ; the transparent color of your choice


$Main_GUI = GUICreate(550,500)
$Show_Calendar = GUICtrlCreateButton("Show Calendar",350,150,100,50)
$Combo_Box = GUICtrlCreateCombo(_NowDate ( ),350,250,100,50)

$Date_GUI = GUICreate("Persian Calendar", 330, 255, -1, -1, $WS_POPUP+$WS_CLIPCHILDREN, $WS_EX_LAYERED)
GUISetBkColor($AlphaKey, $Date_GUI)
_WinAPI_SetLayeredWindowAttributes($Date_GUI, $AlphaKey , 0, $LWA_COLORKEY)

$Persian_Date_IE = _IECreateEmbedded()


$Persian_Calendar_Obect = GUICtrlCreateObj($Persian_Date_IE, -20, -63, 1000, 1000)
_IENavigate($Persian_Date_IE, @ScriptDir & "\ShamsiCalendar\jalali.html")
$Persian_Date_IE.document.body.style.backgroundColor = $AlphaKey


GUISetState(@SW_SHOW,$Main_GUI)

$Date_GUI_Close = GUICreate("Persian Calendar Close",200,200, 50, 24,$WS_POPUP+$WS_CLIPSIBLINGS ,$WS_EX_LAYERED,$Date_GUI)
GUISetBkColor($AlphaKey, $Date_GUI_Close)
GUISwitch($Date_GUI_Close)
_WinAPI_SetLayeredWindowAttributes($Date_GUI_Close, $AlphaKey , 0, $LWA_COLORKEY)
$Exit_Button_Calendar_GUI = GUICtrlCreateButton("Close", 0, 0, 50, 24)



While 1
    GUISwitch($Date_GUI)
    $msg = GUIGetMsg()

    Switch $msg
        Case $Exit_Button_Calendar_GUI
            GUISetState(@SW_HIDE,$Date_GUI)
            GUISetState(@SW_HIDE,$Date_GUI_Close)
            GUISwitch($Main_GUI)
        Case $Show_Calendar
            GUISetState(@SW_SHOW,$Date_GUI)
            GUISetState(@SW_SHOW,$Date_GUI_Close)

        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch


    $Persian_JS_Date = 0
    $nLeftclicks = 0
    If _IsPressed("01", $hDLL) Then ;If left mouse button pressed
        $Pos = MouseGetPos() ;Get mouse position
        Do
            While (_IsPressed("01", $hDLL)) ;Wait until user releases button
                Sleep(10)
            WEnd
            $nLeftclicks += 1 ;Increment click count
            sleep(100) ;Wait for 100ms
            $aTemp = MouseGetPos() ;Get new mouse position again
        Until(Not ($aTemp[0] = $Pos[0] and $aTemp[1] = $Pos[1] and _IsPressed("01", $hDLL))) ;Loop until mouse is on a new position or it is not pushed again
    EndIf


    If  $nLeftclicks = "2" and $Persian_Date_IE.document.getElementById('display_area_1').innertext<> "1399" Then
        $Persian_JS_Date = $Persian_Date_IE.document.getElementById('display_area_1').innertext
        $cDate = $Persian_JS_Date
        MsgBox(0,"",$cDate)
        $Persian_Date_IE.document.getElementById('display_area_1').innertext = '1399';
        GUISetState(@SW_HIDE,$Date_GUI)
        Exit
    EndIf

    $winpos = WinGetPos($Date_GUI)
    WinMove("Persian Calendar Close", "", $winpos[0] + $winpos[2], $winpos[1])

WEnd

Sorry for the mess, it is a part of another log code.

I want to show the GUI when the down arrow of the combo box is clicked instead of the button. 

Share this post


Link to post
Share on other sites

It doesn't work well for me.  Calendar is cropped and overlaps other controls.  But this is not important for your issue.  I would think that my first impression of using a label box would work far better than a pseudo-combo-box. 

#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WinAPI.au3>
#include <Misc.au3>
#include <Date.au3>

Global $Persian_JS_Date
Local $hDLL = DllOpen("user32.dll")
Local $AlphaKey = 0xFFFF00 ; the transparent color of your choice


$Main_GUI = GUICreate("", 550, 500)
$Show_Calendar = GUICtrlCreateButton("Show Calendar", 350, 150, 100, 50)
$idBox = GUICtrlCreateLabel(_NowDate(), 350, 250, 100, 50, $SS_SUNKEN + $SS_CENTER + $SS_CENTERIMAGE)

$Date_GUI = GUICreate("Persian Calendar", 330, 255, -1, -1, $WS_POPUP + $WS_CLIPCHILDREN, $WS_EX_LAYERED)
GUISetBkColor($AlphaKey, $Date_GUI)
_WinAPI_SetLayeredWindowAttributes($Date_GUI, $AlphaKey, 0, $LWA_COLORKEY)

$Persian_Date_IE = _IECreateEmbedded()


$Persian_Calendar_Obect = GUICtrlCreateObj($Persian_Date_IE, -20, -63, 1000, 1000)
_IENavigate($Persian_Date_IE, @ScriptDir & "\jalali.html")
$Persian_Date_IE.document.body.style.backgroundColor = $AlphaKey


GUISetState(@SW_SHOW, $Main_GUI)

$Date_GUI_Close = GUICreate("Persian Calendar Close", 200, 200, 50, 24, $WS_POPUP + $WS_CLIPSIBLINGS, $WS_EX_LAYERED, $Date_GUI)
GUISetBkColor($AlphaKey, $Date_GUI_Close)
GUISwitch($Date_GUI_Close)
_WinAPI_SetLayeredWindowAttributes($Date_GUI_Close, $AlphaKey, 0, $LWA_COLORKEY)
$Exit_Button_Calendar_GUI = GUICtrlCreateButton("Close", 0, 0, 50, 24)



While 1
  GUISwitch($Date_GUI)
  $msg = GUIGetMsg()

  Switch $msg
    Case $Exit_Button_Calendar_GUI
      GUISetState(@SW_HIDE, $Date_GUI)
      GUISetState(@SW_HIDE, $Date_GUI_Close)
      GUISwitch($Main_GUI)
    Case $Show_Calendar
      GUISetState(@SW_SHOW, $Date_GUI)
      GUISetState(@SW_SHOW, $Date_GUI_Close)

    Case $GUI_EVENT_CLOSE
      Exit
    Case $idBox
      ConsoleWrite("Box has been clicked" & @CRLF)
      ; do your stuff here

  EndSwitch


  $Persian_JS_Date = 0
  $nLeftclicks = 0
  If _IsPressed("01", $hDLL) Then   ;If left mouse button pressed
    $Pos = MouseGetPos()     ;Get mouse position
    Do
      While (_IsPressed("01", $hDLL))       ;Wait until user releases button
        Sleep(10)
      WEnd
      $nLeftclicks += 1       ;Increment click count
      Sleep(100)       ;Wait for 100ms
      $aTemp = MouseGetPos()       ;Get new mouse position again
    Until (Not ($aTemp[0] = $Pos[0] And $aTemp[1] = $Pos[1] And _IsPressed("01", $hDLL)))    ;Loop until mouse is on a new position or it is not pushed again
  EndIf


  If $nLeftclicks = "2" And $Persian_Date_IE.document.getElementById('display_area_1').innertext <> "1399" Then
    $Persian_JS_Date = $Persian_Date_IE.document.getElementById('display_area_1').innertext
    $cDate = $Persian_JS_Date
    MsgBox(0, "", $cDate)
    $Persian_Date_IE.document.getElementById('display_area_1').innertext = '1399'    ;
    GUISetState(@SW_HIDE, $Date_GUI)
    Exit
  EndIf

  $winpos = WinGetPos($Date_GUI)
  WinMove("Persian Calendar Close", "", $winpos[0] + $winpos[2], $winpos[1])

WEnd

Also I would personally write an autoit calendar instead of using the JS code. 

Share this post


Link to post
Share on other sites

I tried too, even created another topic but no one helped unfortunately.

I'll apricate it if you can put me in the right direction, how to create my own calendar.

 

 

Share this post


Link to post
Share on other sites

I recently created a calendar with small effort, I know it is not perfect for you but I suppose it can get you a start up :

 

The displayed picture is now wrong but I do not have the ability to change it.

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...