Jump to content
Sign in to follow this  
bf2forlife

Help, Counter with images?

Recommended Posts

bf2forlife

So im doing counter for game, so i took screenshot from all the numbers n stuff there and made .bmps of them(using _imagesearch function for locating them ingame)

I got already some crappy script that needs some fixing, so help would be good.

#include <GUIConstants.au3>
#include <ImageSearch.au3>
HotKeySet("{F7}","Close") 
Opt("GUIOnEventMode", 1)
Global $SSB = StringSplit("1|2|3|4|5|6|7|8|9|-|0|+|/|*|=|.", "|"), $bX = 8, $bY = 40
Global $SSB2 = StringSplit("1.bmp|2.bmp|3.bmp|4.bmp|5.bmp|6.bmp|7.bmp|8.bmp|9.bmp|-.bmp|0.bmp|+.bmp|slash.bmp|star.bmp|=.bmp", "|")
$x1=0
$y1=0
$Form1 = GUICreate("Lc", 108, 233, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $Form1)
$som = _ImageSearch($SSB2,1,$x1,$y1,0)
For $i = 1 To $SSB[0]
    If Not Mod($i, 3) Then
        $bX = 8
        $bY += 32
    Else
        $bX += 32
    EndIf
Next
$SSB = 0
GUISetState(@SW_SHOW)

Func Event()
    Switch GUICtrlRead(@GUI_CtrlId)
        Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-", "*", "/", "."
            GUICtrlSetData($som,  GUICtrlRead($som) & GUICtrlRead(@GUI_CtrlId)) 
        Case "="
            If Execute(GUICtrlRead($som)) Then GUICtrlSetData($som, Execute(GUICtrlRead($som)))
    EndSwitch
EndFunc
Func Close()
    while 1
    Sleep(100)
    WEND
EndFunc
Edited by bf2forlife

Share this post


Link to post
Share on other sites
bf2forlife

And here is the original counter code

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

Global $SSB = StringSplit("1|2|3|4|5|6|7|8|9|-|0|+|/|*|.|C|%|=", "|"), $bX = 8, $bY = 40

$Form1 = GUICreate("Lc", 108, 233, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $Form1)
GUISetBkColor(0xFFFF00)
$som = GUICtrlCreateInput("", 8, 8, 89, 21)
For $i = 1 To $SSB[0]
    GUICtrlCreateButton($SSB[$i], $bX, $bY, 27, 25, $BS_CENTER)
    GUICtrlSetOnEvent(-1, "Event")
    GUICtrlSetFont(-1, 10, 700, 0, "MS Sans Serif")
    If Not Mod($i, 3) Then
        $bX = 8
        $bY += 32
    Else
        $bX += 32
    EndIf
Next
$SSB = 0
GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch GUICtrlRead(@GUI_CtrlId)
        Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-", "*", "/", "."
            GUICtrlSetData($som,  GUICtrlRead($som) & GUICtrlRead(@GUI_CtrlId)) 
        Case "="
            If Execute(GUICtrlRead($som)) Then GUICtrlSetData($som, Execute(GUICtrlRead($som)))
        Case "C"
            GUICtrlSetData($som, "")
        Case "%"
           ;??? Percent, leave this one for you 
    EndSwitch
EndFunc

Func Close()
    Exit
EndFunc

Share this post


Link to post
Share on other sites
martin

And here is the original counter code

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

Global $SSB = StringSplit("1|2|3|4|5|6|7|8|9|-|0|+|/|*|.|C|%|=", "|"), $bX = 8, $bY = 40

$Form1 = GUICreate("Lc", 108, 233, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $Form1)
GUISetBkColor(0xFFFF00)
$som = GUICtrlCreateInput("", 8, 8, 89, 21)
For $i = 1 To $SSB[0]
    GUICtrlCreateButton($SSB[$i], $bX, $bY, 27, 25, $BS_CENTER)
    GUICtrlSetOnEvent(-1, "Event")
    GUICtrlSetFont(-1, 10, 700, 0, "MS Sans Serif")
    If Not Mod($i, 3) Then
        $bX = 8
        $bY += 32
    Else
        $bX += 32
    EndIf
Next
$SSB = 0
GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch GUICtrlRead(@GUI_CtrlId)
        Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-", "*", "/", "."
            GUICtrlSetData($som,  GUICtrlRead($som) & GUICtrlRead(@GUI_CtrlId)) 
        Case "="
            If Execute(GUICtrlRead($som)) Then GUICtrlSetData($som, Execute(GUICtrlRead($som)))
        Case "C"
            GUICtrlSetData($som, "")
        Case "%"
         ;??? Percent, leave this one for you 
    EndSwitch
EndFunc

Func Close()
    Exit
EndFunc
I've modified the original script and then made Pics instead of buttons. Since I haven't got your bitmaps I can't fully test it.

You need to spend a bit of time trying to understanding the original script. Possibly mine is less obvious but it lets you identify the control without using GuiCtrlRead which won't work for Pics.

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

Global $SSB = StringSplit("1|2|3|4|5|6|7|8|9|-|0|+|/|*|.|C|%|=", "|"), $bX = 8, $bY = 40

$Form1 = GUICreate("Lc", 108, 233, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $Form1)
GUISetBkColor(0xFFFF00)
$som = GUICtrlCreateInput("", 8, 8, 89, 21)
$FirstButID = $som + 1
For $i = 1 To $SSB[0]
    GUICtrlCreatePic($SSB2[$i] & ".bmp", $bX, $bY, 27, 25)
    GUICtrlSetOnEvent(-1, "Event")
    GUICtrlSetFont(-1, 10, 700, 0, "MS Sans Serif")
    If Not Mod($i, 3) Then
        $bX = 8
        $bY += 32
    Else
        $bX += 32
    EndIf
Next
;$SSB = 0
GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $FirstButID To $FirstButID + 14
            GUICtrlSetData($som, GUICtrlRead($som) & $SSB[@GUI_CtrlId - $FirstButID + 1])

        Case $FirstButID + 15;C
            GUICtrlSetData($som, "")
            
        Case $FirstButID + 16;%
            GUICtrlSetData($som, Execute(GUICtrlRead($som)) / 100)
            
        Case $FirstButID + 17;=
            If Execute(GUICtrlRead($som)) Then GUICtrlSetData($som, Execute(GUICtrlRead($som)))
    EndSwitch
EndFunc  ;==>Event

Func Close()
    Exit
EndFunc  ;==>Close
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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  

×