Qwerty212

Another IE zoom problem with a Wheel Time Selection

2 posts in this topic

Hello :bye:

 

I'm doing an program to calculate production times with a touch screen input.

I was looking to create something similar to the smartphones timepickers but I don't have the skills yet :sweating: so I looked on the net for examples that can be used inside an Autoit GUI.

I found a html file running a JQuery that was just perfect for my project: marinovdh's blog

It looks like this:

2.png

And it works like a charm in touch screen's with the same touch and feel of an smartphone control.

The sad part is that when I embbed this html in my gui I get this:

6.png

It's really tiny, so It's really difficult to use with the fingers.

I tried to edit the javascript code of the jquery to make the control bigger, but I messed it a lot (to the point that it didn't work at all).

I also tried to set the default zoom of the IE to 200% but it failed. The only way of getting the size that I needed was doing a "Control +" in the ActiveX element of the gui (and it doesn't quite looks good to see the element growing).

When I do the Control + trick I get the gui as I need it:

Sin%2Bt%25C3%25ADtulo.png

I've been using the search for some days but nothing as worked on me.

I've tried:

$oIE.document.style.zoom = 2
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom", "ZoomFactor", "REG_DWORD", "200000")

This is my current code (modified to extract pointless things)

#include <GUIConstants.au3>
#include <IE.au3>
#include <GuiEdit.au3>

;_WinAPI_ShowCursor(False);Just to hide the zoom trick ¬¬'


RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom", "ZoomFactor", "REG_DWORD", "200000"); It didn't work :(

Global $oIE = ObjCreate("Shell.Explorer"); What's the difference between this and $oIE = ObjCreate("Shell.Explorer.2")???

Local Const $sFont = "Arial"

$url = @ScriptDir & "\hora\example.html";An external jquery based html file with the hour selector

$GUIhora = GUICreate("HOUR SELECTION", 780, 340, 0, 0)
GUISetBkColor(0x000000)
GUISetState(@SW_SHOW, $GUIhora)

$labhora2 = GUICtrlCreateButton("00:00", 530, 80, 130, 70)
GUICtrlSetFont(-1, 32, 700, 1, $sFont, 5)

$now = GUICtrlCreateButton("NOW", 675, 80, 70, 70);just a button to let the users input the current time

$GUIActiveX = GUICtrlCreateObj($oIE, -15, -20, 418, 1500); I make the object as high to prevent that scrollbars are showed in the control
GUICtrlSetBkColor(-1,0x000000)
Sleep(20)

$oIE.navigate($url)
Sleep(200)

$pos = WinGetPos("HOUR SELECTION"); I zoom the control just taking the position of the gui and doing a Control + sending.
MouseClick("left", $pos[0] + 380, $pos[1] + 110)
ControlFocus($GUIhora, "", $GUIActiveX)
Send("^{+}")
Send("^{+}")
Send("^{+}")
Send("^{+}")

;~ _WinAPI_ShowCursor(True)

$oIE.document.body.scroll = "no"
$oIE.document.body.style.overflow = "hidden"


Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm"); I need to read the current value of each wheel...
Local $hora = _IEFormElementGetObjByName($oForm, "hora")
Local $minutosdec = _IEFormElementGetObjByName($oForm, "minutosdec")
Local $minutos = _IEFormElementGetObjByName($oForm, "minutos")

$vhora = _IEFormElementGetValue($hora)
$vmindec = _IEFormElementGetValue($minutosdec)
$vmin = _IEFormElementGetValue($minutos)

$previoushour = $vhora & ":" & $vmindec & $vmin

While 1
    Sleep(5)

    $vhora = _IEFormElementGetValue($hora);... so now with the values I can know in  real time the inputted time
    $vmindec = _IEFormElementGetValue($minutosdec)
    $vmin = _IEFormElementGetValue($minutos)

    $newhour = $vhora & " : " & $vmindec & $vmin

    If $newhour <> $previoushour Then; just to check that the button text will only be changed IF the time has changed in the wheel
        If $vhora < 10 Then ;I check if the hour selected is less than 10 to add a zero at the left of its value
            ControlSetText($GUIhora, "", $labhora2, "0" & $vhora & ":" & $vmindec & $vmin)
        Else
            ControlSetText($GUIhora, "", $labhora2, $vhora & ":" & $vmindec & $vmin)
            $previoushour = $newhour
        EndIf
    EndIf

    $msg = GUIGetMsg()

    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit

        Case $msg = $now
            $aPos = MouseGetPos();I check the window coordenates to move the mouse to the correct wheel
            _WinAPI_ShowCursor(False); I hide the cursor to make the wheel movement less embarasing

            $actualhour = @HOUR
            $Actualmin = @MIN

            $vhora = _IEFormElementGetValue($hora)
            $vmindec = _IEFormElementGetValue($minutosdec)
            $vmin = _IEFormElementGetValue($minutos)

            $hourmovement = Number($vhora) - Number($actualhour)
            $mindecmovement = Number($vmindec) - StringTrimRight($Actualmin, 1)
            $minmovement = Number($vmin) - StringTrimLeft($Actualmin, 1)

            ;Instead of moving the wheels with a constant speed I have coded a little loop to increase speed as I'm getting closer to the desired wheel position
            ;Unofrtunately I don't know how to scroll all the wheels at the same time
            ;I have also tried to change the value of the selection boxes in the IE element with a  _IEFormElementGetValue but it doesn't change the wheel position :(

            If Number($hourmovement) > 0 Then
                $pos = WinGetPos("HOUR SELECTION")
                MouseClick("left", $pos[0] + 50, $pos[1] + 100, 1)
                Sleep(10)
                $x = 0
                Do
                    Mousemove($pos[0] + 50, $pos[1] + 100, 1)
                    MouseWheel("up", 1)
                    Sleep(($hourmovement - $x) * 2)
                    $x = $x + 1
                Until $x = $hourmovement

            ElseIf Number($hourmovement) < 0 Then
                $pos = WinGetPos("HOUR SELECTION")
                $hourmovement = Number($hourmovement * (1 - 2))
                MouseClick("left", $pos[0] + 50, $pos[1] + 100, 1)
                Sleep(10)
                $x = 0
                Do
                    Mousemove($pos[0] + 50, $pos[1] + 100, 1)
                    MouseWheel("down", 1)
                    Sleep(($hourmovement - $x) * 2)
                    $x = $x + 1
                Until $x = $hourmovement
            EndIf

            If Number($mindecmovement) > 0 Then
                $pos = WinGetPos("HOUR SELECTION")
                MouseClick("left", $pos[0] + 240, $pos[1] + 100, 1)
                Sleep(10)
                $x = 0
                Do
                    Mousemove($pos[0] + 240, $pos[1] + 100, 1)
                    MouseWheel("up", 1)
                    Sleep(($mindecmovement - $x) * 15)
                    $x = $x + 1
                Until $x = $mindecmovement

            ElseIf Number($mindecmovement) < 0 Then
                $pos = WinGetPos("HOUR SELECTION")
                $mindecmovement = Number($mindecmovement * (1 - 2))
                MouseClick("left", $pos[0] + 240, $pos[1] + 100, 1)
                $x = 0
                Do
                    Mousemove($pos[0] + 240, $pos[1] + 100, 1)
                    MouseWheel("down", 1)
                    Sleep(($mindecmovement - $x) * 15)
                    $x = $x + 1
                Until $x = $mindecmovement
            EndIf


            If Number($minmovement) > 0 Then
                $pos = WinGetPos("HOUR SELECTION")
                MouseClick("left", $pos[0] + 320, $pos[1] + 100, 1)
                $x = 0
                Do
                    Mousemove($pos[0] + 320, $pos[1] + 100, 1)
                    MouseWheel("up", 1)
                    Sleep(10 + (($minmovement - $x) * 7))
                    $x = $x + 1
                Until $x = $minmovement
            ElseIf Number($minmovement) < 0 Then
                $pos = WinGetPos("HOUR SELECTION")
                $minmovement = Number($minmovement * (1 - 2))
                MouseClick("left", $pos[0] + 320, $pos[1] + 100, 1)
                $x = 0
                Do
                    Mousemove($pos[0] + 320, $pos[1] + 100, 1)
                    MouseWheel("down", 1)
                    Sleep(($minmovement - $x) * 7)
                    $x = $x + 1
                Until $x = $minmovement
            EndIf
            MouseMove($apos[0], $apos[1], 0)
            _WinAPI_ShowCursor(True)
    EndSelect
WEnd

This is the zip containing the html file and the javascript:  Hour Selector.zip

Any help on getting the hour selector already zoomed at 200% when gui appears would be really apreciatted.

 

Greets from Barcelona

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

As a workaround I have found this function from trancexx that gets the control handle of the embedded object, so I can hide the window until everything is zoomed and then show it on screen again:

 

;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; Get control handle
Global $hHandle = _GetObjectWinHandle($oIE)

;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

; Focus it
$oIE.document.focus

ControlSend($hHandle, 0, 0, "^{+}")
ControlSend($hHandle, 0, 0, "^{+}")
ControlSend($hHandle, 0, 0, "^{+}")
ControlSend($hHandle, 0, 0, "^{+}")
GUISetState(@SW_SHOW, $GUIhora)


Func _GetObjectWinHandle($oObject)

    Local $aCall = DllCall("oleacc.dll", "int", "WindowFromAccessibleObject", _
            "idispatch", $oObject, _
            "hwnd*", 0)

    If @error Or $aCall[0] Then
        Return SetError(1, 0, 0)
    EndIf

    Return $aCall[2]

EndFunc   ;==>_GetObjectWinHandle

Now I can show the IE zoomed while I try to figure how to modify the JQuery to have the size that I need directly without zooming.

 

Greets from Barcelona

Edited by Qwerty212
1 person likes this

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