Jump to content
Sign in to follow this  
Cormin

Increasing a Hex value by one

Recommended Posts

Cormin

I have a working script right now that I recorded using the included recorder.  It runs through my program perfectly except I have it wait for my input.  I basically just increase a hex value by one every time.  How can I make my script read a value and increase it by one in hex?  The program I use is the TI bq evaluation software, the hex value I'm increasing is basically in an excel sheet looking UI.  So you click on the box once to be able to edit the text in the box.  There are two instances where it does a backspace and a beep, thats where I want it to automatically change the value.
 
Any help would be highly appreciated!   Here is an example of what the program looks like.

#region ---Au3Recorder generated code Start (v3.3.7.0)  ---

#region --- Internal functions Au3Recorder Start ---
Func Au3RecordSetup()
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
EndFunc

Func WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc

AU3RecordSetup()
#endregion --- Internal functions Au3Recorder End ---

WinWaitActivate("Texas Instruments bq Gas Gauge Evaluation Software - bq27541V200 v2.00 - [EVSW Module]","Data Flash Constants")
MouseClick("left",48,198,1)
Sleep ( 1000 )
WinWaitActivate("Texas Instruments bq Gas Gauge Evaluation Software - bq27541V200 v2.00 - [Data Flash Constants]","Data Flash Constants")
MouseClick("left",177,159,1)
Sleep ( 1500 )
MouseClick("left",217,107,1)
Sleep ( 9000 )
MouseClick("left",628,431,1)
Beep(500, 500)
Sleep ( 800 )
MouseClick("left",628,431,1)
Sleep ( 800 )
Send("{BACKSPACE}")
Beep(500, 250)
Sleep ( 5000 )
MouseClick("left",494,149,1)
Sleep ( 1000 )
MouseClick("left",326,287,1)
Beep(500, 500)
Sleep ( 500 )
MouseClick("left",326,287,1)
Sleep ( 500 )
Send("{BACKSPACE}")
Beep(500, 250)
Sleep ( 5000 )
WinWaitActivate("Texas Instruments bq Gas Gauge Evaluation Software - bq27541V200 v2.00 - [Data Flash Constants]","")
MouseClick("left",725,154,1)
Sleep ( 800 )
MouseClick("left",1232,232,1)
Sleep ( 500 )
MouseClick("left",1232,232,1)
Sleep ( 500 )
Send("{BACKSPACE}{BACKSPACE}02{ENTER}")
Sleep ( 800 )
MouseClick("left",75,350,1)
Sleep ( 500 )
Beep(700, 500)
Sleep ( 5000 )
WinWaitActivate("Texas Instruments bq Gas Gauge Evaluation Software - bq27541V200 v2.00 - [bq27xxx Calibration]","&Calibrate Part as i")
MouseClick("left",163,210,1)
Sleep ( 5000 )
Beep(600, 500)
Sleep ( 5000 )
MouseClick("left",28,274,1)
Sleep ( 1000 )
WinWaitActivate("Texas Instruments bq Gas Gauge Evaluation Software - bq27541V200 v2.00 - [Pro screen: I2C over I2C lines]","Pro screen: I2C over")
MouseClick("left",399,327,1)
Sleep ( 1000 )
MouseClick("left",60,186,1)
Sleep ( 500 )
WinWaitActivate("Texas Instruments bq Gas Gauge Evaluation Software - bq27541V200 v2.00 - [Data Flash Constants]","Data Flash Constants")
Sleep ( 2000 )
MouseClick("left",660,157,1)
Sleep ( 1000 )
MouseClick("left",146,107,1)
Beep(500, 250)
Sleep ( 4000 )
MouseClick("left",47,487,1)
Sleep ( 500 )
WinWaitActivate("Texas Instruments bq Gas Gauge Evaluation Software - bq27541V200 v2.00 - [EVSW Module]","Data Flash Constants")
Sleep ( 500 )
MouseClick("left",293,213,1)
Beep(700, 300)
Beep(700, 300)
#endregion --- Au3Recorder generated code End ---
Edited by Cormin

Share this post


Link to post
Share on other sites
BrewManNH

$Number = 100
For $I = 1 to 10
    $Number += 1
    ConsoleWrite(Hex($Number) & @CRLF)
Next

Hex numbers are just decimal numbers in hexidecimal format.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Cormin
$Number = 100
For $I = 1 to 10
    $Number += 1
    ConsoleWrite(Hex($Number) & @CRLF)
Next

Hex numbers are just decimal numbers in hexidecimal format.

I have zero programming knowledge.  How can I incorporate this into my script?

Share this post


Link to post
Share on other sites
BrewManNH

I have no idea where you need to add the number to the script. Also whatever it is you're doing would be done a lot better without resorting to Send and MouseClick, use ControlSend and ControlClick instead.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Cormin

I have no idea where you need to add the number to the script. Also whatever it is you're doing would be done a lot better without resorting to Send and MouseClick, use ControlSend and ControlClick instead.

Sorry I've edited my main post.  It needs to read the value then increase it by one in two spots.  Theres a backspace and a beep right afterwards.  That's where it should do it.  Reading the current value is important because the program can mess up and start from zero if my board has a bad connection.

So lines 33 and 43 is where it should happen.

Edited by Cormin

Share this post


Link to post
Share on other sites
Cormin
$Number = 100
For $I = 1 to 10
    $Number += 1
    ConsoleWrite(Hex($Number) & @CRLF)
Next

Hex numbers are just decimal numbers in hexidecimal format.

Would this work if I just paste this into my script?  This is my first autoit script with no programming background.

Share this post


Link to post
Share on other sites
BrewManNH

You'd just need the $Number += 1 and the Hex($number) parts, but it should work. The first one adds 1 to the variable $Number and the second one gives you the hex value of that number.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Cormin

You'd just need the $Number += 1 and the Hex($number) parts, but it should work. The first one adds 1 to the variable $Number and the second one gives you the hex value of that number.

How does it know that $Number is the exact field that I'm editing.  Again I have zero programming knowledge, I made this script using just the recorder.

How do I define the variable with the field my script just clicked on?  Copy into the clipboard or something?

Edited by Cormin

Share this post


Link to post
Share on other sites
Cormin

If I'm able to help explain my situation better to anybody please ask.  I would very much like to get this working.

Share this post


Link to post
Share on other sites
Melba23

Cormin,

Welcome to the AutoIt forum. :)

First off I have lifted the "New Member" posting restriction, so no worries on that account. ;)

 

I have zero programming knowledge

Not a huge problem as we all started that way, but it does make life a little trickier at times. :whistle:

You made that script using the Recorder - so all it consists of is a bunch of clicks. In order to increase a value and enter it into your app, AutoIt first needs to know the current value - and that is going to be the major problem. I imagine we can quite easily enter the new value once it is calculated, but for that we need what is in the "cell" now. So we need to identify the "cell" in which you wish to "click" and try to read the value therein - in fact if we can do that we might well be able get rid of all these MuseClick lines which are never the best way to interact with an app. :)

You need to fire up the AutoIt Window Info tool - if you did a standard install it should be at C:Program FilesAutoIt3Au3Info.exe. Then select the "Control" tab and drag the little gunsight over the app and see if you get different values appearing in the window. If you do then we should be able to identify the individual "cells" of the app and read them - if not then we are in for a difficult time. :sweating:

So over to you - what happens when you run the tool on your app? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Cormin

Cormin,

...

 

Thanks so much for reaching out and helping!

Here's what I get.  It looks like the same values appear clicking a different "cell" but in that same selection box the tool makes.  It looks like the screenshot didnt catch my mouse.  It was on the "Ser Num" tab right next to 6D.  Also I'd like to point out that I've been using my recorded script for a few weeks daily, have not yet had it click in the wrong space.

Also if it helps, the way the program works, if I left click the cell once the text automatically becomes selected.  So if this can somehow read a selection that could work.

DYyOmk5.png

Edited by Cormin

Share this post


Link to post
Share on other sites
Melba23

Cormin,

 

Thanks so much for reaching out and helping!

Not so fast! ;)

The app uses an MSFlexGrid to display its data - and as far as I know you cannot interact with such controls using AutoIt beyond simple "clicks". They are VisualBasic created controls and do not use the standard Windows API commands - hence they are not accessible via standard AutoIt functions. So I do not believe that we are going to be able to read the value in the "cell" you click - which brings us to a shuddering halt in this thread. Sorry about that - perhaps someone else knows a way to get the text short of OCR, but I certainly do not. Sorry. :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Cormin

...

 

Here is what happens after one left click, the script already does this using my coordinates.  Cant it just do a ctrl-C then copy it to notepad or something edit, then copy and paste into the cell?

I have the script click the cell i need, then it will delete one digit off the serial number, then I manually type the next one and hit enter.

lGfOHDe.png

Share this post


Link to post
Share on other sites
Melba23

Carmin,

 

Cant it just do a ctrl-C then copy it to notepad or something edit, then copy and paste into the cell?

Aha, I did not realise it highlighted the content when clicked - so let us try that. ;)

In your script, after the click and the short pause following it, add these lines:

Send("^c")                      ; Copy the highlighted content - we hope
Sleep(100)                      ; Let the system stablilise
MsgBox(o, "Content", ClipGet()) ; Display the captured content - we hope
Run the script and see what appears in the MsgBox - if it is the contents of the "cell" we are in business! :)

M23

  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Cormin

...

 

I think we have a typo I don't know how to fix

C:UsersdpkDesktopnew i2c.au3 (34) : ==> Missing separator character after keyword.: 
MsgBox(o, "Content", ClipGet()) 
MsgBox(o^ ERROR
>Exit code: 1    Time: 0.217
 
 
If I manually ctrl-c after clicking once it works fine.  I can paste the content of the cell anywhere.
Edited by Cormin

Share this post


Link to post
Share on other sites
Melba23

Cormin,

Sorry, it has been a long day. That should be a numeric "0", not a lower-case "o". :>

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Cormin

Cormin,

...

 

No worries!  I seriously appreciate your help!  But this looks good to me!

SNyCZGX.png

Share this post


Link to post
Share on other sites
Melba23

Cormin,

Excellent! :thumbsup:

Now we need to do the magic and "increase by 1". So add these lines in place of the ones I posted earlier:

Send("^c")                      ; Copy the highlighted content - we hope
Sleep(100)                      ; Let the system stablilise
$vValue = ClipGet()             ; Place the value in a variable
$vValue += 1                    ; Add 1 to the value
Send($vValue)                   ; Send the amended value back to the app
Fingers crossed! :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Cormin

Cormin,

Excellent! :thumbsup:

Now we need to do the magic and "increase by 1". So add these lines in place of the ones I posted earlier:

Send("^c")                      ; Copy the highlighted content - we hope
Sleep(100)                      ; Let the system stablilise
$vValue = ClipGet()             ; Place the value in a variable
$vValue += 1                    ; Add 1 to the value
Send($vValue)                   ; Send the amended value back to the app
Fingers crossed! :)

M23

 

Is this in hex?  Sorry, not sure if I've mentioned that it needs to be.

Share this post


Link to post
Share on other sites
Melba23

Cormin,

So we do this: :)

Send("^c")                      ; Copy the highlighted content - we hope
Sleep(100)                      ; Let the system stablilise
$vValue = ClipGet()             ; Place the value in a variable
$vValue = Int($vValue + 1)      ; Add 1 to the value and convert to integer type
Send(Hex($vValue, 4))           ; Send the amended value back to the app - change the numeric value 4 if you need more characters
M23
  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

×