Jump to content

Recommended Posts

Posted
9 minutes ago, junkew said:

apparently yes, i see some small change in cursor when you tab thru the window. But why move the mouse there as by Tab you already activate it.

After {Tab} just send "English" or whatever other value you want in the dropdown or when its a button most likely send "{Return}}  should do the trick

 

Doing the tab, tab,tab, enter will not work. When I tab all the way down to the resolution dropdown and I tab one more time, it skips the button and goes toward the html link below(advertising banner)

Posted (edited)
30 minutes ago, junkew said:

Then your only solution is to count x,y positions yourself and move mouse there and click

I didn't want it to come to that solution because doing it that way will not work on different resolutions / monitors :/

@junkew I think Image search could work, but when I try to work with it, the script doesn't execute and the mouse doesn't move to the image -- source 

Edited by JustinM
Posted

You could try using percentage math to estimate where it is on the screen.

Like if it's at

x = 800 on a 1000 wide monitor and x = 1200 on a 1500 wide monitor you know to do Monitor With * 0.8

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Posted (edited)
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the handle of the Notepad window using the classname of Notepad.
    Local $hWnd = WinGetHandle("[CLASS:Notepad]")

;//TODO
;   Local $hWnd = WinGetHandle("[REGEXPTITLE:Unigine.*]")

    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when trying to retrieve the window handle of Notepad.")
        Exit
    EndIf

    ; Display the handle of the Notepad window.
    ;MsgBox($MB_SYSTEMMODAL, "", $hWnd)

    ; Retrieve the client area of the Notepad window using the handle returned by WinWait.
    Local $aClientSize = WinGetClientSize($hWnd)

    ; Display the height and width of the client area.
    ;MsgBox($MB_SYSTEMMODAL, "", "Width: " & $aClientSize[0] & @CRLF & "Height: " & $aClientSize[1])

    ;  Retrieve the position as well as height and width of the active window.
    Local $aPos = WinGetPos($hWnd)

    ; Display the array values returned by WinGetPos.
    ; MsgBox($MB_SYSTEMMODAL, "", "X-Pos: " & $aPos[0] & @CRLF & "Y-Pos: " & $aPos[1] & @CRLF & "Width: " & $aPos[2] & @CRLF & "Height: " & $aPos[3])

    mousemove(($apos[0]+$apos[2])-round($apos[2]/10), ($apos[1]+$apos[3])-round($apos[3]/10))
    sleep(2000)
    MouseClick($MOUSE_CLICK_LEFT)

    sleep(2000)
    ; Close the Notepad window using the handle returned by WinGetHandle.
    WinClose($hWnd)
EndFunc   ;==>Example

above an example with notepad. Around TODO you have to match with your window title

Edited by junkew
  • 5 months later...
  • 6 years later...
Posted (edited)

 I am also trying to use this software (Unigine) to check System Performance  & GPU Temperature 

But Reading GPU Temperature still fail , may need someone help for it (nvcpl.dll)

But I Write the Code for Unignine  Auto Run  ( it can works  in different resolution .. I  had check it)

Share it as below  and hope it helps.  Although it has been many years.............

$Delay_Time=150
$Unigine_Path="C:\Program Files (x86)\Unigine\Heaven Benchmark 4.0\heaven.bat"
RUN_Unigine("extreme","X8","n","2560x1440")


;FUNC RUN_Unigine($Preset,$Anti_aliasing,$FullScreen,$Resolution)
    FUNC RUN_Unigine($Preset,$MSAA,$FullScreen,$Resolutiuon)
    ;****************************************************************************
    $X_Position=615 ;Mouse Click  X  Position , control it to always fix 
    ;Each ComboBOX Y Position
    ;Group1
    $Y_Language=176-2
    $Y_Preset=199-2
    ;Group2
    $Y_API=230-2
    $Y_Quality=252-2
    $Y_Tessellation=274-2
    $Y_Stereo_3D=299-2
    $Y_Multi_monitor=321-2
    $Y_Anti_aliasing=343-2
    ;Group3
    $Y_Full_Screen=366-2
    $Y_Resolutiuon=388-2
    ;Start Run Button 
    $Y_Run_Button=450-2
    ;****************************************************************************
    ;Unigine
    ;Check app is exist already then close reopen it
    Opt("WinTitleMatchMode", -2) ;1 = (default) Match the title from the start,2 = Match any substring in the title
    if WinExists( "Unigine ")   = 0 then                      ;To make sure there are no Prime95 Running ,if have running then close it & open it again
        run($Unigine_Path)   ;Run app
    Else
        while  WinExists( "Unigine ") =1
            Winclose( "Unigine ")                         ;Force to Close  windw If Multiple (Like FurMark have 2 window)
            sleep(500)
        WEnd
        sleep(2000)
        run($Unigine_Path)   ;Run app
    endif

    
    ;To verify Unigine already running or not ?
    WinActivate("Unigine ")
    $hWnd =WinWaitActive ( "Unigine ","",15 ) ;it mean it will wait 30 seconds for windows open ...once find window it will go below script immediately, if pass 30 seconds still not find ,it will return "0" and continue below script
    if $hWnd = 0 then     ;if note find ,jump message to notify user wrong
        BlockInput(0) ;
        MsgBox($MB_ICONERROR, "Error", "No Unigine is Running !!")
        Exit 0 ;Totally exit all Script(close Autoit)
    Endif
    Opt("WinTitleMatchMode", 1) ;1 = (default) Match the title from the start,2 = Match any substring in the title
    
    
    BlockInput(1) ;LOCK MOUSE/KB
    
    ;Start to Control Unigine
    WinActivate("Unigine ")
    $hWnd=WinWaitActive ("Unigine ","",15)
    sleep(5000)

    ;Check Preset setting======================================A
    Unigine_Item_Mouse_move_click($X_Position,$Y_Preset)
    Select
        Case $Preset="Custom"
            Unigine_Lists_Mouse_move_click("1")
        Case $Preset="Basic"
            Unigine_Lists_Mouse_move_click("2")
            Unigine_Item_Mouse_move_click($X_Position,$Y_Preset)
            Unigine_Lists_Mouse_move_click("1")
        Case $Preset="Extreme"
            Unigine_Lists_Mouse_move_click("3")
            Unigine_Item_Mouse_move_click($X_Position,$Y_Preset)
            Unigine_Lists_Mouse_move_click("1")
        Case Else
            ;N/A
    EndSelect

    ;Check Anti-aliasing setting===================================B
    Unigine_Item_Mouse_move_click($X_Position,$Y_Anti_aliasing)
    Unigine_Item_Mouse_move_click($X_Position,$Y_Anti_aliasing) ;double click to SELECT Item
    _Unigine_Send("{UP}",3) ; up to list1 reset to default 1item
    Unigine_Item_Mouse_move_click($X_Position,$Y_Anti_aliasing) ;one click to Open Combo Lists
    Select
        Case $MSAA="Off"
            Unigine_Lists_Mouse_move_click("1")
        Case $MSAA="x2"
            Unigine_Lists_Mouse_move_click("2")
        Case $MSAA="x4"
            Unigine_Lists_Mouse_move_click("3")
        Case $MSAA="x8"
            Unigine_Lists_Mouse_move_click("4")
        Case Else
            ;N/A
        EndSelect

    ;Check FullScreen setting====================================C
    SLEEP(600)
    If $FullScreen="Y" Then Unigine_Item_Mouse_move_click($X_Position,$Y_Full_Screen) ;click checkbox
        
    ;Check Resolution setting====================================D
    Unigine_Item_Mouse_move_click($X_Position,$Y_Resolutiuon)
    Unigine_Item_Mouse_move_click($X_Position,$Y_Resolutiuon) ;double click to SELECT Item
    _Unigine_Send("{UP}",25) ; up to list1 reset to default 1item
    Unigine_Item_Mouse_move_click($X_Position,$Y_Resolutiuon) ;one click to Open Combo Lists
    Select
        Case $Resolutiuon="System"
            Unigine_Lists_Mouse_move_click("1")
        Case $Resolutiuon="640X360"
            Unigine_Lists_Mouse_move_click("5")
        Case $Resolutiuon="960X540"
            Unigine_Lists_Mouse_move_click("6")
        Case $Resolutiuon="1024x576"
            Unigine_Lists_Mouse_move_click("7")
        Case $Resolutiuon="1280x720"
            Unigine_Lists_Mouse_move_click("8")
        Case $Resolutiuon="1366x768"
            Unigine_Lists_Mouse_move_click("9")
        Case $Resolutiuon="1600x900"
            Unigine_Lists_Mouse_move_click("10")
        Case $Resolutiuon="1920x1080"
            Unigine_Lists_Mouse_move_click("11")
        Case $Resolutiuon="2560X1440"
            Unigine_Lists_Mouse_move_click("12")
        Case Else
            ;N/A
    EndSelect
    
    ;Start to Run
    Unigine_Item_Mouse_move_click($X_Position,$Y_Run_Button)
EndFunc

Func _Unigine_Click_1times()
    $pos = MouseGetPos()
    MouseClick("left",$pos[0],$pos[1],1)
EndFunc

Func _Unigine_Send($Key,$Click_Times)
    for $i=1 to $Click_Times
        Send($Key)
        sleep(50)
    Next
EndFunc

Func Unigine_Item_Mouse_move_click($X,$Y)
    ;***************************************************************
    ;Unigine Base Window Solution is 750x587(766x626 is include Window Edge)
    $Native_X=750 ;Native Size
    $Native_Y=587 ;Native Size
    $Window_X_Edge_Offset=15-9 ;Vertical (Window Edge)
    $Window_Y_Edge_Offset=38-9 ;Horizontal  (Window Edge)
    ;***************************************************************
    $hWnd=WinActivate("Unigine ")
    $GetSize=WinGetClientSize($hWnd,"")
    $Current_Window_X_Size=$GetSize[0] ;Get Current Unigine Window Size X
    $Current_Window_Y_Size=$GetSize[1] ;Get Current Unigine Window Size Y
    $Calculate_X=($X-$Window_X_Edge_Offset)*($Current_Window_X_Size/$Native_X)+$Window_X_Edge_Offset
    $Calculate_Y=($Y-$Window_Y_Edge_Offset)*($Current_Window_Y_Size/$Native_Y)+$Window_Y_Edge_Offset
    AutoItSetOption ( "MouseCoordMode",0) ;relative coords to the active window ,1 is (default) absolute screen coordinates
    MouseMove($Calculate_X,$Calculate_Y)
    AutoItSetOption ( "MouseCoordMode",1) ;relative coords to the active window ,1 is (default) absolute screen coordinates
    _Unigine_Click_1times()
EndFunc

Func Unigine_Lists_Mouse_move_click($Y)
    ;***************************************************************
    ;Unigine Base Window Solution is 750x587(766x626 is include Window Edge)
    ;$Native_X=750 ;Native Size
    $Native_Y=587 ;Native Size
    ;$Window_X_Edge_Offset=15-9 ;Vertical (Window Edge)
    $Window_Y_Edge_Offset=38-9 ;Horizontal  (Window Edge)
    $Native_List_Height=14.5
    ;***************************************************************
    $hWnd=WinActivate("Unigine ")
    $GetSize=WinGetClientSize($hWnd,"")
    AutoItSetOption ( "MouseCoordMode",0) ;relative coords to the active window ,1 is (default) absolute screen coordinates
    $pos = MouseGetPos()
    $Calculate_X=$pos[0]
    $Current_Window_Y_Size=$GetSize[1] ;Get Current Unigine Window Size Y
    $Calculate_Y=($Native_List_Height)*($Current_Window_Y_Size/$Native_Y)
    MouseMove($Calculate_X,$pos[1]+$Calculate_Y*$Y)
    AutoItSetOption ( "MouseCoordMode",1) ;relative coords to the active window ,1 is (default) absolute screen coordinates
    _Unigine_Click_1times()
EndFunc

 

Edited by debbiejames

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